conferrable 1.0.4 → 1.1.0

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
  SHA256:
3
- metadata.gz: f92d8f5127c4ae292cb7bf8b9e7bd9600df9e71028cd31244dc334855c808be7
4
- data.tar.gz: cf2d99d1a036e1f50f06b115d1d56403e58542a906d8b171cd3dbff5017cb162
3
+ metadata.gz: 00f6b4e7506689f8ba9637674566b37e2013753f852bded56f5997c0349dfebc
4
+ data.tar.gz: 3bfe518753fca7d4cec7bcd6ef1d27c9f419c9305c07a2529eae7231b9a356db
5
5
  SHA512:
6
- metadata.gz: 6d18813bcbae5c777a0869a37a1a52cc63776112f5fdd004a177be75cef07c18663dbf5d6f0722a610e70ea2a0161e817152a9fec2d3be1dd2643fcf997a0847
7
- data.tar.gz: cc6214c934b5dc269efcfc6c70a0d532c50685b5600acabb15be4a42663f48784095dc264234794c238e89f6eb7d5d4e2f5ec013a301e6c272790931547be465
6
+ metadata.gz: 30d06435baeb16ebc3e00558ca9cff70b8c7e2a55f86750cd06233624557091eda29d5e70e4336b72b77f2c5da9011a5acf23c60c1935e324226c42600ea0a9f
7
+ data.tar.gz: baa56734cc264d44d6d698650e6d00953dec8978d7d453567b07685c071aeb3ccd7022df38d72cfb818e546fdd5e253de44b81ea73a051026b97743993618ef9
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  *.gem
3
3
  /tmp
4
4
  /coverage
5
+ Gemfile.lock
@@ -1 +1 @@
1
- 2.6.0
1
+ 2.6.3
@@ -5,9 +5,9 @@ language: ruby
5
5
  rvm:
6
6
  # Build on the latest stable of all supported Rubies (https://www.ruby-lang.org/en/downloads/):
7
7
  - 2.3.8
8
- - 2.4.5
9
- - 2.5.3
10
- - 2.6.0
8
+ - 2.4.6
9
+ - 2.5.5
10
+ - 2.6.3
11
11
  cache: bundler
12
12
  before_script:
13
13
  - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
@@ -18,3 +18,8 @@ script:
18
18
  - bundle exec rspec
19
19
  after_script:
20
20
  - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
21
+ addons:
22
+ # https://docs.travis-ci.com/user/uploading-artifacts/
23
+ artifacts:
24
+ paths:
25
+ - Gemfile.lock
@@ -1,3 +1,7 @@
1
+ # 1.1.0 (August 2nd, 2019)
2
+
3
+ Configuration files can now be plain YAML instead of YAML with ERB. Supported extensions are *.yml, *.yaml, *.yml.erb, and *.yaml.erb in upper, mixed, or lower case.
4
+
1
5
  # 1.0.4 (January 30th, 2019)
2
6
 
3
7
  Maintenance Release
data/README.md CHANGED
@@ -29,7 +29,7 @@ bundle add conferrable
29
29
  Lets say we have a configuration file located at:
30
30
 
31
31
  ````
32
- <app root>/config/config.yml.erb
32
+ <app root>/config/config.yaml
33
33
  ````
34
34
 
35
35
  We can access this by:
@@ -38,21 +38,23 @@ We can access this by:
38
38
  config = Conferrable.get_config # config will be a hash
39
39
  ````
40
40
 
41
+ Note that the configuration file can also be called config.yml (three character extension).
42
+
41
43
  ### Multiple File Example
42
44
 
43
45
  Building on the simple example, say we have two configuration files:
44
46
 
45
47
  ````
46
- <app root>/config/config1.yml.erb
47
- <app root>/config/config2.yml.erb
48
+ <app root>/config/config1.yaml
49
+ <app root>/config/config2.yaml
48
50
  ````
49
51
 
50
52
  We can now explicitly set the files:
51
53
 
52
54
  ````
53
55
  files = [
54
- './config/config1.yml.erb',
55
- './config/config2.yml.erb',
56
+ './config/config1.yaml',
57
+ './config/config2.yaml',
56
58
  ]
57
59
 
58
60
  Conferrable.set_filenames(:config, files)
@@ -70,6 +72,10 @@ config = Conferrable.get_config # config will be a hash
70
72
 
71
73
  Note that the files will be loaded in alphabetical order.
72
74
 
75
+ ### ERB Support ###
76
+
77
+ If a configuration file ends in '.erb', then it will be pre-processed by the ERB templating system. For example, a file named config.yaml.erb would first be processed by ERB and then parsed as a YAML file. This is helpful when dealing with more complex YAML files.
78
+
73
79
  ## Contributing
74
80
 
75
81
  ### Development Environment Configuration
@@ -102,6 +108,12 @@ Also, do not forget to run Rubocop:
102
108
  bundle exec rubocop
103
109
  ````
104
110
 
111
+ For convenience, the default rake task will run Rspec and Rubocop:
112
+
113
+ ```
114
+ bundle exec rake
115
+ ```
116
+
105
117
  ### Publishing
106
118
 
107
119
  Note: ensure you have proper authorization before trying to publish new versions.
@@ -109,14 +121,11 @@ Note: ensure you have proper authorization before trying to publish new versions
109
121
  After code changes have successfully gone through the Pull Request review process then the following steps should be followed for publishing new versions:
110
122
 
111
123
  1. Merge Pull Request into master
112
- 2. Update ```lib/conferrable/version.rb``` using [semantic versioning](https://semver.org/)
113
- 3. Install dependencies: ```bundle```
114
- 4. Update ```CHANGELOG.md``` with release notes
124
+ 2. Update `lib/conferrable/version.rb` using [semantic versioning](https://semver.org/)
125
+ 3. Install dependencies: `bundle`
126
+ 4. Update `CHANGELOG.md` with release notes
115
127
  5. Commit & push master to remote and ensure CI builds master successfully
116
- 6. Build the project locally: `gem build conferrable`
117
- 7. Publish package to RubyGems: `gem push conferrable-X.gem` where X is the version to push
118
- 8. Tag master with new version: `git tag <version>`
119
- 9. Push tags remotely: `git push origin --tags`
128
+ 6. Run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
120
129
 
121
130
  ## License
122
131
 
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[rubocop spec]
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  Conferrable standardizes how we interact with these static YAML configuration files.
14
14
  DESCRIPTION
15
15
 
16
- s.authors = ['Matthew Ruggio']
17
- s.email = ['mruggio@bluemarblepayroll.com']
16
+ s.authors = ['Matthew Ruggio', 'Ryan Gerry']
17
+ s.email = ['mruggio@bluemarblepayroll.com', 'rgerry@bluemarblepayroll.com']
18
18
  s.files = `git ls-files`.split("\n")
19
19
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.required_ruby_version = '>= 2.3.8'
25
25
 
26
26
  s.add_development_dependency('guard-rspec', '~>4.7')
27
+ s.add_development_dependency('rake', '~> 12')
27
28
  s.add_development_dependency('rspec')
28
29
  s.add_development_dependency('rubocop', '~>0.63.1')
29
30
  s.add_development_dependency('simplecov', '~>0.16.1')
@@ -20,11 +20,20 @@ module Conferrable
20
20
  end
21
21
 
22
22
  def read(filename)
23
- YAML.safe_load(ERB.new(IO.read(filename)).result)
23
+ file_content = IO.read(filename)
24
+
25
+ pre_processed_content =
26
+ filename.downcase.end_with?(ERB_EXTENSION) ? ERB.new(file_content).result : file_content
27
+
28
+ YAML.safe_load(pre_processed_content)
24
29
  end
25
30
 
26
31
  private
27
32
 
33
+ ERB_EXTENSION = '.erb'
34
+ FILE_MATCHER = /.+\.(ya?ml|ya?ml.erb)\Z/i.freeze
35
+ private_constant :ERB_EXTENSION, :FILE_MATCHER
36
+
28
37
  def list(filename)
29
38
  if File.exist?(filename) && File.directory?(filename)
30
39
  glob_files_only(filename)
@@ -36,8 +45,8 @@ module Conferrable
36
45
  end
37
46
 
38
47
  def glob_files_only(filename)
39
- dir_name = File.join(filename, '**', '*.yml.erb')
40
- Dir.glob(dir_name).reject { |f| File.directory?(f) }
48
+ dir_glob = File.join(filename, '**/*')
49
+ Dir.glob(dir_glob).grep(FILE_MATCHER).reject { |f| File.directory?(f) }
41
50
  end
42
51
  end
43
52
  end
@@ -8,5 +8,5 @@
8
8
  #
9
9
 
10
10
  module Conferrable
11
- VERSION = '1.0.4'
11
+ VERSION = '1.1.0'
12
12
  end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Copyright (c) 2018-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
10
+ require './spec/spec_helper'
11
+
12
+ describe Conferrable::FileUtilities do
13
+ let(:config_examples_path) { File.expand_path('../config_examples/', __dir__) }
14
+
15
+ describe 'resolving file names' do
16
+ it 'finds all YAML and YAML + ERB files with upper or lower case extensions' do
17
+ expected_files = Set.new([
18
+ File.join(config_examples_path, 'full.yaml.erb'),
19
+ File.join(config_examples_path, 'full.yaml'),
20
+ File.join(config_examples_path, 'simple.yml.erb'),
21
+ File.join(config_examples_path, 'simple.yml'),
22
+ File.join(config_examples_path, 'UPPER.YML.ERB'),
23
+ File.join(config_examples_path, 'UPPER.YML')
24
+ ])
25
+
26
+ expect(Set.new(described_class.resolve(config_examples_path))).to eq expected_files
27
+ end
28
+ end
29
+
30
+ describe 'reading/parsing YAML files' do
31
+ it 'returns a parsed YAML evaluated result for a *.yml file' do
32
+ file_path = File.join(config_examples_path, 'simple.yml')
33
+ expected_result = { 'key1' => ['element1', '<%= "ERB which will not evaluate" =>'] }
34
+
35
+ expect(described_class.read(file_path)).to eq(expected_result)
36
+ end
37
+
38
+ it 'returns a parsed YAML and ERB evaluated result for a *.yml.erb file' do
39
+ file_path = File.join(config_examples_path, 'simple.yml.erb')
40
+ expected_result = { 'key1' => %w[static_element dynamic_element] }
41
+
42
+ expect(described_class.read(file_path)).to eq(expected_result)
43
+ end
44
+
45
+ it 'returns a parsed YAML and ERB evaluated result for an upper case *.YML.ERB file' do
46
+ file_path = File.join(config_examples_path, 'UPPER.YML.ERB')
47
+ expected_result = { 'key1' => %w[static_element dynamic_element] }
48
+
49
+ expect(described_class.read(file_path)).to eq(expected_result)
50
+ end
51
+ end
52
+ end
File without changes
@@ -0,0 +1 @@
1
+ key1: [static_element, <%= 'dynamic' + '_' + 'element' %>]
File without changes
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ key1:
2
+ - element1
3
+ - '<%= "ERB which will not evaluate" =>'
@@ -0,0 +1 @@
1
+ key1: [static_element, <%= 'dynamic' + '_' + 'element' %>]
@@ -10,7 +10,7 @@
10
10
  require 'simplecov'
11
11
  require 'simplecov-console'
12
12
 
13
- require './lib/conferrable'
14
-
15
13
  SimpleCov.formatter = SimpleCov::Formatter::Console
16
14
  SimpleCov.start
15
+
16
+ require './lib/conferrable'
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conferrable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ruggio
8
+ - Ryan Gerry
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2019-02-04 00:00:00.000000000 Z
12
+ date: 2019-08-07 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: guard-rspec
@@ -24,6 +25,20 @@ dependencies:
24
25
  - - "~>"
25
26
  - !ruby/object:Gem::Version
26
27
  version: '4.7'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '12'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '12'
27
42
  - !ruby/object:Gem::Dependency
28
43
  name: rspec
29
44
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +101,7 @@ description: |2
86
101
  Conferrable standardizes how we interact with these static YAML configuration files.
87
102
  email:
88
103
  - mruggio@bluemarblepayroll.com
104
+ - rgerry@bluemarblepayroll.com
89
105
  executables:
90
106
  - console
91
107
  extensions: []
@@ -98,10 +114,10 @@ files:
98
114
  - ".travis.yml"
99
115
  - CHANGELOG.md
100
116
  - Gemfile
101
- - Gemfile.lock
102
117
  - Guardfile
103
118
  - LICENSE
104
119
  - README.md
120
+ - Rakefile
105
121
  - bin/console
106
122
  - conferrable.gemspec
107
123
  - lib/conferrable.rb
@@ -111,10 +127,19 @@ files:
111
127
  - lib/conferrable/file_based_configuration.rb
112
128
  - lib/conferrable/file_utilities.rb
113
129
  - lib/conferrable/version.rb
114
- - spec/conferrable_spec.rb
115
- - spec/configuration_spec.rb
116
- - spec/entry_spec.rb
117
- - spec/file_based_configuration_spec.rb
130
+ - spec/conferrable/conferrable_spec.rb
131
+ - spec/conferrable/configuration_spec.rb
132
+ - spec/conferrable/entry_spec.rb
133
+ - spec/conferrable/file_based_configuration_spec.rb
134
+ - spec/conferrable/file_utilities_spec.rb
135
+ - spec/config_examples/UPPER.YML
136
+ - spec/config_examples/UPPER.YML.ERB
137
+ - spec/config_examples/directory.yml/.gitkeep
138
+ - spec/config_examples/full.yaml
139
+ - spec/config_examples/full.yaml.erb
140
+ - spec/config_examples/not-yaml.txt
141
+ - spec/config_examples/simple.yml
142
+ - spec/config_examples/simple.yml.erb
118
143
  - spec/spec_helper.rb
119
144
  homepage: https://github.com/bluemarblepayroll/conferrable
120
145
  licenses:
@@ -135,13 +160,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
160
  - !ruby/object:Gem::Version
136
161
  version: '0'
137
162
  requirements: []
138
- rubygems_version: 3.0.1
163
+ rubygems_version: 3.0.3
139
164
  signing_key:
140
165
  specification_version: 4
141
166
  summary: Simple YAML file-based configuration management
142
167
  test_files:
143
- - spec/conferrable_spec.rb
144
- - spec/configuration_spec.rb
145
- - spec/entry_spec.rb
146
- - spec/file_based_configuration_spec.rb
168
+ - spec/conferrable/conferrable_spec.rb
169
+ - spec/conferrable/configuration_spec.rb
170
+ - spec/conferrable/entry_spec.rb
171
+ - spec/conferrable/file_based_configuration_spec.rb
172
+ - spec/conferrable/file_utilities_spec.rb
173
+ - spec/config_examples/UPPER.YML
174
+ - spec/config_examples/UPPER.YML.ERB
175
+ - spec/config_examples/directory.yml/.gitkeep
176
+ - spec/config_examples/full.yaml
177
+ - spec/config_examples/full.yaml.erb
178
+ - spec/config_examples/not-yaml.txt
179
+ - spec/config_examples/simple.yml
180
+ - spec/config_examples/simple.yml.erb
147
181
  - spec/spec_helper.rb
@@ -1,102 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- conferrable (1.0.4)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ansi (1.5.0)
10
- ast (2.4.0)
11
- coderay (1.1.2)
12
- diff-lcs (1.3)
13
- docile (1.3.1)
14
- ffi (1.10.0)
15
- formatador (0.2.5)
16
- guard (2.15.0)
17
- formatador (>= 0.2.4)
18
- listen (>= 2.7, < 4.0)
19
- lumberjack (>= 1.0.12, < 2.0)
20
- nenv (~> 0.1)
21
- notiffany (~> 0.0)
22
- pry (>= 0.9.12)
23
- shellany (~> 0.0)
24
- thor (>= 0.18.1)
25
- guard-compat (1.2.1)
26
- guard-rspec (4.7.3)
27
- guard (~> 2.1)
28
- guard-compat (~> 1.1)
29
- rspec (>= 2.99.0, < 4.0)
30
- hirb (0.7.3)
31
- jaro_winkler (1.5.2)
32
- json (2.1.0)
33
- listen (3.1.5)
34
- rb-fsevent (~> 0.9, >= 0.9.4)
35
- rb-inotify (~> 0.9, >= 0.9.7)
36
- ruby_dep (~> 1.2)
37
- lumberjack (1.0.13)
38
- method_source (0.9.2)
39
- nenv (0.3.0)
40
- notiffany (0.1.1)
41
- nenv (~> 0.1)
42
- shellany (~> 0.0)
43
- parallel (1.13.0)
44
- parser (2.6.0.0)
45
- ast (~> 2.4.0)
46
- powerpack (0.1.2)
47
- pry (0.12.2)
48
- coderay (~> 1.1.0)
49
- method_source (~> 0.9.0)
50
- rainbow (3.0.0)
51
- rb-fsevent (0.10.3)
52
- rb-inotify (0.10.0)
53
- ffi (~> 1.0)
54
- rspec (3.8.0)
55
- rspec-core (~> 3.8.0)
56
- rspec-expectations (~> 3.8.0)
57
- rspec-mocks (~> 3.8.0)
58
- rspec-core (3.8.0)
59
- rspec-support (~> 3.8.0)
60
- rspec-expectations (3.8.1)
61
- diff-lcs (>= 1.2.0, < 2.0)
62
- rspec-support (~> 3.8.0)
63
- rspec-mocks (3.8.0)
64
- diff-lcs (>= 1.2.0, < 2.0)
65
- rspec-support (~> 3.8.0)
66
- rspec-support (3.8.0)
67
- rubocop (0.63.1)
68
- jaro_winkler (~> 1.5.1)
69
- parallel (~> 1.10)
70
- parser (>= 2.5, != 2.5.1.1)
71
- powerpack (~> 0.1)
72
- rainbow (>= 2.2.2, < 4.0)
73
- ruby-progressbar (~> 1.7)
74
- unicode-display_width (~> 1.4.0)
75
- ruby-progressbar (1.10.0)
76
- ruby_dep (1.5.0)
77
- shellany (0.0.1)
78
- simplecov (0.16.1)
79
- docile (~> 1.1)
80
- json (>= 1.8, < 3)
81
- simplecov-html (~> 0.10.0)
82
- simplecov-console (0.4.2)
83
- ansi
84
- hirb
85
- simplecov
86
- simplecov-html (0.10.2)
87
- thor (0.20.3)
88
- unicode-display_width (1.4.1)
89
-
90
- PLATFORMS
91
- ruby
92
-
93
- DEPENDENCIES
94
- conferrable!
95
- guard-rspec (~> 4.7)
96
- rspec
97
- rubocop (~> 0.63.1)
98
- simplecov (~> 0.16.1)
99
- simplecov-console (~> 0.4.2)
100
-
101
- BUNDLED WITH
102
- 1.17.2