Feature/engine support (Issue #11) #12

Open
wants to merge 6 commits into
from

Conversation

Projects
None yet
3 participants
@rthbound

rthbound commented Jan 7, 2013

Addresses #11 by generating an env.rb file that loads routes for any mounted engine and for the application itself (loads url_helpers for main_app and 'engine_name')

Warning, it's ugly... The thought of this code going into every spinach user's env.rb file grosses me out.

Perhaps it could be moved into the railties file...

@josepjaume

This comment has been minimized.

Show comment
Hide comment
@josepjaume

josepjaume Jan 16, 2013

Member

This is really cool :)

Member

josepjaume commented Jan 16, 2013

This is really cool :)

lib/spinach-rails/generators/rails.rb
@@ -9,6 +9,28 @@ def create_environment_file
require 'minitest/spec'
+module Spinach
+ class FeatureSteps
+ known_engines = ObjectSpace.enum_for(:each_object, ::Rails::Railtie.singleton_class).to_a

This comment has been minimized.

@josepjaume

josepjaume Jan 16, 2013

Member

This hack is pretty neat, but isn't there any other way to iterate through all the engines other than that? Also, I think this only works if spinach is loaded after all the other Engines am I right?

If that's the case, maybe this code should be initialized someplace here:

https://github.com/codegram/spinach-rails/blob/master/lib/spinach-rails/railtie.rb#L12

There should be a way to be sure we're the last gem to be initialized.

Or did I get something wrong?

@josepjaume

josepjaume Jan 16, 2013

Member

This hack is pretty neat, but isn't there any other way to iterate through all the engines other than that? Also, I think this only works if spinach is loaded after all the other Engines am I right?

If that's the case, maybe this code should be initialized someplace here:

https://github.com/codegram/spinach-rails/blob/master/lib/spinach-rails/railtie.rb#L12

There should be a way to be sure we're the last gem to be initialized.

Or did I get something wrong?

This comment has been minimized.

@josepjaume

josepjaume Jan 16, 2013

Member

Ok, I see you actually mentioned this on the Issue 👍

Do you have the time to maybe tackle the problem from the Railtie and we can then merge it into master?

@josepjaume

josepjaume Jan 16, 2013

Member

Ok, I see you actually mentioned this on the Issue 👍

Do you have the time to maybe tackle the problem from the Railtie and we can then merge it into master?

This comment has been minimized.

@rthbound

rthbound Jan 18, 2013

Would love to... Maybe you also noticed the engine is installed into vendor/plugins, support for which will be removed in Rails 4. May want to address that prior to merging, also.

@rthbound

rthbound Jan 18, 2013

Would love to... Maybe you also noticed the engine is installed into vendor/plugins, support for which will be removed in Rails 4. May want to address that prior to merging, also.

This comment has been minimized.

@txus

txus Sep 18, 2013

Member

@rthbound ObjectSpace is disabled by default in JRuby. I don't think it's a very good idea to use it if we plan to keep our cross-implementation support.

@txus

txus Sep 18, 2013

Member

@rthbound ObjectSpace is disabled by default in JRuby. I don't think it's a very good idea to use it if we plan to keep our cross-implementation support.

This comment has been minimized.

@rthbound

rthbound Sep 18, 2013

@txus
Totally fair. It's a handy hack, but agreeably not a solution we should merge.

@rthbound

rthbound Sep 18, 2013

@txus
Totally fair. It's a handy hack, but agreeably not a solution we should merge.

This comment has been minimized.

@txus

txus Sep 19, 2013

Member

If you get rid of ObjectSpace, it's a big +1 for me and I'll merge it right away :)

@txus

txus Sep 19, 2013

Member

If you get rid of ObjectSpace, it's a big +1 for me and I'll merge it right away :)

This comment has been minimized.

@rthbound

rthbound Nov 22, 2013

Looks like Rails::Engine.ancestors could replace searching ObjectSpace

@rthbound

rthbound Nov 22, 2013

Looks like Rails::Engine.ancestors could replace searching ObjectSpace

@rthbound

This comment has been minimized.

Show comment
Hide comment
@rthbound

rthbound Nov 22, 2013

@txus I've got something together, but tests are failing (even on a fresh clone)...

@txus I've got something together, but tests are failing (even on a fresh clone)...

@txus

This comment has been minimized.

Show comment
Hide comment
@txus

txus Dec 20, 2013

Member

@rthbound any luck?

Member

txus commented Dec 20, 2013

@rthbound any luck?

@rthbound

This comment has been minimized.

Show comment
Hide comment
@rthbound

rthbound Dec 20, 2013

@txus looks like the failures are due to problems with the test itself and likely not to do with the implementation. Have not yet confirmed.

@txus looks like the failures are due to problems with the test itself and likely not to do with the implementation. Have not yet confirmed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment