A way to get data from json files
Add this line to your application's Gemfile:
gem 'inrules'
And then execute:
$ bundle
Or install it yourself as:
$ gem install inrules
You must define a folder in the root folder of your project as follow
in-files/
Inside of it you can define the files (without extension, just the name) with a json content. E.g.
in-files/common
in-files/environment-paths
in-files/runtime-info
in-files/another-input-data-file
#environment-paths
{
"ENVIRONMENT":{
"IC":{
"base_url":"https://ic.base_url.it"
},
"RC":{
"base_url":"https://rc.base_url.it"
},
"BETA":{
"base_url":"https://beta.base_url.it"
},
"PROD":{
"base_url":"https://app.base_url.com"
}
}
}
And a JSON file called in.rules specifying the files in in-files dir you want to load and get
#in.rules
{
"common" : ["common"],
"rule_1" : ["environment-paths","runtime-info","another-input-data-file"],
"rule_2" : []
}
params = Inrules.get_params("rule_1")
#=> a Hash with all data from specified files. "common" object & "rule_1" merged
#Note: passing no rule to get_params method, only "common" specifications will be returned
- Fork it ( https://github.com/romgrod/inrules/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request