Welcome to Settings-js
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:
- Fork settings_js
- Create a topic branch - git checkout -b my_branch
- Push to your branch - git push origin my_branch
- Create a Pull Request from your branch
- That's it!
License
Settings-js
is released under the MIT License.