Welcome to Settings-js

Code Climate Travis CI Dependency Status

Use application specific settings with Javascript.

As modern web applications rely more and more on javascript and frameworks like backbone/angular, it can be quite a hussle to maintain duplicate values in javascript and ruby.

Settings-js is designed to work with different settings backends. As of today, only Settingslogic is supported.

Getting started

Add this to your Gemfile

gem 'settings_js'

Add the following to an initializer:

  • Settings Backend (for the moment, only settingslogic is implemented)
  • Settings Class used by the application
  • List the keys that must be accessible in the javascript
SettingsJs.configuration do |config|
  config.backend = 'settings_logic'      # backend used
  config.klass   = Settings              # your own settings class
  config.keys    = %w(hosts custom.keys) # imported keys
end

Load the Javascript file and access the Settings class:

// = require settings-js/settings

Settings.hosts,host_name
# => 'http://localhost:8080'

Contributing

Once you've made your great commits:

  1. Fork settings_js
  2. Create a topic branch - git checkout -b my_branch
  3. Push to your branch - git push origin my_branch
  4. Create a Pull Request from your branch
  5. That's it!

License

Settings-js is released under the MIT License.