fillparams 0.0.5 → 0.0.6

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
- SHA1:
3
- metadata.gz: b395cba7ab792ed4a1c11c26891e67e0634ae97d
4
- data.tar.gz: 92e789e987fe7a5b00f5a7ac4315f1dcbd7f9912
2
+ SHA256:
3
+ metadata.gz: 626edd4bcbbc93f3aa0c6fcdbd419199b618e4b36f5f3414a8318fe7cf9f0089
4
+ data.tar.gz: bc92f306c837c684738a0da419a934e63648ad5291bbd504e7cf7bd75b57b7b9
5
5
  SHA512:
6
- metadata.gz: 2264445d52e0804dbb99c58c71815c32b0b95ea59f29eb10722a2e2f6b48f9c6b6e2e8d11ca350deec135523ae5a332fb89495119e00a73bbeb8573d74d82baa
7
- data.tar.gz: 660590e02a7bb2ff1e2e13e4a3587ad28a2619dccca9d4dbf011c3d1e8c924def998a629204b4c4606f824b6966429342b2e430a2618b1eaf3fcb5144b7bb499
6
+ metadata.gz: 9e577a6ceb9be2a13a544a117984a5d59a5622e9b184de116dd23b4a9b9e0f529d9b694fc17d547ed3a3f65f065f71bfd592f603ce4fd74f2d3118b657efffa5
7
+ data.tar.gz: 18fa85856d136aaa337a193e61858e4a4ae8e4ed0796872487f29db741df5f2e96d69b19949f0336acd2d4002a3f654e9458248172b515818f895472b50de9f5
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ ---
2
+ language: ruby
3
+ notifications:
4
+ email:
5
+ - krzysztof.hasinski+fillparams@gmail.com
6
+ rvm:
7
+ - 2.6.9
8
+ - 2.7.6
9
+ - 3.1.2
10
+ - ruby-head
11
+ - jruby
12
+
data/FillParams.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency 'bundler', '~> 1.6'
21
+ spec.add_development_dependency 'bundler', '~> 2.0'
22
22
  spec.add_development_dependency 'rake'
23
23
  spec.add_development_dependency 'rspec'
24
24
  end
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Krzysztof Hasiński
1
+ Copyright (c) 2014 Krzysztof Hasiński, Justyna Wojtczak
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # FillParams
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/fillparams.svg)](http://badge.fury.io/rb/fillparams)
4
- [![Code Climate](https://codeclimate.com/github/khasinski/fillparams.png)](https://codeclimate.com/github/khasinski/fillparams)
5
- [![Build Status](https://travis-ci.org/khasinski/fillparams.svg?branch=master)](https://travis-ci.org/khasinski/fillparams)
4
+
5
+ # ⚠️ Deprecated
6
+
7
+ # Please use [ENVs](https://github.com/bkeepers/dotenv) or [encrypted credentials](https://edgeguides.rubyonrails.org/security.html#custom-credentials) instead
6
8
 
7
9
  This tool allows you to manage ignored YAML parameters in your config files.
8
10
  It is inspired by [Incenteev ParameterHandler](https://github.com/Incenteev/ParameterHandler).
@@ -1,3 +1,3 @@
1
1
  module FillParams
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
@@ -14,9 +14,7 @@ class ParameterFiller
14
14
 
15
15
  def fill_file_list
16
16
  @config_files.each do |file_name|
17
- if verbose
18
- puts 'Filling ' + file_name + '...'
19
- end
17
+ puts 'Filling ' + file_name + '...' if verbose
20
18
  fill_file file_name
21
19
  end
22
20
  end
@@ -33,9 +31,7 @@ class ParameterFiller
33
31
  def load_yaml_file(file_name)
34
32
  begin
35
33
  data = YAML.load_file(file_name)
36
- unless data
37
- data = {}
38
- end
34
+ data = {} unless data
39
35
  rescue Exception => e
40
36
  raise ArgumentError, 'Invalid YAML in config file ' + file_name unless data
41
37
  end
@@ -44,9 +40,7 @@ class ParameterFiller
44
40
 
45
41
  def setup_files(file_name, dist_file_name)
46
42
  raise ArgumentError, 'Dist file not found for ' + file_name unless File.file?(dist_file_name)
47
- unless File.file?(file_name)
48
- File.write(file_name, '')
49
- end
43
+ File.write(file_name, '') unless File.file?(file_name)
50
44
  return
51
45
  end
52
46
 
@@ -57,9 +51,7 @@ class ParameterFiller
57
51
  data[key] = ask_for_param(key, value)
58
52
  end
59
53
  if dist_data[key].is_a?(Hash)
60
- unless data.has_key?(key)
61
- data[key] = {}
62
- end
54
+ data[key] = {} unless data.has_key?(key)
63
55
  data[key] = fill_parameters(data[key], dist_data[key])
64
56
  end
65
57
  end
@@ -1,53 +1,196 @@
1
1
  require 'spec_helper'
2
- describe ParameterFiller do
3
2
 
4
- def sample_dist_data
5
- YAML.load(<<-EOF
6
- NAME: value
7
- string: abc
8
- number: 1.23
9
- EOF
10
- )
11
- end
3
+ describe ParameterFiller do
4
+ describe '#fill_parameters' do
5
+ context 'simple input yml' do
6
+ def sample_dist_data
7
+ YAML.load(<<-EOF
8
+ NAME: value
9
+ string: abc
10
+ number: 1.23
11
+ EOF
12
+ )
13
+ end
12
14
 
13
- let(:pf) { ParameterFiller.new('', false, false) }
14
- context 'when the data is nil' do
15
- let(:data){ nil }
16
- it 'returns the same config as sample_dist_data' do
17
- expect(pf.fill_parameters(data, sample_dist_data)).to eq sample_dist_data
18
- end
19
- end
20
- context 'when the dist data is nil' do
21
- let(:dist_data){ nil }
22
- let(:data){ sample_dist_data }
23
- it 'returns the same config as sample_dist_data' do
24
- expect(pf.fill_parameters(data, sample_dist_data)).to eq sample_dist_data
15
+ let(:pf) { ParameterFiller.new('', false, false) }
16
+ context 'when the data is nil' do
17
+ let(:data){ nil }
18
+ it 'returns the same config as sample_dist_data' do
19
+ expect(pf.fill_parameters(data, sample_dist_data)).to eq sample_dist_data
20
+ end
21
+ end
22
+ context 'when the dist data is nil' do
23
+ let(:dist_data){ nil }
24
+ let(:data){ sample_dist_data }
25
+ it 'returns the same config as sample_dist_data' do
26
+ expect(pf.fill_parameters(data, sample_dist_data)).to eq sample_dist_data
27
+ end
28
+ end
29
+ context 'when the data is the same as sample data' do
30
+ let(:data){ sample_dist_data }
31
+ it 'returns the same config as sample_dist_data' do
32
+ expect(pf.fill_parameters(data, sample_dist_data)).to eq sample_dist_data
33
+ end
34
+ end
35
+ context 'when the data has additional key' do
36
+ let(:data){ sample_dist_data.merge('new_key'=> 'new_val') }
37
+ it 'returns the same config as data' do
38
+ expect(pf.fill_parameters(data, sample_dist_data)).to eq data
39
+ end
40
+ end
41
+ context 'when the dist data has additional key' do
42
+ let(:dist_data){ sample_dist_data.merge('new_key'=> 'new_val') }
43
+ let(:data){ sample_dist_data }
44
+ it 'returns the same config as dist_data' do
45
+ expect(pf.fill_parameters(data, dist_data)).to eq dist_data
46
+ end
47
+ end
48
+ context 'when both data and dist data have additional keys' do
49
+ let(:dist_data){ sample_dist_data.merge('new_key'=> 'new_val') }
50
+ let(:data){ sample_dist_data.merge('new_key2'=> 'new_val2') }
51
+ it 'returns data with this keys' do
52
+ expect(pf.fill_parameters(data, dist_data)).to eq dist_data.merge('new_key2'=> 'new_val2')
53
+ end
54
+ end
25
55
  end
26
- end
27
- context 'when the data is the same as sample data' do
28
- let(:data){ sample_dist_data }
29
- it 'returns the same config as sample_dist_data' do
30
- expect(pf.fill_parameters(data, sample_dist_data)).to eq sample_dist_data
31
- end
32
- end
33
- context 'when the data has additional key' do
34
- let(:data){ sample_dist_data.merge('new_key'=> 'new_val') }
35
- it 'returns the same config as data' do
36
- expect(pf.fill_parameters(data, sample_dist_data)).to eq data
37
- end
38
- end
39
- context 'when the dist data has additional key' do
40
- let(:dist_data){ sample_dist_data.merge('new_key'=> 'new_val') }
41
- let(:data){ sample_dist_data }
42
- it 'returns the same config as dist_data' do
43
- expect(pf.fill_parameters(data, dist_data)).to eq dist_data
56
+
57
+ context 'nested input yml' do
58
+ def sample_dist_data
59
+ YAML.load(<<-EOF
60
+ key01: val01
61
+ key02:
62
+ key11: val11
63
+ key12:
64
+ key20: val20
65
+ EOF
66
+ )
67
+ end
68
+ let(:pf) { ParameterFiller.new('', false, false) }
69
+ context 'when the data is nil' do
70
+ let(:data){ nil }
71
+ it 'returns the same config as sample_dist_data' do
72
+ expect(pf.fill_parameters(data, sample_dist_data)).to eq sample_dist_data
73
+ end
74
+ end
75
+ context 'when the dist data is nil' do
76
+ let(:dist_data){ nil }
77
+ let(:data){ sample_dist_data }
78
+ it 'returns the same config as sample_dist_data' do
79
+ expect(pf.fill_parameters(data, sample_dist_data)).to eq sample_dist_data
80
+ end
81
+ end
82
+ context 'when the data is the same as sample data' do
83
+ let(:data){ sample_dist_data }
84
+ it 'returns the same config as sample_dist_data' do
85
+ expect(pf.fill_parameters(data, sample_dist_data)).to eq sample_dist_data
86
+ end
87
+ end
88
+ context 'when the data has additional key' do
89
+ context 'on zero level of nesting' do
90
+ let(:data){ sample_dist_data.merge('new_key'=> 'new_val') }
91
+ it 'returns the same config as data' do
92
+ expect(pf.fill_parameters(data, sample_dist_data)).to eq data
93
+ end
94
+ end
95
+ context 'on first level of nesting' do
96
+ let(:data){ sample_dist_data.merge('key02' => sample_dist_data['key02'].merge('new_key'=> 'new_val')) }
97
+ it 'returns the same config as data' do
98
+ expect(pf.fill_parameters(data, sample_dist_data)).to eq data
99
+ end
100
+ end
101
+ end
102
+ context 'when the dist data has additional key' do
103
+ context 'on zero level of nesting' do
104
+ let(:dist_data){ sample_dist_data.merge('new_key'=> 'new_val') }
105
+ let(:data){ sample_dist_data }
106
+ it 'returns the same config as dist_data' do
107
+ expect(pf.fill_parameters(data, dist_data)).to eq dist_data
108
+ end
109
+ end
110
+ context 'on first level of nesting' do
111
+ let(:dist_data){ sample_dist_data.merge('key02' => sample_dist_data['key02'].merge('new_key'=> 'new_val')) }
112
+ let(:data){ sample_dist_data }
113
+ it 'returns the same config as dist_data' do
114
+ expect(pf.fill_parameters(data, dist_data)).to eq dist_data
115
+ end
116
+ end
117
+ end
118
+ context 'when both data and dist data have additional keys' do
119
+ context 'dist data on zero level of nesting and data on first level of nesting' do
120
+ let(:dist_data){ sample_dist_data.merge('new_key'=> 'new_val') }
121
+ let(:data){ sample_dist_data.merge('key02' => sample_dist_data['key02'].merge('new_key2'=> 'new_val2')) }
122
+ it 'returns data with this keys' do
123
+ expect(pf.fill_parameters(data, dist_data)).to eq data.merge('new_key'=> 'new_val')
124
+ end
125
+ end
126
+ context 'dist data on first level of nesting and data on zero level of nesting' do
127
+ let(:dist_data){ sample_dist_data.merge('key02' => sample_dist_data['key02'].merge('new_key'=> 'new_val')) }
128
+ let(:data){ sample_dist_data.merge('new_key2'=> 'new_val2') }
129
+ it 'returns data with this keys' do
130
+ expect(pf.fill_parameters(data, dist_data)).to eq dist_data.merge('new_key2'=> 'new_val2')
131
+ end
132
+ end
133
+ context 'when both data and dist data on first level of nesting' do
134
+ let(:dist_data){ sample_dist_data.merge('key02' => sample_dist_data['key02'].merge('new_key'=> 'new_val')) }
135
+ let(:data){ sample_dist_data.merge('key02' => sample_dist_data['key02'].merge('new_key2'=> 'new_val2')) }
136
+ it 'returns data with this keys' do
137
+ expect(pf.fill_parameters(data, dist_data)).to eq dist_data.merge('key02' => dist_data['key02'].merge('new_key2'=> 'new_val2'))
138
+ end
139
+ end
140
+ end
44
141
  end
45
- end
46
- context 'when both data and dist data have additional keys' do
47
- let(:dist_data){ sample_dist_data.merge('new_key'=> 'new_val') }
48
- let(:data){ sample_dist_data.merge('new_key2'=> 'new_val2') }
49
- it 'returns data with this keys' do
50
- expect(pf.fill_parameters(data, dist_data)).to eq dist_data.merge('new_key2'=> 'new_val2')
142
+
143
+ context 'yml with anchors and aliases' do
144
+ def sample_dist_data
145
+ YAML.load(<<-EOF
146
+ defaults: &defaults
147
+ adapter: postgres
148
+ host: localhost
149
+
150
+ development:
151
+ database: myapp_development
152
+ <<: *defaults
153
+
154
+ test:
155
+ database: myapp_test
156
+ <<: *defaults
157
+ EOF
158
+ )
159
+ end
160
+
161
+ def data_results
162
+ YAML.load(<<-EOF
163
+ defaults:
164
+ adapter: postgres
165
+ host: localhost
166
+
167
+ development:
168
+ database: myapp_development
169
+ adapter: postgres
170
+ host: localhost
171
+
172
+ test:
173
+ database: myapp_test
174
+ adapter: postgres
175
+ host: localhost
176
+ EOF
177
+ )
178
+ end
179
+
180
+ let(:pf) { ParameterFiller.new('', false, false) }
181
+ context 'when the data is nil' do
182
+ let(:data){ nil }
183
+ it 'returns data_results' do
184
+ expect(pf.fill_parameters(data, sample_dist_data)).to eq data_results
185
+ end
186
+ end
187
+ context 'when the dist data is nil' do
188
+ let(:dist_data){ nil }
189
+ let(:data){ sample_dist_data }
190
+ it 'returns data_results' do
191
+ expect(pf.fill_parameters(data, sample_dist_data)).to eq data_results
192
+ end
193
+ end
51
194
  end
52
195
  end
53
196
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'bundler/setup'
2
-
3
2
  require 'parameter_filler.rb'
4
3
 
5
4
  Bundler.setup
metadata CHANGED
@@ -1,56 +1,56 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fillparams
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Krzysztof Hasiński
8
8
  - Justyna Wojtczak
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-05 00:00:00.000000000 Z
12
+ date: 2022-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.6'
20
+ version: '2.0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '1.6'
27
+ version: '2.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '>='
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  description: A gem for filling in parameters automatically
@@ -62,8 +62,9 @@ executables:
62
62
  extensions: []
63
63
  extra_rdoc_files: []
64
64
  files:
65
- - .gitignore
66
- - .rspec
65
+ - ".gitignore"
66
+ - ".rspec"
67
+ - ".travis.yml"
67
68
  - FillParams.gemspec
68
69
  - Gemfile
69
70
  - LICENSE.txt
@@ -82,24 +83,23 @@ homepage: http://github.com/khasinski/fillparams
82
83
  licenses:
83
84
  - MIT
84
85
  metadata: {}
85
- post_install_message:
86
+ post_install_message:
86
87
  rdoc_options: []
87
88
  require_paths:
88
89
  - lib
89
90
  required_ruby_version: !ruby/object:Gem::Requirement
90
91
  requirements:
91
- - - '>='
92
+ - - ">="
92
93
  - !ruby/object:Gem::Version
93
94
  version: '0'
94
95
  required_rubygems_version: !ruby/object:Gem::Requirement
95
96
  requirements:
96
- - - '>='
97
+ - - ">="
97
98
  - !ruby/object:Gem::Version
98
99
  version: '0'
99
100
  requirements: []
100
- rubyforge_project:
101
- rubygems_version: 2.0.3
102
- signing_key:
101
+ rubygems_version: 3.2.22
102
+ signing_key:
103
103
  specification_version: 4
104
104
  summary: Parameters handler, for usage see github page
105
105
  test_files: