fig_newton 0.11 → 0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/ChangeLog +4 -0
- data/config/yaml/test_config.yml +2 -0
- data/features/fig_newton.feature +10 -0
- data/features/step_definitions/fig_newton_steps.rb +32 -24
- data/fig_newton.gemspec +3 -3
- data/lib/fig_newton/missing.rb +7 -6
- data/lib/fig_newton/version.rb +1 -1
- data/spec/fig_newton/fig_newton_spec.rb +4 -4
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88d726ff2918b2540e7a764e0948b8c4d1adfe7d
|
4
|
+
data.tar.gz: f0db4d054ff0416c03d56eeb6edefb10e3ded2f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 377ee257931cf04e49bc5113a37e4e58c8a043a0298899d6fbefcfc1f8eea5b18b3eff7eb6c6b6a2a62b903eadc2f1a455641cd48e1c4fb764dbfa27b41805c8
|
7
|
+
data.tar.gz: 0046d651e27a9f03c995bbacfbc4466ed48c50d4aaf6ce9871a77ad9c3e679d79e7c31c18251340c78870340d35a51e1dc861cb99b4abdd214659250205c9207
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.0.0-
|
1
|
+
ruby-2.0.0-p598
|
data/ChangeLog
CHANGED
data/config/yaml/test_config.yml
CHANGED
data/features/fig_newton.feature
CHANGED
@@ -45,6 +45,16 @@ Feature: Functionality of the fig_newton gem
|
|
45
45
|
When I ask for the value for "port"
|
46
46
|
Then I should see 1234
|
47
47
|
|
48
|
+
Scenario: Requesting a true boolean value
|
49
|
+
Given I have read the configuration file
|
50
|
+
When I ask for the value for "set_flag"
|
51
|
+
Then I should see true
|
52
|
+
|
53
|
+
Scenario: Requesting a false boolean value
|
54
|
+
Given I have read the configuration file
|
55
|
+
When I ask for the value for "cleared_flag"
|
56
|
+
Then I should see false
|
57
|
+
|
48
58
|
Scenario: Requesting data from a node can be converted to a hash
|
49
59
|
Given I have read the configuration file
|
50
60
|
When I ask for the value for "database"
|
@@ -1,87 +1,95 @@
|
|
1
|
-
Given /^I have read the configuration file$/ do
|
1
|
+
Given (/^I have read the configuration file$/) do
|
2
2
|
FigNewton.yml_directory = 'config/yaml'
|
3
3
|
FigNewton.load 'test_config.yml'
|
4
4
|
end
|
5
5
|
|
6
|
-
When /^I have read the default file from the default directory$/ do
|
6
|
+
When (/^I have read the default file from the default directory$/) do
|
7
7
|
FigNewton.yml = nil
|
8
8
|
end
|
9
9
|
|
10
|
-
When /^I ask for the value for "([^\"]*)"$/ do |key|
|
10
|
+
When (/^I ask for the value for "([^\"]*)"$/) do |key|
|
11
11
|
@value = FigNewton.send key
|
12
12
|
end
|
13
13
|
|
14
|
-
Then /^I should see "([^\"]*)"$/ do |value|
|
15
|
-
@value.
|
14
|
+
Then (/^I should see "([^\"]*)"$/) do |value|
|
15
|
+
expect(@value).to eql value
|
16
16
|
end
|
17
17
|
|
18
|
-
Then /^I should see (\d+)$/ do |value|
|
19
|
-
@value.
|
18
|
+
Then (/^I should see (\d+)$/) do |value|
|
19
|
+
expect(@value).to eql value.to_i
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
Then (/^I should see true$/) do
|
23
|
+
expect(@value).to be true
|
24
|
+
end
|
25
|
+
|
26
|
+
Then (/^I should see false$/) do
|
27
|
+
expect(@value).to be false
|
28
|
+
end
|
29
|
+
|
30
|
+
When (/^I ask for a value that does not exist named "([^\"]*)"$/) do |non_existing|
|
23
31
|
@does_not_exist = non_existing
|
24
32
|
end
|
25
33
|
|
26
|
-
Then /^I should raise a NoMethodError exception$/ do
|
34
|
+
Then (/^I should raise a NoMethodError exception$/) do
|
27
35
|
expect{ FigNewton.send(@does_not_exist) }.to raise_error(NoMethodError)
|
28
36
|
end
|
29
37
|
|
30
|
-
Then /^I should have a node$/ do
|
31
|
-
@value.
|
38
|
+
Then (/^I should have a node$/) do
|
39
|
+
expect(@value).to be_an_instance_of FigNewton::Node
|
32
40
|
end
|
33
41
|
|
34
|
-
Then /^the "([^\"]*)" value for the node should be "([^\"]*)"$/ do |key, value|
|
35
|
-
@value.send(key).
|
42
|
+
Then (/^the "([^\"]*)" value for the node should be "([^\"]*)"$/) do |key, value|
|
43
|
+
expect(@value.send(key)).to eql value
|
36
44
|
end
|
37
45
|
|
38
|
-
When /^I ask for the node value for "([^\"]*)"$/ do |key|
|
46
|
+
When (/^I ask for the node value for "([^\"]*)"$/) do |key|
|
39
47
|
@value = @value.send(key)
|
40
48
|
end
|
41
49
|
|
42
|
-
Given /^I have an environment variable named "([^\"]*)" set to "([^\"]*)"$/ do |env_name, filename|
|
50
|
+
Given (/^I have an environment variable named "([^\"]*)" set to "([^\"]*)"$/) do |env_name, filename|
|
43
51
|
FigNewton.yml = nil
|
44
52
|
ENV[env_name] = filename
|
45
53
|
FigNewton.yml_directory = 'config/yaml'
|
46
54
|
FigNewton.instance_variable_set(:@yml, nil)
|
47
55
|
end
|
48
56
|
|
49
|
-
Then /^the hash of values should look like:$/ do |table|
|
50
|
-
table.transpose.hashes.first.
|
57
|
+
Then (/^the hash of values should look like:$/) do |table|
|
58
|
+
expect(table.transpose.hashes.first).to eql @value.to_hash
|
51
59
|
end
|
52
60
|
|
53
|
-
Given /^I have a yml file that is named after the hostname$/ do
|
61
|
+
Given (/^I have a yml file that is named after the hostname$/) do
|
54
62
|
FigNewton.yml = nil
|
55
63
|
FigNewton.yml_directory = 'config/yaml'
|
56
64
|
@hostname = Socket.gethostname
|
57
65
|
File.open("config/yaml/#{@hostname}.yml", 'w') {|file| file.write("from_the_hostname_file: read from the hostname file\n")}
|
58
66
|
end
|
59
67
|
|
60
|
-
Then /^I should remove the file$/ do
|
68
|
+
Then (/^I should remove the file$/) do
|
61
69
|
File.delete("config/yaml/#{@hostname}.yml")
|
62
70
|
end
|
63
71
|
|
64
|
-
When(/^I ask for a value that does not exist named "(.+)" that has a default value "(.+)"$/) do |key, value|
|
72
|
+
When (/^I ask for a value that does not exist named "(.+)" that has a default value "(.+)"$/) do |key, value|
|
65
73
|
@value = FigNewton.send key, value
|
66
74
|
end
|
67
75
|
|
68
|
-
When(/^I ask for a value that does not exist named "(.+)" that has a default block returning "(.+)"$/) do |key, value|
|
76
|
+
When (/^I ask for a value that does not exist named "(.+)" that has a default block returning "(.+)"$/) do |key, value|
|
69
77
|
@value = FigNewton.send(key) {
|
70
78
|
value
|
71
79
|
}
|
72
80
|
end
|
73
81
|
|
74
|
-
When(/^I ask for a value that does not exist named "(.+)" that has a default lambda returning "(.+)"$/) do |key, value|
|
82
|
+
When (/^I ask for a value that does not exist named "(.+)" that has a default lambda returning "(.+)"$/) do |key, value|
|
75
83
|
mylambda = lambda {|property| @lambda_property = property; return value}
|
76
84
|
@value = FigNewton.send key, &mylambda
|
77
85
|
end
|
78
86
|
|
79
|
-
When(/^I ask for a value that does not exist named "(.+)" that has a default proc returning "(.+)"$/) do |key, value|
|
87
|
+
When (/^I ask for a value that does not exist named "(.+)" that has a default proc returning "(.+)"$/) do |key, value|
|
80
88
|
myproc = Proc.new {value}
|
81
89
|
@value = FigNewton.send(key, &myproc)
|
82
90
|
end
|
83
91
|
|
84
|
-
Then(/^the lambda should be passed the property "(.+)"$/) do |expected_property|
|
92
|
+
Then (/^the lambda should be passed the property "(.+)"$/) do |expected_property|
|
85
93
|
expect(@lambda_property).to eq(expected_property)
|
86
94
|
end
|
87
95
|
|
data/fig_newton.gemspec
CHANGED
@@ -16,8 +16,8 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
gem.version = FigNewton::VERSION
|
18
18
|
|
19
|
-
gem.add_dependency 'yml_reader', '>= 0.
|
19
|
+
gem.add_dependency 'yml_reader', '>= 0.5'
|
20
20
|
|
21
|
-
gem.add_development_dependency 'rspec', '>= 2.
|
22
|
-
gem.add_development_dependency 'cucumber', '>= 1.
|
21
|
+
gem.add_development_dependency 'rspec', '>= 3.2.0'
|
22
|
+
gem.add_development_dependency 'cucumber', '>= 1.3.19'
|
23
23
|
end
|
data/lib/fig_newton/missing.rb
CHANGED
@@ -7,9 +7,9 @@ module FigNewton
|
|
7
7
|
read_file unless @yml
|
8
8
|
m = args.first
|
9
9
|
value = @yml[m.to_s]
|
10
|
-
value = args[1]
|
11
|
-
value = block.call(m.to_s)
|
12
|
-
super
|
10
|
+
value = args[1] if value.nil?
|
11
|
+
value = block.call(m.to_s) if value.nil? and block
|
12
|
+
super if value.nil?
|
13
13
|
value = FigNewton::Node.new(value) unless type_known? value
|
14
14
|
value
|
15
15
|
end
|
@@ -21,14 +21,15 @@ module FigNewton
|
|
21
21
|
hostname = Socket.gethostname
|
22
22
|
hostfile = "#{yml_directory}/#{hostname}.yml"
|
23
23
|
@yml = YAML.load_file hostfile if File.exist? hostfile
|
24
|
-
end
|
24
|
+
end
|
25
25
|
FigNewton.load('default.yml') if @yml.nil?
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
29
|
-
|
29
|
+
|
30
30
|
def type_known?(value)
|
31
|
-
|
31
|
+
known_types = [String, Integer, TrueClass, FalseClass]
|
32
|
+
known_types.any? { |type| value.kind_of? type }
|
32
33
|
end
|
33
34
|
end
|
34
35
|
end
|
data/lib/fig_newton/version.rb
CHANGED
@@ -5,11 +5,11 @@ describe FigNewton do
|
|
5
5
|
it "should retrieve the data by a key named after the method called" do
|
6
6
|
FigNewton.yml_directory = 'conf'
|
7
7
|
yml_mock = double('yaml')
|
8
|
-
File.
|
9
|
-
YAML.
|
10
|
-
yml_mock.
|
8
|
+
expect(File).to receive(:read).with('conf/test').and_return('test')
|
9
|
+
expect(YAML).to receive(:load).and_return(yml_mock)
|
10
|
+
expect(yml_mock).to receive(:[]).with('desired_data').and_return('information')
|
11
11
|
FigNewton.load('test')
|
12
|
-
FigNewton.desired_data.
|
12
|
+
expect(FigNewton.desired_data).to eql 'information'
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fig_newton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.12'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Morgan
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-02-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: yml_reader
|
@@ -17,42 +17,42 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '>='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '0.
|
20
|
+
version: '0.5'
|
21
21
|
type: :runtime
|
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: '0.
|
27
|
+
version: '0.5'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rspec
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - '>='
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 2.
|
34
|
+
version: 3.2.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
|
-
version: 2.
|
41
|
+
version: 3.2.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: cucumber
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - '>='
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 1.
|
48
|
+
version: 1.3.19
|
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
|
-
version: 1.
|
55
|
+
version: 1.3.19
|
56
56
|
description: Provides a simple mechanism to maintain and use different configurations
|
57
57
|
stored in yml files.
|
58
58
|
email:
|