fig_newton 0.6 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +5 -0
- data/features/fig_newton.feature +16 -0
- data/features/step_definitions/fig_newton_steps.rb +16 -0
- data/fig_newton.gemspec +4 -4
- data/lib/fig_newton/missing.rb +9 -1
- data/lib/fig_newton/node.rb +4 -0
- data/lib/fig_newton/version.rb +1 -1
- metadata +10 -8
data/ChangeLog
CHANGED
data/features/fig_newton.feature
CHANGED
@@ -15,6 +15,12 @@ Feature: Functionality of the fig_newton gem
|
|
15
15
|
When I ask for the value for "from_the_env_file"
|
16
16
|
Then I should see "read from the env file"
|
17
17
|
|
18
|
+
Scenario: Using a file that has the same name as the hostname
|
19
|
+
Given I have a yml file that is named after the hostname
|
20
|
+
When I ask for the value for "from_the_hostname_file"
|
21
|
+
Then I should see "read from the hostname file"
|
22
|
+
And I should remove the file
|
23
|
+
|
18
24
|
Scenario: Requesting data that contains a node of additional data
|
19
25
|
Given I have read the configuration file
|
20
26
|
When I ask for the value for "database"
|
@@ -38,3 +44,13 @@ Feature: Functionality of the fig_newton gem
|
|
38
44
|
Given I have read the configuration file
|
39
45
|
When I ask for the value for "port"
|
40
46
|
Then I should see 1234
|
47
|
+
|
48
|
+
Scenario: Requesting data from a node can be converted to a hash
|
49
|
+
Given I have read the configuration file
|
50
|
+
When I ask for the value for "database"
|
51
|
+
Then I should have a node
|
52
|
+
And the hash of values should look like:
|
53
|
+
| username | steve |
|
54
|
+
| password | secret |
|
55
|
+
|
56
|
+
|
@@ -40,7 +40,23 @@ When /^I ask for the node value for "([^\"]*)"$/ do |key|
|
|
40
40
|
end
|
41
41
|
|
42
42
|
Given /^I have an environment variable named "([^\"]*)" set to "([^\"]*)"$/ do |env_name, filename|
|
43
|
+
FigNewton.yml = nil
|
43
44
|
ENV[env_name] = filename
|
44
45
|
FigNewton.yml_directory = 'config/yaml'
|
45
46
|
FigNewton.instance_variable_set(:@yml, nil)
|
46
47
|
end
|
48
|
+
|
49
|
+
Then /^the hash of values should look like:$/ do |table|
|
50
|
+
table.transpose.hashes.first.should == @value.to_hash
|
51
|
+
end
|
52
|
+
|
53
|
+
Given /^I have a yml file that is named after the hostname$/ do
|
54
|
+
FigNewton.yml = nil
|
55
|
+
FigNewton.yml_directory = 'config/yaml'
|
56
|
+
@hostname = Socket.gethostname
|
57
|
+
File.open("config/yaml/#{@hostname}.yml", 'w') {|file| file.write("from_the_hostname_file: read from the hostname file\n")}
|
58
|
+
end
|
59
|
+
|
60
|
+
Then /^I should remove the file$/ do
|
61
|
+
File.delete("config/yaml/#{@hostname}.yml")
|
62
|
+
end
|
data/fig_newton.gemspec
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
require File.expand_path('../lib/fig_newton/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = ["Jeff Morgan"]
|
6
|
-
gem.email = ["jeff.morgan@leandog.com"]
|
5
|
+
gem.authors = ["Jeff Morgan", "Steve Jackson"]
|
6
|
+
gem.email = ["jeff.morgan@leandog.com", "steve.jackson@leandogsoftware.com"]
|
7
7
|
gem.description = %q{Provides a simple mechanism to maintain and use different configurations stored in yml files.}
|
8
8
|
gem.summary = %q{Provides a simple mechanism to maintain and use different configurations stored in yml files.}
|
9
9
|
gem.homepage = "http://github.com/cheezy/fig_newton"
|
@@ -17,6 +17,6 @@ Gem::Specification.new do |gem|
|
|
17
17
|
|
18
18
|
gem.add_dependency 'yml_reader', '>= 0.2'
|
19
19
|
|
20
|
-
gem.add_development_dependency 'rspec', '>= 2.
|
21
|
-
gem.add_development_dependency 'cucumber', '>= 1.
|
20
|
+
gem.add_development_dependency 'rspec', '>= 2.12.0'
|
21
|
+
gem.add_development_dependency 'cucumber', '>= 1.2.0'
|
22
22
|
end
|
data/lib/fig_newton/missing.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
module FigNewton
|
2
4
|
module Missing
|
3
5
|
def method_missing(*args, &block)
|
@@ -10,8 +12,14 @@ module FigNewton
|
|
10
12
|
end
|
11
13
|
|
12
14
|
def read_file
|
15
|
+
@yml = nil
|
13
16
|
@yml = YAML.load_file "#{yml_directory}/#{ENV['FIG_NEWTON_FILE']}" if ENV['FIG_NEWTON_FILE']
|
14
|
-
|
17
|
+
hostname = Socket.gethostname
|
18
|
+
puts hostname
|
19
|
+
hostfile = "#{yml_directory}/#{hostname}.yml"
|
20
|
+
puts hostfile
|
21
|
+
@yml = YAML.load_file hostfile if File.exist? hostfile and @yml.nil?
|
22
|
+
FigNewton.load('default.yml') if @yml.nil?
|
15
23
|
end
|
16
24
|
|
17
25
|
private
|
data/lib/fig_newton/node.rb
CHANGED
data/lib/fig_newton/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fig_newton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.7'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jeff Morgan
|
9
|
+
- Steve Jackson
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
+
date: 2013-01-01 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: yml_reader
|
@@ -34,7 +35,7 @@ dependencies:
|
|
34
35
|
requirements:
|
35
36
|
- - ! '>='
|
36
37
|
- !ruby/object:Gem::Version
|
37
|
-
version: 2.
|
38
|
+
version: 2.12.0
|
38
39
|
type: :development
|
39
40
|
prerelease: false
|
40
41
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +43,7 @@ dependencies:
|
|
42
43
|
requirements:
|
43
44
|
- - ! '>='
|
44
45
|
- !ruby/object:Gem::Version
|
45
|
-
version: 2.
|
46
|
+
version: 2.12.0
|
46
47
|
- !ruby/object:Gem::Dependency
|
47
48
|
name: cucumber
|
48
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +51,7 @@ dependencies:
|
|
50
51
|
requirements:
|
51
52
|
- - ! '>='
|
52
53
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.
|
54
|
+
version: 1.2.0
|
54
55
|
type: :development
|
55
56
|
prerelease: false
|
56
57
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,11 +59,12 @@ dependencies:
|
|
58
59
|
requirements:
|
59
60
|
- - ! '>='
|
60
61
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
62
|
+
version: 1.2.0
|
62
63
|
description: Provides a simple mechanism to maintain and use different configurations
|
63
64
|
stored in yml files.
|
64
65
|
email:
|
65
66
|
- jeff.morgan@leandog.com
|
67
|
+
- steve.jackson@leandogsoftware.com
|
66
68
|
executables: []
|
67
69
|
extensions: []
|
68
70
|
extra_rdoc_files: []
|
@@ -105,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
107
|
version: '0'
|
106
108
|
segments:
|
107
109
|
- 0
|
108
|
-
hash:
|
110
|
+
hash: 3950624979441891503
|
109
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
112
|
none: false
|
111
113
|
requirements:
|
@@ -114,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
116
|
version: '0'
|
115
117
|
segments:
|
116
118
|
- 0
|
117
|
-
hash:
|
119
|
+
hash: 3950624979441891503
|
118
120
|
requirements: []
|
119
121
|
rubyforge_project:
|
120
122
|
rubygems_version: 1.8.24
|