Project

info_hub

0.0
No release in over 3 years
Low commit activity in last 3 years
This gem delivers a simple DSL to read data from YAML files. That might be useful for storing some basic knowledge around the application.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0
>= 0

Runtime

 Project Readme

InfoHub

Gem Version

This gem delivers a simple DSL to read data from YAML files. It might be useful for storing some basic knowledge around the application.

Installation

Add the following code to your Gemfile and run bundle install

# Gemfile
gem 'info_hub'

and run bundle install

Create a new file which includes all syste-wide constants:

# config/info_hub.yml
percentage:
    min: 1
    max: 100

Then add path to that file to InfoHub paths (in config/initializers/info_hub.rb)

# config/initializers/info_hub.rb
InfoHub.info_hub_file_paths << File.expand_path('../info_hub.yml', __dir__)

InfoHub.finalize!

Before finalize! execution, you may add as many .yml files as you need. All of them will be deeply merged in the order they were added.

Usage

Now anywhere in you code you can:

InfoHub[:percentage] # => { min: 1, max: 100 }
# or the equivalent
InfoHub.fetch(:percentage) # => { min: 1, max: 100 }

You may also get some internal values:

# Similar to `dig` in ruby 2.3
InfoHub.get(:percentage, :min) # => 1
InfoHub.get(:percentage, :max) # => 100

Licence

See LICENSE file.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/virtuozzo/info_hub.