fillparams 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/FillParams.gemspec +2 -2
- data/lib/FillParams/version.rb +1 -1
- data/lib/parameter_filler.rb +2 -1
- data/spec/foobar_spec.rb +49 -4
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40bc376f336e9f6c067ebe6a524d8d4ab7d7ea81
|
4
|
+
data.tar.gz: 5f889ec0330aee3cdca5ec9aaa4a7d356fbfaf29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8aaf09171ac516ba515c2d047b8224a6e68261dc26d7ceb174c3c22571415e2a2df9049dbae19270db6b49ed7a43cb6237cbc430c0cbc831128d946eae0f183c
|
7
|
+
data.tar.gz: b938892dca6c047f5898cc7e15d038e8feedb6bb753ad1d17c7e6d74bed7178046f0a7ea5aefb94e425c27263c4ba4aa80380a4ebe547d8a9fd5c71ae6100324
|
data/FillParams.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = 'fillparams'
|
8
8
|
spec.version = FillParams::VERSION
|
9
9
|
spec.authors = ['Krzysztof Hasiński', 'Justyna Wojtczak']
|
10
|
-
spec.email = ['krzysztof.hasinski+fillparams@gmail.com']
|
10
|
+
spec.email = ['krzysztof.hasinski+fillparams@gmail.com', 'justine84+fillparams@gmail.com']
|
11
11
|
spec.summary = 'Parameters handler, for usage see github page'
|
12
12
|
spec.description = 'A gem for filling in parameters automatically'
|
13
13
|
spec.homepage = 'http://github.com/khasinski/fillparams'
|
@@ -22,4 +22,4 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency 'rake'
|
23
23
|
spec.add_development_dependency 'rspec'
|
24
24
|
spec.add_development_dependency 'rspec-activemodel-mocks'
|
25
|
-
end
|
25
|
+
end
|
data/lib/FillParams/version.rb
CHANGED
data/lib/parameter_filler.rb
CHANGED
@@ -51,8 +51,9 @@ class ParameterFiller
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def fill_parameters(data, dist_data)
|
54
|
+
data ||= {}
|
54
55
|
dist_data.each do |key, value|
|
55
|
-
|
56
|
+
unless data.has_key?(key) || dist_data[key].is_a?(Hash)
|
56
57
|
data[key] = ask_for_param(key, value)
|
57
58
|
end
|
58
59
|
if dist_data[key].is_a?(Hash)
|
data/spec/foobar_spec.rb
CHANGED
@@ -1,8 +1,53 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
describe ParameterFiller do
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
|
4
|
+
def sample_dist_data
|
5
|
+
YAML.load(<<-EOF
|
6
|
+
NAME: value
|
7
|
+
string: abc
|
8
|
+
number: 1.23
|
9
|
+
EOF
|
10
|
+
)
|
6
11
|
end
|
7
|
-
end
|
8
12
|
|
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
|
25
|
+
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
|
44
|
+
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')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fillparams
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Krzysztof Hasiński
|
@@ -70,6 +70,7 @@ dependencies:
|
|
70
70
|
description: A gem for filling in parameters automatically
|
71
71
|
email:
|
72
72
|
- krzysztof.hasinski+fillparams@gmail.com
|
73
|
+
- justine84+fillparams@gmail.com
|
73
74
|
executables:
|
74
75
|
- fillparams
|
75
76
|
extensions: []
|