Oshuma / app_config

Simple Ruby framework-agnostic application configuration.
http://oshuma.github.io/app_config/
MIT License
20 stars 7 forks source link

Feature: Rails3 Support #9

Closed jacquescrocker closed 14 years ago

jacquescrocker commented 14 years ago

AppConfig rocks! I'd like to provide better support with Rails (not a dependency, just provide support if Rails exists)

This will all be in a railtie so if Rails3 isnt being used, it wont be loaded in. No rails3 gem dependencies will need to be added to app_config.

I can help maintain the fixes. I'm currently changing my own app_config plugin to use yours (http://github.com/railsjedi/app_config/tree/old)

Just want to make sure this fix is welcome. Are you cool with it?

Thanks!

Oshuma commented 14 years ago

If, for example, you have this app_config.yml:

production:
  some_setting: 'production mode'
development:
  some_setting: 'development mode'

You can load it as such:

Rails.env  # => :production

AppConfig.setup do |config|
  config[:env] = Rails.env
  config[:path] = "#{Rails.root}/config/app_config.yml"
end

AppConfig[:some_setting]  # => 'production mode'

Since there is an environment mode, just like Rails' database config, I don't see any reason to add additional code to the library just to support Rails (or any framework). My original (and still existing) goal is for AppConfig to be pure Ruby, able to be used in any Ruby project, not conflicting with, or relying on, any specific framework. I tend to reject any patches that use anything other than core Ruby.

However, with that said, feel free to fork it and make any modifications you see fit. That's the reason it's open source. ;)

jacquescrocker commented 14 years ago

Alright, no prob. I think with some changes we can make it a kickass library for use with Rails. However, if you'd rather keep it simple thats cool as well.

Oshuma commented 14 years ago

Yea, simplicity is definitely a huge priority. I do think it'd be neat to have plugins, though. Maybe something like 'app_config-rails', 'app_config-sinatra', etc. where those gems would have 'app_config' as a dependency, and can include any framework specific things (Rails generator, etc.).

Thoughts?

jacquescrocker commented 14 years ago

Ok. I decided to create a rails_config gem that handles this http://github.com/railsjedi/rails_config

I'm evaluating whether to use AppConfig as a depency. It looks like you are cool with adding multiple storage engines and OStruct like access, so I should be able to switch my internal implementation of the config object to use your gem.

rails_config can then be the wrapper around it that provides generators and a nice first-time user experience for rails3 users