Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lotus console doesn't load files in load_path #80

Closed
tak1n opened this issue Nov 16, 2014 · 4 comments
Closed

Lotus console doesn't load files in load_path #80

tak1n opened this issue Nov 16, 2014 · 4 comments
Assignees
Labels
Milestone

Comments

@tak1n
Copy link
Member

tak1n commented Nov 16, 2014

Given this example application:

require 'lotus'
require 'lotus/model'

module Timetracker
  class Application < Lotus::Application
    configure do
      root File.dirname(__FILE__)
      load_paths << [
        'controllers',
        'entities',
        'repositories'
      ]

      routes 'config/routes'
      mapping 'config/mapping'
    end
  end
end

And this entity:

module Timetracker
  module Entities
    class User
      include Lotus::Entity

      self.attributes = :name, :lastname, :email, :password, :activated
    end
  end
end

puts "hi"

When starting the application the user entity gets required via the load_path configuration.

timetracker-ruby ➤ be lotus server -p 3000                                                                                        git:master mri-2.1.5
hi
[2014-11-16 11:37:10] INFO  WEBrick 1.3.1
[2014-11-16 11:37:10] INFO  ruby 2.1.5 (2014-11-13) [x86_64-linux]
[2014-11-16 11:37:10] INFO  WEBrick::HTTPServer#start: pid=30579 port=3000

When starting the lotus console the entity isn't required:

timetracker-ruby ➤ be lotus console --applications=app/application.rb                                                             git:master mri-2.1.5
irb(main):001:0> 

The whole application can be found under: https://github.com/bennyklotz/timetracker-ruby

@tak1n
Copy link
Member Author

tak1n commented Nov 16, 2014

Did some digging.
Application.load is called when starting the app but not when starting the console.
Therefore all frameworks and configurations aren't loaded properly for the console.

https://github.com/lotus/lotus/blob/master/lib/lotus/application.rb#L121

When explicitly load! the application in the application class definition the configuration and frameworks are properly loaded for the console, but loaded twice when starting the app.

@tak1n
Copy link
Member Author

tak1n commented Nov 16, 2014

The problem is in https://github.com/lotus/lotus/blob/master/lib/lotus/commands/console.rb#L25
The application is required but not initialized.

In Console#start the proper applications should be initialized.

@tak1n
Copy link
Member Author

tak1n commented Nov 21, 2014

With #30 solved we could iterate over available Applications and call load! on them.

@jodosha jodosha added this to the v0.2.0 milestone Dec 20, 2014
@jodosha jodosha added the bug label Dec 20, 2014
@jodosha jodosha self-assigned this Dec 20, 2014
@jodosha
Copy link
Member

jodosha commented Dec 20, 2014

Solved by 29ca76f

@jodosha jodosha closed this as completed Dec 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants