fig_newton 0.3 → 0.4

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.4 / 2012-6-9
2
+ * Fixes
3
+ * Updated yml_reader dependency to fix issue with using default directory
4
+ * Made change to the way files are read - default directory and file work properly now.
5
+
1
6
  === Version 0.3 / 2012-5-22
2
7
  * Enhancements
3
8
  * Added support for reading filename from environment variable FIG_NEWTON_FILE
data/README.md CHANGED
@@ -16,9 +16,9 @@ FigNewton.load('system_test.yml')
16
16
 
17
17
  Next we simply begin calling methods on the FigNewton module that match our keys. Let's assume the system_test.yml file contains the following entries:
18
18
 
19
- base_url: http://system_test.mycompany.com
20
- database_user: cheezy
21
- database_password: secret
19
+ base_url: http://system_test.mycompany.com
20
+ database_user: cheezy
21
+ database_password: secret
22
22
 
23
23
  In our code we can call methods that match the keys. Here is an example PageObject where we are using the `base_url` entry:
24
24
 
@@ -37,6 +37,7 @@ default: FIG_NEWTON_FILE=local.yml --color --format pretty
37
37
  ci: FIG_NEWTON_FILE=ci.yml --color --format pretty
38
38
  test: FIG_NEWTON_FILE=test.yml --color --format pretty
39
39
  staging: FIG_NEWTON_FILE=staging.yml --color --format pretty
40
+ ````
40
41
 
41
42
  When you run the cucumber command you can easily select the correct profile which in turn will select the correct configuration file for your environment.
42
43
 
@@ -0,0 +1,2 @@
1
+ base_url: 'http://cheezyworld.com'
2
+
@@ -28,3 +28,9 @@ Feature: Functionality of the fig_newton gem
28
28
  And I ask for the node value for "second"
29
29
  Then the "third" value for the node should be "foo"
30
30
  And the "fourth" value for the node should be "bar"
31
+
32
+ Scenario: Using default directory and file
33
+ Given I have read the default file from the default directory
34
+ When I ask for the value for "base_url"
35
+ Then I should see "http://cheezyworld.com"
36
+
@@ -1,7 +1,12 @@
1
1
  Given /^I have read the configuration file$/ do
2
+ FigNewton.yml_directory = 'config/yaml'
2
3
  FigNewton.load 'test_config.yml'
3
4
  end
4
5
 
6
+ When /^I have read the default file from the default directory$/ do
7
+ FigNewton.yml = nil
8
+ end
9
+
5
10
  When /^I ask for the value for "([^\"]*)"$/ do |key|
6
11
  @value = FigNewton.send key
7
12
  end
@@ -32,5 +37,6 @@ end
32
37
 
33
38
  Given /^I have an environment variable named "([^\"]*)" set to "([^\"]*)"$/ do |env_name, filename|
34
39
  ENV[env_name] = filename
40
+ FigNewton.yml_directory = 'config/yaml'
35
41
  FigNewton.instance_variable_set(:@yml, nil)
36
42
  end
@@ -3,4 +3,9 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../', 'lib'))
3
3
  require 'rspec/expectations'
4
4
  require 'fig_newton'
5
5
 
6
- FigNewton.yml_directory = 'config/yaml'
6
+ Before do
7
+ FigNewton.yml_directory = nil
8
+ ENV.delete 'FIG_NEWTON_FILE'
9
+ end
10
+
11
+
data/fig_newton.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = FigNewton::VERSION
17
17
 
18
- gem.add_dependency 'yml_reader', '>= 0.1'
18
+ gem.add_dependency 'yml_reader', '>= 0.2'
19
19
 
20
20
  gem.add_development_dependency 'rspec', '>= 2.8.0'
21
21
  gem.add_development_dependency 'cucumber', '>= 1.1.0'
@@ -1,7 +1,7 @@
1
1
  module FigNewton
2
2
  module Missing
3
3
  def method_missing(*args, &block)
4
- read_env_file unless @yml
4
+ read_file unless @yml
5
5
  m = args.first
6
6
  value = @yml[m.to_s]
7
7
  super unless value
@@ -9,8 +9,9 @@ module FigNewton
9
9
  value
10
10
  end
11
11
 
12
- def read_env_file
13
- @yml = YAML.load_file "#{@yml_directory}/#{ENV['FIG_NEWTON_FILE']}"
12
+ def read_file
13
+ @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']
14
15
  end
15
16
  end
16
17
  end
@@ -1,3 +1,3 @@
1
1
  module FigNewton
2
- VERSION = "0.3"
2
+ VERSION = "0.4"
3
3
  end
data/lib/fig_newton.rb CHANGED
@@ -7,8 +7,12 @@ module FigNewton
7
7
  extend YmlReader
8
8
  extend FigNewton::Missing
9
9
 
10
- def self.default_directory
11
- 'config/environments'
12
- end
13
10
 
11
+ class << self
12
+ attr_accessor :yml
13
+
14
+ def default_directory
15
+ 'config/environments'
16
+ end
17
+ end
14
18
  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.3'
4
+ version: '0.4'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-22 00:00:00.000000000 Z
12
+ date: 2012-06-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yml_reader
16
- requirement: &70201006592140 !ruby/object:Gem::Requirement
16
+ requirement: &70200586622860 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: '0.1'
21
+ version: '0.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70201006592140
24
+ version_requirements: *70200586622860
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &70201006591640 !ruby/object:Gem::Requirement
27
+ requirement: &70200586621460 !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: *70201006591640
35
+ version_requirements: *70200586621460
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: cucumber
38
- requirement: &70201006591180 !ruby/object:Gem::Requirement
38
+ requirement: &70200586620520 !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: *70201006591180
46
+ version_requirements: *70200586620520
47
47
  description: Provides a simple mechanism to maintain and use different configurations
48
48
  stored in yml files.
49
49
  email:
@@ -62,6 +62,7 @@ files:
62
62
  - LICENSE
63
63
  - README.md
64
64
  - Rakefile
65
+ - config/environments/default.yml
65
66
  - config/yaml/sample.yml
66
67
  - config/yaml/test_config.yml
67
68
  - cucumber.yml