0.0
No commit activity in last 3 years
No release in over 3 years
Sharing same application settings between ruby and javascript
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

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.