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 CHANGED
@@ -1,3 +1,8 @@
1
+ === Version 0.7 / 2013-1-1
2
+ * Enhancements
3
+ * Added a to_hash method to Node
4
+ * Added check to see if yml file named after hostname exists.
5
+
1
6
  === Version 0.6 / 2012-11-14
2
7
  * Fixes
3
8
  * Fixed a problem where it would not return an integer (Thanks Steve Jackson)
@@ -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.8.0'
21
- gem.add_development_dependency 'cucumber', '>= 1.1.0'
20
+ gem.add_development_dependency 'rspec', '>= 2.12.0'
21
+ gem.add_development_dependency 'cucumber', '>= 1.2.0'
22
22
  end
@@ -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
- FigNewton.load('default.yml') unless ENV['FIG_NEWTON_FILE']
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
@@ -7,5 +7,9 @@ module FigNewton
7
7
  def initialize(yml)
8
8
  @yml = yml
9
9
  end
10
+
11
+ def to_hash
12
+ @yml
13
+ end
10
14
  end
11
15
  end
@@ -1,3 +1,3 @@
1
1
  module FigNewton
2
- VERSION = "0.6"
2
+ VERSION = "0.7"
3
3
  end
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.6'
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: 2012-11-14 00:00:00.000000000 Z
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.8.0
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.8.0
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.1.0
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.1.0
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: 2254345954836371452
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: 2254345954836371452
119
+ hash: 3950624979441891503
118
120
  requirements: []
119
121
  rubyforge_project:
120
122
  rubygems_version: 1.8.24