{"action":"created","issue":{"url":"https://api.github.com/repos/ib-ruby/ib-ruby/issues/116","labels_url":"https://api.github.com/repos/ib-ruby/ib-ruby/issues/116/labels{/name}","comments_url":"https://api.github.com/repos/ib-ruby/ib-ruby/issues/116/comments","events_url":"https://api.github.com/repos/ib-ruby/ib-ruby/issues/116/events","html_url":"https://github.com/ib-ruby/ib-ruby/issues/116","id":92144983,"number":116,"title":"Breaking down ib-ruby ","user":{"login":"arvicco","id":39557,"avatar_url":"https://avatars.githubusercontent.com/u/39557?v=3","gravatar_id":"","url":"https://api.github.com/users/arvicco","html_url":"https://github.com/arvicco","followers_url":"https://api.github.com/users/arvicco/followers","following_url":"https://api.github.com/users/arvicco/following{/other_user}","gists_url":"https://api.github.com/users/arvicco/gists{/gist_id}","starred_url":"https://api.github.com/users/arvicco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arvicco/subscriptions","organizations_url":"https://api.github.com/users/arvicco/orgs","repos_url":"https://api.github.com/users/arvicco/repos","events_url":"https://api.github.com/users/arvicco/events{/privacy}","received_events_url":"https://api.github.com/users/arvicco/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-30T17:00:54Z","updated_at":"2015-07-01T12:11:37Z","closed_at":null,"body":"Looks like I now have some dev time to spend on ib-ruby, so here are some ideas for improvement.\r\n\r\nAs it stands now, ib-ruby is a mess of code, trying to be all things to all people. This is a maintainance nightmare. In order to make it more maintainable, we need a set of repos each focused on specific aspect of ib-ruby. I suggest a following set of repos:\r\n1. ib-ruby-protocol. This gem focuses on IB wire protocol, converting incoming and outgoing messages from IB wire format to structured data format (json?) and vice versa. This gem should not contain any higher-lever models (Order, Tick, ...) - this will be a responsibility of higher-level gems.\r\n2. ib-ruby-specs. This will contain a set of specs common to any model of ib-ruby, regardless of the implementation\r\n3. ib-ruby-core. This contains modules and classes common to all model implementations.\r\n4. ib-ruby. Default lightweight model implementation. No Rails, no DB backing. I assume ActiveModel, but open to alternative suggestions.\r\n5. ib-ruby-db. ActiveRecord DB-backed models, no Rails.\r\n6. ib-ruby-rails. ActiveRecord models, Rails engine.\r\n\r\n(4-6) should be able to run common set of specs (2), as well as their own particular specs. All model implementations should support common DSL, but since they are decoupled from each other otherwise, they can have their own dependencies and stuff. So, if someone needs a simple lightweight script, he could use ib-ruby (4) without the need to install all the Rails dependencies.\r\n\r\nPlease let me know if you have any additional ideas or suggestions."},"comment":{"url":"https://api.github.com/repos/ib-ruby/ib-ruby/issues/comments/117636540","html_url":"https://github.com/ib-ruby/ib-ruby/issues/116#issuecomment-117636540","issue_url":"https://api.github.com/repos/ib-ruby/ib-ruby/issues/116","id":117636540,"user":{"login":"arvicco","id":39557,"avatar_url":"https://avatars.githubusercontent.com/u/39557?v=3","gravatar_id":"","url":"https://api.github.com/users/arvicco","html_url":"https://github.com/arvicco","followers_url":"https://api.github.com/users/arvicco/followers","following_url":"https://api.github.com/users/arvicco/following{/other_user}","gists_url":"https://api.github.com/users/arvicco/gists{/gist_id}","starred_url":"https://api.github.com/users/arvicco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arvicco/subscriptions","organizations_url":"https://api.github.com/users/arvicco/orgs","repos_url":"https://api.github.com/users/arvicco/repos","events_url":"https://api.github.com/users/arvicco/events{/privacy}","received_events_url":"https://api.github.com/users/arvicco/received_events","type":"User","site_admin":false},"created_at":"2015-07-01T12:11:37Z","updated_at":"2015-07-01T12:11:37Z","body":"One of the problems with a single gem is that it requires a gazillion of dependencies. If I want lightweight models for scripting, why would I need a whole bunch of Rails dependencies? Right now I've been reinstalling ib-ruby on a new machine from scratch, and it took me 3 hours just to tweak and resolve all dependencies.\r\n\r\nThat's why I'm suggesting 3 top-level gems: one for each use-case (lightweight, db-backed, Rails). Lightweight gem users don't need to mess with databases, migrations, Rails-specific stuff and so on.\r\n\r\nNow, why we need to separate wire protocol from core. Currently, our \"event loop\" in Connection#process_messages is a bit of a hack. If someone wants to integrate a proper event-loop framework (such as EventMachine), it's not possible - the code for message processing is tightly coupIed to message content. If we have a separate protocol-level parser, it becomes possible to reuse this parser  in alternative message-processing and event-driven frameworks.\r\n\r\nRegarding (3), it's not a big deal - I suggested it just to keep the specs DRY. Rather than copy the model specs to 3 top-level gems, it makes sense to keep them in a separate repo and incorporate by reference.\r\n\r\nAs a first step, I would probably try to extract ib-ruby-core (that defines protocol and plain message processing). This will go a long way towards decoupling ib-ruby code. In the process, I'll upgrade message processing to latest 9.72 TWS API."}}