config-reader 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c7ce214efba842d40d1adc82bf5313ca57f2f3099e510068d4a4f0739371bc47
4
- data.tar.gz: cbd23f6c1163bc9a84ba243cd7346d3a6b4a34c27092f1e2466e254b6d753557
3
+ metadata.gz: 7c7acec20176a0287255bd5bfef69fa7445d19d63f5073ee926fe7c6fb60e9e2
4
+ data.tar.gz: 873c7606ef11f1b8e8f63bf37a80a443f129145c2cdde6ab6c5bb6e2f95b22b2
5
5
  SHA512:
6
- metadata.gz: 6e4e3cbf47c540791af60f56e8333ab3ec4a88f5e3f656886e15a03c14d125085818f7f7317210122afee14b32ba62ad2223dba5f4d464bcfed129627ec98335
7
- data.tar.gz: 66c0d83bc8bd2bd4ffd4efd6b24aef8b2ce1eec124bac584c3175140aaccf3db0f53ccd179a6eb542c346cba74c01562b118f344494ec0495d967e4c7036482f
6
+ metadata.gz: dc52814e3832ce11f01512f56f3dc315757af119159491960df868d394018f39e044a3b19460d6fd5097e223a565d92c178bd909e3eca1eb488edabe4e550330
7
+ data.tar.gz: 3d73af20dd3f8abeb910ef99a83d2555260768c0903c9e9d9cc0b6f1bfa6222a5de4d9e56b3c027aab2b2ef08265ae9ba7293c4656c8337899e451c9d3ffb626
@@ -3,13 +3,30 @@ require 'erb'
3
3
  require 'ostruct'
4
4
  require 'yaml'
5
5
 
6
+ # Process the input as ERB and then YAML and return results as OpenStruct
6
7
  class ConfigReader
7
- # Process IO as ERB and then YAML
8
- # and return results as OpenStruct
9
- # @param [String] path
10
- # @param [String,Symbol] env
11
- # @return [OpenStruct]
12
- def self.load(path, env)
13
- OpenStruct.new(YAML.load(ERB.new(IO.read(path)).result)[env.to_s])
8
+ attr_reader :file_path, :environment
9
+
10
+ def initialize(file_path, environment)
11
+ @file_path = file_path
12
+ @environment = environment.to_s
13
+ end
14
+
15
+ def config
16
+ @config ||= OpenStruct.new(yaml)
17
+ end
18
+
19
+ private
20
+
21
+ def yaml
22
+ YAML.load(erb)[environment]
23
+ end
24
+
25
+ def erb
26
+ ERB.new(input).result
27
+ end
28
+
29
+ def input
30
+ IO.read(file_path)
14
31
  end
15
32
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  class ConfigReader
3
- VERSION = '0.0.2'
3
+ VERSION = '0.1.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config-reader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tulino