huyettings 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -0
  3. data/README.md +13 -5
  4. data/lib/huyettings.rb +14 -4
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9cea781accadc295e6feccf0bcbff3a974ab8b2
4
- data.tar.gz: 98540724a35c2f16c4ab73dc4d2658a55641c41d
3
+ metadata.gz: 236456afe9d299d9383d1a69570c911796bdd4a6
4
+ data.tar.gz: 5f921f0160b17a683ef83de9fceb527ff539b954
5
5
  SHA512:
6
- metadata.gz: bb9f9aaee6cc60183d4ae900525213c7921d7a8830601b95899cfbbc8d69ad7714a7ad2f7187c1c3daed81efae62af22d89a4a581d2f460da18cae4fb5f8cac4
7
- data.tar.gz: b1d842f3a95f0ee620eedf9e5e52b5cc21e9f4ca0511065d078933d06a6927134ea23cd743f9b123e201ef0d72062269688405cb92382fef6a97e5017ce145f4
6
+ metadata.gz: 68e5c0aca3b2b75c59d5899623117d2ac5a80befde2701f3c840eb1265e6efd6d180816f150245789a482d5261b79b133528a249c68b340fa452665d285df098
7
+ data.tar.gz: 3d08907517625d3964f0ddbf7272c4ae4145af85b993833283e8f501de079c07d6d9eb11d27fd8d4633c0a72a44982ada8dea7db5c5a99483ee66e3f4dae3741
data/.travis.yml CHANGED
@@ -2,4 +2,6 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.2.5
5
+ - 2.3.0
6
+ - 2.4.1
5
7
  before_install: gem install bundler -v 1.15.1
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Huyettings
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/huyettings`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Build Status](https://travis-ci.org/JanaVPetrova/huyettings.svg?branch=master)](https://travis-ci.org/JanaVPetrova/huyettings)
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ Supersimple configuration manager. Single level. Yaml. ERB. No more pain.
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,9 +22,17 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- config = Huyettings.new('/path/to/settings.yml', :my_shiny_env)
26
- config.setting1
27
- config.setting2
25
+ ```
26
+ test:
27
+ setting1: 'setting1'
28
+ setting2: <%= 1 + 2 %>
29
+ ```
30
+
31
+ ```ruby
32
+ config = Huyettings.new('/path/to/settings.yml', :my_shiny_env)
33
+ config.setting1
34
+ config.setting2
35
+ ```
28
36
 
29
37
  ## Contributing
30
38
 
data/lib/huyettings.rb CHANGED
@@ -2,7 +2,7 @@ require 'yaml'
2
2
  require 'erb'
3
3
 
4
4
  class Huyettings
5
- VERSION = '0.2.0'
5
+ VERSION = '0.3.0'.freeze
6
6
 
7
7
  attr_reader :filepath, :env
8
8
 
@@ -12,16 +12,26 @@ class Huyettings
12
12
  end
13
13
 
14
14
  def method_missing(method, *_args)
15
- env_settings[method.to_s]
15
+ env_settings[method.to_sym]
16
16
  end
17
17
 
18
18
  private
19
19
 
20
20
  def env_settings
21
- @env_settings ||= full_settings[env.to_s]
21
+ @env_settings ||= full_settings[env.to_sym]
22
22
  end
23
23
 
24
24
  def full_settings
25
- YAML::load(ERB.new(File.read(filepath)).result)
25
+ key_symbolizer(YAML.load(ERB.new(File.read(filepath)).result))
26
+ end
27
+
28
+ def key_symbolizer(hash)
29
+ hash.each_with_object({}) do |(key, value), memo|
30
+ if value.is_a? Hash
31
+ memo[key.to_sym] = key_symbolizer(value)
32
+ else
33
+ memo[key.to_sym] = value
34
+ end
35
+ end
26
36
  end
27
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: huyettings
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yana Petrova
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-25 00:00:00.000000000 Z
11
+ date: 2017-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler