hierarchical_config 0.7 → 0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a62f19f8a7966878ec50be8bf611d3c8f22bb4ee
4
- data.tar.gz: 2cd93af27c41376f9f6508382178f04a80ca6e1c
3
+ metadata.gz: a86651ea049840bd9eecbc107b5e58646d4977c2
4
+ data.tar.gz: f04aa3fb370aef955a4bd908238c2a8852732151
5
5
  SHA512:
6
- metadata.gz: 25eb992e932755e2528cf2be6b03cb693053ad14ec50c1d3ee7449b3b9eb5b4f5d7640ccd2a97ce9b6330f6fef4cc6234915c50182ef106180a4c1d0b3fe21af
7
- data.tar.gz: ab38d3da65541b0b1c5f5988490945a99c28ccf2dd13c21611ed7909a39f948a600fa5f3ab94f47aed605ddc0edd70e36e68eed0565427a5749c660a2ecbc28e
6
+ metadata.gz: ffac763d52d6c550b67b7462bdf730a82d543ab438f6a26830ce8dd0921b179bb1d2cd221e86ad2dc0b056157e0cde73feb8823554e80a83f6ec6b9c783257e4
7
+ data.tar.gz: d4fb91a9cd2c9f44c0923409f9cad436e98f7bc642c05d5de4fb30115fa2c392961c2f2b0c2c7727048393bee18a373c576d3445e2028b75ef0ae85595e54fcb
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.8.7"
4
+ - "1.9.3"
5
+ - "2.2.3"
6
+ script: ruby test/test.rb
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at tim@galeckas.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in hierarchical_config.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,41 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hierarchical_config (0.8)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ coderay (1.1.2)
10
+ diff-lcs (1.3)
11
+ method_source (0.9.0)
12
+ pry (0.11.3)
13
+ coderay (~> 1.1.0)
14
+ method_source (~> 0.9.0)
15
+ rake (10.5.0)
16
+ rspec (3.8.0)
17
+ rspec-core (~> 3.8.0)
18
+ rspec-expectations (~> 3.8.0)
19
+ rspec-mocks (~> 3.8.0)
20
+ rspec-core (3.8.0)
21
+ rspec-support (~> 3.8.0)
22
+ rspec-expectations (3.8.1)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.8.0)
25
+ rspec-mocks (3.8.0)
26
+ diff-lcs (>= 1.2.0, < 2.0)
27
+ rspec-support (~> 3.8.0)
28
+ rspec-support (3.8.0)
29
+
30
+ PLATFORMS
31
+ ruby
32
+
33
+ DEPENDENCIES
34
+ bundler (~> 1.16)
35
+ hierarchical_config!
36
+ pry (~> 0.11.3)
37
+ rake (~> 10.0)
38
+ rspec (~> 3.0)
39
+
40
+ BUNDLED WITH
41
+ 1.16.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Tim Galeckas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -130,3 +130,4 @@ You can access children nodes with a method call or an index operator, in any co
130
130
  AppConfig.check # => true
131
131
  AppConfig.check? # => true
132
132
  AppConfig.super_secret_password? # => true
133
+
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "hierarchical_config"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "hierarchical_config/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'hierarchical_config'
7
+ spec.version = HierarchicalConfig::VERSION
8
+ spec.authors = ['timgaleckas', 'tjbladez', 'jdfrens']
9
+ spec.email = 'tim@galeckas.com, nick@tjbladez.com'
10
+ spec.summary = 'Robust strategy for defining the configuration accross environments, machines, clusters'
11
+ spec.description = 'Robust strategy for defining the configuration accross environments, machines, clusters'
12
+ spec.homepage = 'http://github.com/timgaleckas/hierarchical_config'
13
+ spec.license = 'MIT'
14
+
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.16"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency "pry", "~> 0.11.3"
29
+ end
@@ -0,0 +1,3 @@
1
+ module HierarchicalConfig
2
+ VERSION = "0.9"
3
+ end
@@ -3,6 +3,8 @@ require 'yaml'
3
3
  require 'erb'
4
4
  require 'set'
5
5
 
6
+ require "hierarchical_config/version"
7
+
6
8
  module HierarchicalConfig
7
9
  REQUIRED = :REQUIRED
8
10
  #this is the incantation that works for ruby 1.8.7 (syck)
@@ -37,10 +39,23 @@ module HierarchicalConfig
37
39
  def to_hash
38
40
  @table.inject({}) do |hash, key_value|
39
41
  key, value = *key_value
40
- hash[key] = value.respond_to?( :to_hash ) ? value.to_hash : value
42
+ hash[key] = item_to_hash(value)
41
43
  hash
42
44
  end
43
45
  end
46
+
47
+ private
48
+
49
+ def item_to_hash(value)
50
+ case value
51
+ when Array
52
+ value.map{|item| item_to_hash(item)}
53
+ when OpenStruct
54
+ value.to_hash
55
+ else
56
+ value
57
+ end
58
+ end
44
59
  end
45
60
 
46
61
  class << self
@@ -132,18 +147,33 @@ module HierarchicalConfig
132
147
  def lock_down_and_ostructify!( hash, path, environment)
133
148
  errors = []
134
149
  hash.each do | key, value |
135
- case
136
- when value.respond_to?( :keys ) && value.respond_to?( :values )
137
- child_hash, child_errors = lock_down_and_ostructify!( value, path + '.' + key, environment )
138
- errors += child_errors
139
- hash[key] = child_hash
140
- when value == REQUIRED
141
- errors << "#{path}.#{key} is REQUIRED for #{environment}"
142
- else
143
- value.freeze
144
- end
150
+ hash[key], child_errors = lock_down_and_ostructify_item!(value, path + '.' + key, environment)
151
+ errors += child_errors
145
152
  end
146
153
  return OpenStruct.new(hash).freeze, errors
147
154
  end
155
+
156
+ def lock_down_and_ostructify_item!(value, path, environment)
157
+ errors = []
158
+ return_value = case value
159
+ when Hash
160
+ child_hash, child_errors = lock_down_and_ostructify!( value, path, environment )
161
+ errors += child_errors
162
+ child_hash
163
+ when Array
164
+ value.each_with_index.map do |item, index|
165
+ child_item, child_errors = lock_down_and_ostructify_item!( item, "#{path}[#{index}]", environment )
166
+ errors += child_errors
167
+ child_item
168
+ end.freeze
169
+ when REQUIRED
170
+ errors << "#{path} is REQUIRED for #{environment}"
171
+ nil
172
+ else
173
+ value.freeze
174
+ end
175
+
176
+ return return_value, errors
177
+ end
148
178
  end
149
179
  end
metadata CHANGED
@@ -1,17 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hierarchical_config
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.7'
4
+ version: '0.9'
5
5
  platform: ruby
6
6
  authors:
7
7
  - timgaleckas
8
8
  - tjbladez
9
9
  - jdfrens
10
10
  autorequire:
11
- bindir: bin
11
+ bindir: exe
12
12
  cert_chain: []
13
- date: 2012-07-19 00:00:00.000000000 Z
14
- dependencies: []
13
+ date: 2018-10-07 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bundler
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.16'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '1.16'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rake
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '10.0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '10.0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rspec
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '3.0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '3.0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: pry
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: 0.11.3
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: 0.11.3
15
71
  description: Robust strategy for defining the configuration accross environments,
16
72
  machines, clusters
17
73
  email: tim@galeckas.com, nick@tjbladez.com
@@ -19,10 +75,21 @@ executables: []
19
75
  extensions: []
20
76
  extra_rdoc_files: []
21
77
  files:
22
- - README.markdown
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - CODE_OF_CONDUCT.md
81
+ - Gemfile
82
+ - Gemfile.lock
83
+ - LICENSE.txt
84
+ - README.md
85
+ - bin/console
86
+ - bin/setup
87
+ - hierarchical_config.gemspec
23
88
  - lib/hierarchical_config.rb
89
+ - lib/hierarchical_config/version.rb
24
90
  homepage: http://github.com/timgaleckas/hierarchical_config
25
- licenses: []
91
+ licenses:
92
+ - MIT
26
93
  metadata: {}
27
94
  post_install_message:
28
95
  rdoc_options: []