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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b18bc3578e7921270361c42585ff4557ec7b44ac
4
- data.tar.gz: 54ba40d324eed4527c37cfa372e051d2c35e82fc
3
+ metadata.gz: 40bc376f336e9f6c067ebe6a524d8d4ab7d7ea81
4
+ data.tar.gz: 5f889ec0330aee3cdca5ec9aaa4a7d356fbfaf29
5
5
  SHA512:
6
- metadata.gz: 70e620ee44b7a7798a430eefea42eca8aa4224a58b54685dd3863f3782682573c048eddca170490b7bca3aba87c049e15ae409f06e20b63e166a62c074ccf0c7
7
- data.tar.gz: eda5b7eff680cd9beb7408ca33b2bb43ca8795d30956b6f5e436516bd89f62d3de4b0b296b71c4a58c05670a6c7879a7891550aea638649e7f8eba66a0b3473f
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
@@ -1,3 +1,3 @@
1
1
  module FillParams
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -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
- if !data.has_key?(key) && !dist_data[key].is_a?(Hash)
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
- pending "write it"
4
- it 'should be true' do
5
- expect(1).to eq 1
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.2
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: []