yacht 0.2.0 → 0.2.5
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.
- data/README.rdoc +42 -2
- data/features/load.feature +17 -4
- data/features/missing_yaml_files.feature +6 -5
- data/features/step_definitions/aruba_extension_steps.rb +5 -0
- data/features/step_definitions/debugger_steps.rb +4 -0
- data/features/step_definitions/error_handling_steps.rb +0 -1
- data/features/step_definitions/javascript_steps.rb +9 -0
- data/features/step_definitions/loader_steps.rb +6 -2
- data/features/support/env.rb +2 -1
- data/lib/monkeypatches/rails_helper.rb +17 -0
- data/lib/yacht/base.rb +2 -0
- data/lib/yacht/javascript.rb +21 -0
- data/lib/yacht/loader.rb +7 -5
- data/lib/yacht/rails.rb +7 -0
- data/lib/yacht/version.rb +1 -1
- data/lib/yacht.rb +11 -4
- data/spec/monkeypatches/rails_helper_spec.rb +47 -0
- data/spec/yacht/classy_struct_spec.rb +0 -1
- data/spec/yacht/javascript_spec.rb +48 -0
- data/spec/yacht/loader_spec.rb +34 -0
- data/spec/yacht/rails_spec.rb +18 -5
- data/yacht.gemspec +3 -1
- metadata +35 -16
data/README.rdoc
CHANGED
@@ -55,17 +55,57 @@ First create two (or more) YAML files in the same directory to define your setti
|
|
55
55
|
production:
|
56
56
|
cdn_host: localhost
|
57
57
|
|
58
|
-
=== Step 2: Use Yacht.my_key or Yacht['my_key']
|
58
|
+
=== Step 2: Use Yacht.my_key or Yacht['my_key'] in ruby
|
59
59
|
|
60
60
|
* <b>Rails</b>:
|
61
61
|
# now you can access any key set in your YAML files with:
|
62
|
-
|
62
|
+
Yacht.my_key
|
63
|
+
# => "my_value"
|
63
64
|
|
64
65
|
* Outside of rails, you need to tell +Yacht+ where your YAML files are stored, and what environment you want to use.
|
65
66
|
Yacht::Loader.dir = '/path/to/YAML/dir'
|
66
67
|
Yacht::Loader.environment = 'my_environment'
|
67
68
|
Yacht.my_key
|
68
69
|
|
70
|
+
|
71
|
+
== Other features
|
72
|
+
|
73
|
+
=== Yacht::Loader.to_js_snippet export to javascript
|
74
|
+
If you would like to access values stored in Yacht inside of javascript, there is a helper for that. First, create a YAML file to tell Yacht which keys should be exported:
|
75
|
+
|
76
|
+
# config/yacht/base_keys.yml
|
77
|
+
# only keys listed here will be available in javascript
|
78
|
+
# remember that any values exported to javascript will be visible to all visitors to your site
|
79
|
+
- cookie_domain
|
80
|
+
|
81
|
+
Then use Yacht::Loader#to_js_snippet to create a string that can be eval'd or included in the DOM:
|
82
|
+
|
83
|
+
Yacht::Loader.to_js_snippet
|
84
|
+
# => ";var Yacht = {\"cookie_domain\":\"example.com\"};"
|
85
|
+
|
86
|
+
You can also add in extra values from outside of Yacht using the :merge option, like so:
|
87
|
+
|
88
|
+
Yacht::Loader.to_js_snippet(:merge => {:current_time => Time.now.to_s})
|
89
|
+
# => ";var Yacht = {\"cookie_domain\":\"example.com\",\"current_time\":\"06/29/2011\"};"
|
90
|
+
|
91
|
+
|
92
|
+
=== yacht_js_snippet Rails helper
|
93
|
+
|
94
|
+
When using Yacht inside of a Rails application, you can use the yacht_js_snippet method to wrap the string from Yacht::Loader#to_js_snippet in a script tag using Rails' javascript_tag helper.
|
95
|
+
|
96
|
+
Yacht.rails_env
|
97
|
+
# => "development" # Yacht automatically adds the current Rails environment in ruby
|
98
|
+
# If you want rails_env included in javascript, just add it to js_keys.yml
|
99
|
+
|
100
|
+
# inside a view or helper:
|
101
|
+
yacht_js_snippet
|
102
|
+
# => "<script type=\"text/javascript\">\n//<![CDATA[\n;var Yacht = {\"cookie_domain\":\"localhost\",\"rails_env\":\"development\"};\n//]]>\n</script>"
|
103
|
+
|
104
|
+
# you can also pass options to yacht_js_snippet:
|
105
|
+
yacht_js_snippet(:merge => {:current_time => Time.now.to_s})
|
106
|
+
# => "<script type=\"text/javascript\">\n//<![CDATA[\n;var Yacht = {\"cookie_domain\":\"localhost\",\"rails_env\":\"development\",\"current_time\":\"06/29/2011\"};\n//]]>\n</script>"
|
107
|
+
|
108
|
+
|
69
109
|
== License
|
70
110
|
|
71
111
|
Yacht is licensed under the MIT License with one addition: The Software shall be used for Good, not Evil.
|
data/features/load.feature
CHANGED
@@ -4,7 +4,7 @@ Feature: Load configuration settings
|
|
4
4
|
I want to load configuration settings from an external source like a YAML file
|
5
5
|
|
6
6
|
Background:
|
7
|
-
Given a file named "base.yml" with:
|
7
|
+
Given a file named "yacht/base.yml" with:
|
8
8
|
"""
|
9
9
|
default:
|
10
10
|
:api_key: some_fake_key
|
@@ -24,6 +24,7 @@ Feature: Load configuration settings
|
|
24
24
|
host: example.com
|
25
25
|
reply-to: info@example.com
|
26
26
|
"""
|
27
|
+
And I set Yacht's YAML directory to: "yacht"
|
27
28
|
|
28
29
|
Scenario: Load from YAML
|
29
30
|
When I load Yacht with environment: "development"
|
@@ -43,7 +44,7 @@ Feature: Load configuration settings
|
|
43
44
|
"""
|
44
45
|
|
45
46
|
Scenario: Local overrides with local.yml
|
46
|
-
Given a file named "local.yml" with:
|
47
|
+
Given a file named "yacht/local.yml" with:
|
47
48
|
"""
|
48
49
|
:api_key: some_crazy_local_key
|
49
50
|
"""
|
@@ -64,7 +65,7 @@ Feature: Load configuration settings
|
|
64
65
|
"""
|
65
66
|
|
66
67
|
Scenario: Whitelisting with whitelist.yml
|
67
|
-
|
68
|
+
Given a file named "yacht/whitelist.yml" with:
|
68
69
|
"""
|
69
70
|
- :partner_sites
|
70
71
|
"""
|
@@ -77,4 +78,16 @@ Feature: Load configuration settings
|
|
77
78
|
'github'
|
78
79
|
]
|
79
80
|
}
|
80
|
-
"""
|
81
|
+
"""
|
82
|
+
|
83
|
+
@js
|
84
|
+
Scenario: Generate a Yacht.js file
|
85
|
+
Given a file named "yacht/js_keys.yml" with:
|
86
|
+
"""
|
87
|
+
- :partner_sites
|
88
|
+
"""
|
89
|
+
When I use Yacht to generate a javascript snippet with environment: "development"
|
90
|
+
Then the javascript snippet should contain:
|
91
|
+
"""
|
92
|
+
;var Yacht = {"partner_sites":["twitter","github"]};
|
93
|
+
"""
|
@@ -3,28 +3,29 @@ Feature: Handle missing YAML files reasonably
|
|
3
3
|
Missing YAML files should cause an error to be raised when reasonable
|
4
4
|
|
5
5
|
Background:
|
6
|
-
Given a file named "base.yml" with:
|
6
|
+
Given a file named "yacht/base.yml" with:
|
7
7
|
"""
|
8
8
|
development:
|
9
9
|
api_key: some_fake_key
|
10
10
|
"""
|
11
|
+
And I set Yacht's YAML directory to: "yacht"
|
11
12
|
|
12
13
|
Scenario: No base.yml
|
13
|
-
Given a file named "base.yml" does not exist
|
14
|
+
Given a file named "yacht/base.yml" does not exist
|
14
15
|
When I try to use Yacht
|
15
16
|
Then Yacht should raise an error with message: "Couldn't load base config"
|
16
17
|
|
17
18
|
Scenario: No local.yml
|
18
|
-
Given a file named "local.yml" does not exist
|
19
|
+
Given a file named "yacht/local.yml" does not exist
|
19
20
|
When I try to use Yacht
|
20
21
|
Then Yacht should not raise an error
|
21
22
|
|
22
23
|
Scenario: No whitelist.yml but whitelist not used
|
23
|
-
Given a file named "whitelist.yml" does not exist
|
24
|
+
Given a file named "yacht/whitelist.yml" does not exist
|
24
25
|
When I try to use Yacht
|
25
26
|
Then Yacht should not raise an error
|
26
27
|
|
27
28
|
Scenario: No whitelist.yml and whitelist used
|
28
|
-
Given a file named "whitelist.yml" does not exist
|
29
|
+
Given a file named "yacht/whitelist.yml" does not exist
|
29
30
|
When I try to use Yacht with a whitelist
|
30
31
|
Then Yacht should raise an error with message: "Couldn't load whitelist"
|
@@ -2,4 +2,9 @@ Given /^a file named "([^"]*)" does not exist$/ do |file_name|
|
|
2
2
|
in_current_dir do
|
3
3
|
FileUtils.rm(file_name) if File.file?(file_name)
|
4
4
|
end
|
5
|
+
end
|
6
|
+
|
7
|
+
# Stock Aruba step definition doesn't recognize triple-quoted multiline strings
|
8
|
+
Then /^the file "([^"]*)" should contain:$/ do |file, exact_content|
|
9
|
+
check_exact_file_content(file, exact_content)
|
5
10
|
end
|
@@ -16,7 +16,6 @@ module ErrorHandlingHelpers
|
|
16
16
|
# If an error is raised, return it instead
|
17
17
|
def use_yacht(whitelist=false)
|
18
18
|
in_current_dir do
|
19
|
-
Yacht::Loader.dir = '.'
|
20
19
|
Yacht::Loader.environment = 'development'
|
21
20
|
Yacht::Loader.to_classy_struct(:apply_whitelist? => whitelist)
|
22
21
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
When /^I use Yacht to generate a javascript snippet with environment: "([^"]*)"$/ do |env|
|
2
|
+
in_current_dir do
|
3
|
+
@js_snippet = Yacht::Loader.to_js_snippet(:env => env)
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
Then /^the javascript snippet should contain:$/ do |string|
|
8
|
+
@js_snippet.should == string
|
9
|
+
end
|
@@ -1,6 +1,11 @@
|
|
1
|
+
Given /^I set Yacht's YAML directory to: "([^"]*)"$/ do |dir|
|
2
|
+
in_current_dir do
|
3
|
+
Yacht::Loader.dir = dir
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
1
7
|
When /^I define the constant "([^"]*)" with environment: "([^"]*)"( using a whitelist)?$/ do |constant_name, env, whitelist|
|
2
8
|
in_current_dir do
|
3
|
-
Yacht::Loader.dir = '.'
|
4
9
|
Yacht::Loader.environment = env
|
5
10
|
Object.const_set( constant_name, Yacht::Loader.to_classy_struct(:apply_whitelist? => whitelist ) )
|
6
11
|
end
|
@@ -15,7 +20,6 @@ Then /^the constant "([^"]*)" should contain the following hash:$/ do |constant_
|
|
15
20
|
end
|
16
21
|
|
17
22
|
When /^I load Yacht with environment: "([^"]*)"$/ do |env|
|
18
|
-
Yacht::Loader.dir = '.'
|
19
23
|
Yacht::Loader.environment = env
|
20
24
|
end
|
21
25
|
|
data/features/support/env.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Yacht::RailsHelper
|
2
|
+
# Create a string with a javascript version of Yacht values intended for inclusion in an HTML page
|
3
|
+
#
|
4
|
+
# @note environment will be set to Rails.env by default
|
5
|
+
#
|
6
|
+
# @example Set custom environment
|
7
|
+
# yacht_js_snippet(:env => 'local_development')
|
8
|
+
# # => "<script type=\"text/javascript\">;var Yacht = {\"foo\":\"bar\"};</script>"
|
9
|
+
def yacht_js_snippet(opts={})
|
10
|
+
javascript_tag Yacht::Loader.to_js_snippet(opts)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# TODO: use a Railtie to do this Rails-3-style
|
15
|
+
module ApplicationHelper
|
16
|
+
include Yacht::RailsHelper
|
17
|
+
end
|
data/lib/yacht/base.rb
CHANGED
@@ -3,10 +3,12 @@ class Yacht < BasicObject
|
|
3
3
|
end
|
4
4
|
|
5
5
|
class << self
|
6
|
+
# Return value for key retrieved from Yacht::Loader.to_hash
|
6
7
|
def [](key)
|
7
8
|
self._hash[key]
|
8
9
|
end
|
9
10
|
|
11
|
+
# Return a hash with all values for current environment
|
10
12
|
def _hash
|
11
13
|
@_hash ||= Loader.to_hash
|
12
14
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
class Yacht::Loader
|
4
|
+
class << self
|
5
|
+
# Returns a string snippet that can be eval'd in javascript
|
6
|
+
# or included in the DOM
|
7
|
+
# @param [Hash] opts the options to pass to to_hash
|
8
|
+
# @option opts [Hash] :merge ({}) hash to be merged into to_hash
|
9
|
+
def to_js_snippet(opts={})
|
10
|
+
hash_to_merge = opts.delete(:merge) || {}
|
11
|
+
hash = to_hash(opts).slice(*js_keys).merge(hash_to_merge)
|
12
|
+
";var Yacht = #{hash.to_json};"
|
13
|
+
end
|
14
|
+
|
15
|
+
def js_keys
|
16
|
+
load_config_file(:js_keys, :expect_to_load => Array) || begin
|
17
|
+
raise Yacht::LoadError.new("Couldn't load js_keys")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/yacht/loader.rb
CHANGED
@@ -7,12 +7,11 @@ class Yacht::Loader
|
|
7
7
|
end
|
8
8
|
attr_writer :environment
|
9
9
|
|
10
|
-
|
11
|
-
@dir ||= File.join( File.dirname(__FILE__), 'yacht')
|
12
|
-
end
|
13
|
-
attr_writer :dir
|
10
|
+
attr_accessor :dir
|
14
11
|
|
15
12
|
def full_file_path_for_config(config_type)
|
13
|
+
raise Yacht::LoadError.new "No directory set" unless dir
|
14
|
+
|
16
15
|
File.join( self.dir, "#{config_type}.yml" )
|
17
16
|
end
|
18
17
|
|
@@ -23,13 +22,16 @@ class Yacht::Loader
|
|
23
22
|
end
|
24
23
|
|
25
24
|
def valid_config_types
|
26
|
-
%w( base local whitelist )
|
25
|
+
%w( base local whitelist js_keys )
|
27
26
|
end
|
28
27
|
|
29
28
|
def all
|
30
29
|
chain_configs(base_config, self.environment).deep_merge(local_config)
|
31
30
|
end
|
32
31
|
|
32
|
+
# @param [Hash] opts the options for creating the hash
|
33
|
+
# @option opts [String] :env environment to use from base.yml
|
34
|
+
# @option opts [Boolean] :apply_whitelist? (false) only include keys in whitelist.yml
|
33
35
|
def to_hash(opts={})
|
34
36
|
opts[:apply_whitelist?] ||= false unless opts.has_key?(:apply_whitelist?)
|
35
37
|
self.environment = opts[:env] if opts.has_key?(:env)
|
data/lib/yacht/rails.rb
CHANGED
@@ -12,5 +12,12 @@ class Yacht::Loader
|
|
12
12
|
def full_file_path_for_config(config_type)
|
13
13
|
dir.join("#{config_type}.yml")
|
14
14
|
end
|
15
|
+
|
16
|
+
# Add current Rails environment to defined keys
|
17
|
+
def all_with_rails_env
|
18
|
+
all_without_rails_env.merge('rails_env' => Rails.env)
|
19
|
+
end
|
20
|
+
alias_method_chain :all, :rails_env
|
21
|
+
|
15
22
|
end
|
16
23
|
end
|
data/lib/yacht/version.rb
CHANGED
data/lib/yacht.rb
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
+
require "yacht/version"
|
2
|
+
|
3
|
+
require 'monkeypatches/hash'
|
4
|
+
|
1
5
|
require "yacht/base"
|
2
6
|
require "yacht/loader"
|
3
|
-
require "yacht/classy_struct"
|
4
|
-
require "yacht/version"
|
5
7
|
|
6
|
-
|
7
|
-
require
|
8
|
+
if Object.const_defined?(:Rails)
|
9
|
+
require "yacht/rails"
|
10
|
+
require "monkeypatches/rails_helper"
|
11
|
+
end
|
12
|
+
|
13
|
+
require "yacht/classy_struct"
|
14
|
+
require "yacht/javascript"
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Yacht::RailsHelper' do
|
4
|
+
let(:mock_js_string) {
|
5
|
+
';var Yacht = {"foo":"bar"};'
|
6
|
+
}
|
7
|
+
|
8
|
+
# need a dummy class to test out the Yacht::RailsHelper module
|
9
|
+
let(:dummy_class) {
|
10
|
+
class DummyClass
|
11
|
+
end
|
12
|
+
DummyClass
|
13
|
+
}
|
14
|
+
|
15
|
+
let(:dummy_instance) {
|
16
|
+
dummy_class.new
|
17
|
+
}
|
18
|
+
|
19
|
+
before do
|
20
|
+
Rails = stub('Rails')
|
21
|
+
|
22
|
+
require "monkeypatches/rails_helper"
|
23
|
+
|
24
|
+
dummy_class.send(:include, Yacht::RailsHelper)
|
25
|
+
end
|
26
|
+
|
27
|
+
describe :yacht_js_snippet do
|
28
|
+
it "should use javascript_tag to create a snippet using the current Rails environment by default" do
|
29
|
+
Yacht::Loader.stub(:to_js_snippet).and_return(mock_js_string)
|
30
|
+
dummy_instance.should_receive(:javascript_tag).with(mock_js_string)
|
31
|
+
|
32
|
+
dummy_instance.yacht_js_snippet
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should pass options to Yacht::Loader#to_js_snippet" do
|
36
|
+
dummy_instance.stub(:javascript_tag).as_null_object
|
37
|
+
|
38
|
+
Yacht::Loader.should_receive(:to_js_snippet).with(:foo => 'bar').and_return("")
|
39
|
+
|
40
|
+
dummy_instance.yacht_js_snippet(:foo => 'bar')
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should add yacht_js_snippet to ApplicationHelper" do
|
44
|
+
ApplicationHelper.should <= Yacht::RailsHelper
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Yacht::Loader do
|
4
|
+
subject{ Yacht::Loader }
|
5
|
+
|
6
|
+
let(:mock_js_string) {
|
7
|
+
';var Yacht = {"foo":"bar"};'
|
8
|
+
}
|
9
|
+
|
10
|
+
describe :to_js_snippet do
|
11
|
+
it "should export Yacht values to a javascript file" do
|
12
|
+
subject.stub(:all).and_return(:foo => 'bar')
|
13
|
+
subject.stub(:js_keys).and_return(:foo)
|
14
|
+
|
15
|
+
subject.to_js_snippet.should == ';var Yacht = {"foo":"bar"};'
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should only export values defined in javascript.yml" do
|
19
|
+
subject.stub(:to_hash).and_return(:foo => 'bar', :baz => 'snafu')
|
20
|
+
subject.stub(:js_keys).and_return(:baz)
|
21
|
+
|
22
|
+
subject.to_js_snippet.should == ';var Yacht = {"baz":"snafu"};'
|
23
|
+
end
|
24
|
+
|
25
|
+
it "merges the hash passed with :merge" do
|
26
|
+
subject.stub(:to_hash).and_return(:foo => 'bar', :baz => 'snafu')
|
27
|
+
subject.stub(:js_keys).and_return(:baz)
|
28
|
+
|
29
|
+
subject.to_js_snippet(:merge => {:request_id => 123}).should == ';var Yacht = {"baz":"snafu","request_id":123};'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe :js_keys do
|
34
|
+
it "raises an error if load_config_file returns nil" do
|
35
|
+
subject.stub(:load_config_file).with(:js_keys, :expect_to_load => Array).and_return(nil)
|
36
|
+
|
37
|
+
expect {
|
38
|
+
subject.js_keys
|
39
|
+
}.to raise_error( Yacht::LoadError, "Couldn't load js_keys")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "expects load_config_file to return an Array" do
|
43
|
+
subject.should_receive(:load_config_file).with(:js_keys, :expect_to_load => Array).and_return([])
|
44
|
+
|
45
|
+
subject.js_keys
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/spec/yacht/loader_spec.rb
CHANGED
@@ -16,6 +16,9 @@ describe Yacht::Loader do
|
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
+
describe :dir do
|
20
|
+
end
|
21
|
+
|
19
22
|
describe :to_hash do
|
20
23
|
before do
|
21
24
|
subject.stub(:base_config).and_return(mock_base_config)
|
@@ -96,6 +99,7 @@ describe Yacht::Loader do
|
|
96
99
|
:color_of_the_day => 'purple',
|
97
100
|
}
|
98
101
|
})
|
102
|
+
subject.stub(:local_config).and_return({})
|
99
103
|
|
100
104
|
subject.environment = 'wacky'
|
101
105
|
subject.to_hash[:color_of_the_day].should == 'purple'
|
@@ -198,7 +202,37 @@ describe Yacht::Loader do
|
|
198
202
|
subject.send(:load_config_file, :foo, :expect_to_load => Array)
|
199
203
|
}.to raise_error( Yacht::LoadError, "foo_file must contain Array (got Hash)" )
|
200
204
|
end
|
205
|
+
end
|
206
|
+
|
207
|
+
describe :_load_config_file do
|
208
|
+
it "returns nil if file does not exist" do
|
209
|
+
File.stub(:exists?).with('some_file').and_return(false)
|
210
|
+
subject.send(:_load_config_file, 'some_file').should be_nil
|
211
|
+
end
|
212
|
+
|
213
|
+
it "opens the file using YAML.load if the file exists" do
|
214
|
+
File.stub(:exists?).with('some_file').and_return(true)
|
215
|
+
File.stub(:read).with('some_file').and_return('some contents')
|
216
|
+
YAML.should_receive(:load).with('some contents')
|
217
|
+
|
218
|
+
subject.send(:_load_config_file, 'some_file')
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
describe :full_file_path_for_config do
|
223
|
+
it "raises an error if dir is blank" do
|
224
|
+
subject.stub(:dir).and_return(nil)
|
225
|
+
|
226
|
+
expect {
|
227
|
+
subject.full_file_path_for_config(:base)
|
228
|
+
}.to raise_error( Yacht::LoadError, "No directory set" )
|
229
|
+
end
|
201
230
|
|
231
|
+
it "returns the full path to the YAML file for the given config type" do
|
232
|
+
subject.stub(:dir).and_return('/full/path')
|
233
|
+
|
234
|
+
subject.full_file_path_for_config(:foo).should == '/full/path/foo.yml'
|
235
|
+
end
|
202
236
|
end
|
203
237
|
|
204
238
|
context "checks environment and sets sensible defaults" do
|
data/spec/yacht/rails_spec.rb
CHANGED
@@ -4,18 +4,17 @@ describe "Rails support" do
|
|
4
4
|
subject { Yacht::Loader }
|
5
5
|
|
6
6
|
before do
|
7
|
+
Rails = stub("Rails")
|
8
|
+
Object.stub(:alias_method_chain).as_null_object
|
7
9
|
require "yacht/rails"
|
8
10
|
@yacht_dir = "/path/to/rails/config/yacht"
|
9
11
|
end
|
10
12
|
|
11
13
|
describe :environment do
|
12
|
-
before do
|
13
|
-
Rails = stub("Rails")
|
14
|
-
end
|
15
14
|
it "uses the current rails environment by default" do
|
16
|
-
Rails.should_receive(:env)
|
15
|
+
Rails.should_receive(:env).and_return('awesome')
|
17
16
|
|
18
|
-
subject.environment
|
17
|
+
subject.environment.should == 'awesome'
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
@@ -36,4 +35,18 @@ describe "Rails support" do
|
|
36
35
|
subject.full_file_path_for_config("some")
|
37
36
|
end
|
38
37
|
end
|
38
|
+
|
39
|
+
describe :all_with_rails_env do
|
40
|
+
it "adds the current Rails environment to super" do
|
41
|
+
subject.stub(:all_without_rails_env).and_return(:foo => :bar)
|
42
|
+
|
43
|
+
Rails.stub(:env).and_return(:awesome)
|
44
|
+
subject.all_with_rails_env.should == {:foo => :bar, 'rails_env' => :awesome}
|
45
|
+
end
|
46
|
+
|
47
|
+
it "aliases all to all_without_rails_env" do
|
48
|
+
Object.should_receive(:alias_method_chain).with(:all, :rails_env)
|
49
|
+
load "yacht/rails.rb"
|
50
|
+
end
|
51
|
+
end
|
39
52
|
end
|
data/yacht.gemspec
CHANGED
@@ -16,14 +16,16 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.platform = Gem::Platform::RUBY
|
17
17
|
|
18
18
|
s.add_dependency "classy_struct", ">= 0.3.2"
|
19
|
+
s.add_dependency "json"
|
19
20
|
|
20
|
-
s.add_development_dependency "gherkin", '
|
21
|
+
s.add_development_dependency "gherkin", '>= 2.4.0'
|
21
22
|
s.add_development_dependency "cucumber", '>= 0.10.0'
|
22
23
|
s.add_development_dependency 'aruba'
|
23
24
|
s.add_development_dependency "rspec", '>= 2.6.0'
|
24
25
|
s.add_development_dependency "simplecov", '>= 0.4.1'
|
25
26
|
|
26
27
|
|
28
|
+
|
27
29
|
s.required_rubygems_version = ">= 1.3.7"
|
28
30
|
s.files = `git ls-files`.split("\n")
|
29
31
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: yacht
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mani Tadayon
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-06-
|
14
|
+
date: 2011-06-29 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -26,60 +26,71 @@ dependencies:
|
|
26
26
|
type: :runtime
|
27
27
|
version_requirements: *id001
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: json
|
30
30
|
prerelease: false
|
31
31
|
requirement: &id002 !ruby/object:Gem::Requirement
|
32
32
|
none: false
|
33
33
|
requirements:
|
34
|
-
- -
|
34
|
+
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
37
|
-
type: :
|
36
|
+
version: "0"
|
37
|
+
type: :runtime
|
38
38
|
version_requirements: *id002
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
|
-
name:
|
40
|
+
name: gherkin
|
41
41
|
prerelease: false
|
42
42
|
requirement: &id003 !ruby/object:Gem::Requirement
|
43
43
|
none: false
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2.4.0
|
48
48
|
type: :development
|
49
49
|
version_requirements: *id003
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
|
-
name:
|
51
|
+
name: cucumber
|
52
52
|
prerelease: false
|
53
53
|
requirement: &id004 !ruby/object:Gem::Requirement
|
54
54
|
none: false
|
55
55
|
requirements:
|
56
56
|
- - ">="
|
57
57
|
- !ruby/object:Gem::Version
|
58
|
-
version:
|
58
|
+
version: 0.10.0
|
59
59
|
type: :development
|
60
60
|
version_requirements: *id004
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
62
|
+
name: aruba
|
63
63
|
prerelease: false
|
64
64
|
requirement: &id005 !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: "0"
|
70
70
|
type: :development
|
71
71
|
version_requirements: *id005
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
|
-
name:
|
73
|
+
name: rspec
|
74
74
|
prerelease: false
|
75
75
|
requirement: &id006 !ruby/object:Gem::Requirement
|
76
76
|
none: false
|
77
77
|
requirements:
|
78
78
|
- - ">="
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version:
|
80
|
+
version: 2.6.0
|
81
81
|
type: :development
|
82
82
|
version_requirements: *id006
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
prerelease: false
|
86
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 0.4.1
|
92
|
+
type: :development
|
93
|
+
version_requirements: *id007
|
83
94
|
description: Yacht is Yet Another Configuration Helper Tool.
|
84
95
|
email:
|
85
96
|
- mtadayon@atti.com
|
@@ -103,22 +114,28 @@ files:
|
|
103
114
|
- features/load.feature
|
104
115
|
- features/missing_yaml_files.feature
|
105
116
|
- features/step_definitions/aruba_extension_steps.rb
|
117
|
+
- features/step_definitions/debugger_steps.rb
|
106
118
|
- features/step_definitions/error_handling_steps.rb
|
119
|
+
- features/step_definitions/javascript_steps.rb
|
107
120
|
- features/step_definitions/loader_steps.rb
|
108
121
|
- features/support/cleanup.rb
|
109
122
|
- features/support/env.rb
|
110
123
|
- gem_tasks/cucumber.rake
|
111
124
|
- gem_tasks/spec.rake
|
112
125
|
- lib/monkeypatches/hash.rb
|
126
|
+
- lib/monkeypatches/rails_helper.rb
|
113
127
|
- lib/yacht.rb
|
114
128
|
- lib/yacht/base.rb
|
115
129
|
- lib/yacht/classy_struct.rb
|
130
|
+
- lib/yacht/javascript.rb
|
116
131
|
- lib/yacht/loader.rb
|
117
132
|
- lib/yacht/rails.rb
|
118
133
|
- lib/yacht/version.rb
|
134
|
+
- spec/monkeypatches/rails_helper_spec.rb
|
119
135
|
- spec/spec_helper.rb
|
120
136
|
- spec/yacht/base_spec.rb
|
121
137
|
- spec/yacht/classy_struct_spec.rb
|
138
|
+
- spec/yacht/javascript_spec.rb
|
122
139
|
- spec/yacht/loader_spec.rb
|
123
140
|
- spec/yacht/rails_spec.rb
|
124
141
|
- yacht.gemspec
|
@@ -146,13 +163,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
163
|
requirements: []
|
147
164
|
|
148
165
|
rubyforge_project:
|
149
|
-
rubygems_version: 1.3.9.
|
166
|
+
rubygems_version: 1.3.9.2
|
150
167
|
signing_key:
|
151
168
|
specification_version: 3
|
152
|
-
summary: yacht-0.2.
|
169
|
+
summary: yacht-0.2.5
|
153
170
|
test_files:
|
171
|
+
- spec/monkeypatches/rails_helper_spec.rb
|
154
172
|
- spec/spec_helper.rb
|
155
173
|
- spec/yacht/base_spec.rb
|
156
174
|
- spec/yacht/classy_struct_spec.rb
|
175
|
+
- spec/yacht/javascript_spec.rb
|
157
176
|
- spec/yacht/loader_spec.rb
|
158
177
|
- spec/yacht/rails_spec.rb
|