config-parser 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fc6869f1aa46b1446eff6a47d6dda33e72a7a50d
4
+ data.tar.gz: ac300beccf597924911ac279b2c117112cd895d8
5
+ SHA512:
6
+ metadata.gz: 01a2a7aec84c8d24ab2d58c90238ea463a5014e1403f880b06aa8c81274a915b3b60c63314c02e90406bcdbd980c7fe689e71dd51702bae8d292e55a440fbe08
7
+ data.tar.gz: f81280199802c941c3b7a0ef3fc0097b8840a275be38990d392388a9ae6ab5ef2e84807ed103c1180b1ec895a5cf9f51193abc061e6c6e119ee90cdea0156dd7
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,36 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ config-parser (0.3.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ rspec (3.5.0)
11
+ rspec-core (~> 3.5.0)
12
+ rspec-expectations (~> 3.5.0)
13
+ rspec-mocks (~> 3.5.0)
14
+ rspec-core (3.5.4)
15
+ rspec-support (~> 3.5.0)
16
+ rspec-expectations (3.5.0)
17
+ diff-lcs (>= 1.2.0, < 2.0)
18
+ rspec-support (~> 3.5.0)
19
+ rspec-its (1.2.0)
20
+ rspec-core (>= 3.0.0)
21
+ rspec-expectations (>= 3.0.0)
22
+ rspec-mocks (3.5.0)
23
+ diff-lcs (>= 1.2.0, < 2.0)
24
+ rspec-support (~> 3.5.0)
25
+ rspec-support (3.5.0)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ config-parser!
32
+ rspec
33
+ rspec-its
34
+
35
+ BUNDLED WITH
36
+ 1.14.6
@@ -5,11 +5,14 @@ Gem::Specification.new do |gem|
5
5
  overwriting variables per Rails environment and overwriting variables with a local
6
6
  options_local.yml file."
7
7
  gem.homepage = "https://github.com/openSUSE/rubygem_config-parser"
8
- gem.authors = ['cschum@suse.de', 'tom@opensuse.org']
8
+ gem.authors = ['cschum@suse.de', 'tom@opensuse.org', 'kpimenov@suse.de']
9
9
  gem.files = `git ls-files`.split("\n")
10
10
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
11
11
  gem.require_paths = ['lib']
12
- gem.version = '0.2.0'
12
+ gem.version = '0.3.0'
13
+ gem.license = 'MIT'
14
+ gem.add_development_dependency 'rspec'
15
+ gem.add_development_dependency 'rspec-its'
13
16
  end
14
17
 
15
18
 
@@ -21,6 +21,8 @@
21
21
  #THE SOFTWARE.
22
22
 
23
23
  require 'yaml'
24
+ require 'erb'
25
+
24
26
  require "#{File.dirname(__FILE__)}/utils"
25
27
 
26
28
  module Common
@@ -48,7 +50,7 @@ module Common
48
50
  cmd_line_args = {}
49
51
 
50
52
  if File.exists? @tmp_cmdl_file
51
- cmd_line_args = YAML.load_file(@tmp_cmdl_file)
53
+ cmd_line_args = load_file(@tmp_cmdl_file)
52
54
 
53
55
  # Don't remove tmp_cmdl_file if the keep_tmp_cmdl_file flag is set.
54
56
  if defined? KEEP_TMP_CMDL_FILE and KEEP_TMP_CMDL_FILE
@@ -96,7 +98,7 @@ module Common
96
98
 
97
99
  if File.exists? @cfg_file
98
100
  vputs "Loading '#{@cfg_file}'", args[:verbose]
99
- options = YAML.load_file @cfg_file
101
+ options = load_file @cfg_file
100
102
  end
101
103
 
102
104
  if args[:config_file]
@@ -135,6 +137,10 @@ module Common
135
137
 
136
138
  private
137
139
 
140
+ def load_file(filename)
141
+ YAML.load(ERB.new(File.read(filename)).result binding)
142
+ end
143
+
138
144
  def vputs msg, verbose
139
145
  return if verbose == 'silent' || verbose.nil?
140
146
  puts "** P#{Process.pid} #{msg}"
@@ -160,7 +166,7 @@ module Common
160
166
 
161
167
  # Update options.
162
168
  def update_options file, options
163
- YAML.load_file(file).each do |k, v|
169
+ load_file(file).each do |k, v|
164
170
  next unless v
165
171
  if options[k]
166
172
  options[k].update(v)
@@ -0,0 +1,10 @@
1
+ require_relative 'spec_helper'
2
+
3
+ describe Common::Options do
4
+ subject { Common::Options.new('spec/fixtures/example_config.yml') }
5
+
6
+ its(:plain_key) { is_expected.to eq('plain_value') }
7
+ its(:erb_key) { is_expected.to eq('erb_value') }
8
+ its(:mixed_key) { is_expected.to eq('mixed_value') }
9
+
10
+ end
@@ -0,0 +1,4 @@
1
+ default:
2
+ plain_key: plain_value
3
+ erb_key: <%= %w(erb value).join('_') %>
4
+ mixed_key: "<%= 'mixed_' %>value"
@@ -0,0 +1,8 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'config-parser'
5
+
6
+ require 'rspec'
7
+ require 'rspec/its'
8
+
metadata CHANGED
@@ -1,57 +1,91 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - cschum@suse.de
9
8
  - tom@opensuse.org
9
+ - kpimenov@suse.de
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-07-01 00:00:00.000000000 Z
14
- dependencies: []
15
- description: ! 'Parsing an options.yml file into a Hash with convenience methods like
16
-
13
+ date: 2017-04-05 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rspec-its
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ description: |-
44
+ Parsing an options.yml file into a Hash with convenience methods like
17
45
  overwriting variables per Rails environment and overwriting variables with a local
18
-
19
- options_local.yml file.'
46
+ options_local.yml file.
20
47
  email:
21
48
  executables: []
22
49
  extensions: []
23
50
  extra_rdoc_files: []
24
51
  files:
25
- - .gitignore
52
+ - ".gitignore"
53
+ - Gemfile
54
+ - Gemfile.lock
26
55
  - LICENSE
27
56
  - README.markdown
28
57
  - config-parser.gemspec
29
58
  - lib/common/options.rb
30
59
  - lib/common/utils.rb
31
60
  - lib/config-parser.rb
61
+ - spec/erb_interpolation_spec.rb
62
+ - spec/fixtures/example_config.yml
63
+ - spec/spec_helper.rb
32
64
  homepage: https://github.com/openSUSE/rubygem_config-parser
33
- licenses: []
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
34
68
  post_install_message:
35
69
  rdoc_options: []
36
70
  require_paths:
37
71
  - lib
38
72
  required_ruby_version: !ruby/object:Gem::Requirement
39
- none: false
40
73
  requirements:
41
- - - ! '>='
74
+ - - ">="
42
75
  - !ruby/object:Gem::Version
43
76
  version: '0'
44
77
  required_rubygems_version: !ruby/object:Gem::Requirement
45
- none: false
46
78
  requirements:
47
- - - ! '>='
79
+ - - ">="
48
80
  - !ruby/object:Gem::Version
49
81
  version: '0'
50
82
  requirements: []
51
83
  rubyforge_project:
52
- rubygems_version: 1.8.23
84
+ rubygems_version: 2.6.8
53
85
  signing_key:
54
- specification_version: 3
86
+ specification_version: 4
55
87
  summary: Parsing an options.yml file into a Hash with convenience.
56
- test_files: []
57
- has_rdoc:
88
+ test_files:
89
+ - spec/erb_interpolation_spec.rb
90
+ - spec/fixtures/example_config.yml
91
+ - spec/spec_helper.rb