fig_newton 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ - rbx-19mode
7
+ - ree
8
+ - ruby-head
data/ChangeLog ADDED
@@ -0,0 +1,6 @@
1
+ === Version 0.2 / 2012-5-16
2
+ * Enhancements
3
+ * Added support for nested hashes
4
+
5
+ === Version 0.1 / 2012-5-3
6
+ * Initial Release
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # FigNewton
2
2
 
3
+ [![Build Status](http://travis-ci.org/cheezy/fig_newton.png)](http://travis-ci.org/cheezy/fig_newton)
4
+
3
5
  Manages configuration for test suites. It is common to need different configuration information for different test environments. For example, the base_url or database login information might change when you move from development to a test environment. FigNewton makes it simple to create and use this information.
4
6
 
5
7
  ## Usage
@@ -1 +1,10 @@
1
1
  base_url: 'http://cheezyworld.com'
2
+
3
+ database:
4
+ username: steve
5
+ password: secret
6
+
7
+ first:
8
+ second:
9
+ third: foo
10
+ fourth: bar
data/cucumber.yml CHANGED
@@ -1 +1 @@
1
- default: --no-source --color --format Cucumber::Formatter::Fuubar
1
+ default: --no-source --color --format pretty
@@ -10,3 +10,16 @@ Feature: Functionality of the fig_newton gem
10
10
  When I ask for a value that does not exist named "does_not_exist"
11
11
  Then I should raise a NoMethodError exception
12
12
 
13
+ Scenario: Requesting data that contains a node of additional data
14
+ Given I have read the configuration file
15
+ When I ask for the value for "database"
16
+ Then I should have a node
17
+ And the "username" value for the node should be "steve"
18
+ And the "password" value for the node should be "secret"
19
+
20
+ Scenario: Requesting data from multiple nested data
21
+ Given I have read the configuration file
22
+ When I ask for the value for "first"
23
+ And I ask for the node value for "second"
24
+ Then the "third" value for the node should be "foo"
25
+ And the "fourth" value for the node should be "bar"
@@ -17,3 +17,16 @@ end
17
17
  Then /^I should raise a NoMethodError exception$/ do
18
18
  expect{ FigNewton.send(@does_not_exist) }.to raise_error(NoMethodError)
19
19
  end
20
+
21
+ Then /^I should have a node$/ do
22
+ @value.should be_an_instance_of FigNewton::Node
23
+ end
24
+
25
+ Then /^the "([^\"]*)" value for the node should be "([^\"]*)"$/ do |key, value|
26
+ @value.send(key).should == value
27
+ end
28
+
29
+ When /^I ask for the node value for "([^\"]*)"$/ do |key|
30
+ @value = @value.send(key)
31
+ end
32
+
data/lib/fig_newton.rb CHANGED
@@ -1,17 +1,13 @@
1
- require "fig_newton/version"
1
+ require 'fig_newton/version'
2
+ require 'fig_newton/node'
3
+ require 'fig_newton/missing'
2
4
  require 'yml_reader'
3
5
 
4
6
  module FigNewton
5
7
  extend YmlReader
8
+ extend FigNewton::Missing
6
9
 
7
10
  def self.default_directory
8
11
  'config/environments'
9
12
  end
10
-
11
- def self.method_missing(*args, &block)
12
- m = args.first
13
- value = @yml[m.to_s]
14
- super unless value
15
- value
16
- end
17
13
  end
@@ -0,0 +1,11 @@
1
+ module FigNewton
2
+ module Missing
3
+ def method_missing(*args, &block)
4
+ m = args.first
5
+ value = @yml[m.to_s]
6
+ super unless value
7
+ value = FigNewton::Node.new(value) unless value.kind_of? String
8
+ value
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + "/missing"
2
+
3
+ module FigNewton
4
+ class Node
5
+ include FigNewton::Missing
6
+
7
+ def initialize(yml)
8
+ @yml = yml
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,3 @@
1
1
  module FigNewton
2
- VERSION = "0.1"
2
+ VERSION = "0.2"
3
3
  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.1'
4
+ version: '0.2'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-03 00:00:00.000000000 Z
12
+ date: 2012-05-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yml_reader
16
- requirement: &70117719454340 !ruby/object:Gem::Requirement
16
+ requirement: &70353545646100 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70117719454340
24
+ version_requirements: *70353545646100
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70117719450580 !ruby/object:Gem::Requirement
27
+ requirement: &70353545645600 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.8.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70117719450580
35
+ version_requirements: *70353545645600
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: cucumber
38
- requirement: &70117719449760 !ruby/object:Gem::Requirement
38
+ requirement: &70353545645140 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 1.1.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70117719449760
46
+ version_requirements: *70353545645140
47
47
  description: Provides a simple mechanism to maintain and use different configurations
48
48
  stored in yml files.
49
49
  email:
@@ -55,6 +55,8 @@ files:
55
55
  - .gitignore
56
56
  - .rspec
57
57
  - .rvmrc
58
+ - .travis.yml
59
+ - ChangeLog
58
60
  - Gemfile
59
61
  - Guardfile
60
62
  - LICENSE
@@ -67,6 +69,8 @@ files:
67
69
  - features/support/env.rb
68
70
  - fig_newton.gemspec
69
71
  - lib/fig_newton.rb
72
+ - lib/fig_newton/missing.rb
73
+ - lib/fig_newton/node.rb
70
74
  - lib/fig_newton/version.rb
71
75
  - spec/fig_newton/fig_newton_spec.rb
72
76
  - spec/spec_helper.rb