breadboard 1.0.1 → 1.1.0.rc1
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/CHANGELOG +3 -0
- data/Gemfile.lock +7 -7
- data/VERSION +1 -1
- data/features/configure.feature +8 -0
- data/features/step_definitions/active_resource_steps.rb +3 -3
- data/features/step_definitions/configure_steps.rb +48 -0
- data/lib/breadboard.rb +1 -0
- data/lib/breadboard/active_resource.rb +10 -4
- data/lib/breadboard/breadboard.rb +2 -10
- data/lib/breadboard/env_config.rb +28 -0
- data/lib/breadboard/environment.rb +12 -3
- data/readme.md +13 -0
- metadata +76 -58
data/CHANGELOG
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
breadboard (1.0.
|
4
|
+
breadboard (1.0.2)
|
5
5
|
activeresource (~> 3.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: http://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (3.0.
|
11
|
-
activesupport (= 3.0.
|
10
|
+
activemodel (3.0.11)
|
11
|
+
activesupport (= 3.0.11)
|
12
12
|
builder (~> 2.1.2)
|
13
13
|
i18n (~> 0.5.0)
|
14
|
-
activeresource (3.0.
|
15
|
-
activemodel (= 3.0.
|
16
|
-
activesupport (= 3.0.
|
17
|
-
activesupport (3.0.
|
14
|
+
activeresource (3.0.11)
|
15
|
+
activemodel (= 3.0.11)
|
16
|
+
activesupport (= 3.0.11)
|
17
|
+
activesupport (3.0.11)
|
18
18
|
builder (2.1.2)
|
19
19
|
cucumber (0.10.2)
|
20
20
|
builder (>= 2.1.2)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.1.0.rc1
|
data/features/configure.feature
CHANGED
@@ -26,3 +26,11 @@ Feature: Configuring Breadboard
|
|
26
26
|
Scenario: configuring the method for determining the Rails environment
|
27
27
|
Given I have required breadboard
|
28
28
|
Then I should be able to override the default Rails.env environment retrieval in case I'm not in a rails app
|
29
|
+
|
30
|
+
Scenario: Configure Breadboard with hash instead of url
|
31
|
+
Given I have required breadboard
|
32
|
+
Then I should be able to configure breadboard with hash
|
33
|
+
|
34
|
+
Scenario: Configure model with user, password
|
35
|
+
Given I have required breadboard
|
36
|
+
Then I should be able to configure model with user, password
|
@@ -137,15 +137,15 @@ Given /^my Rails environment is "([^"]*)"$/ do |environment|
|
|
137
137
|
end
|
138
138
|
|
139
139
|
Then /^I should recieve the value configured in the Breadboard "([^"]*)" environment settings for that model$/ do |environment|
|
140
|
-
NoSiteAttribute.site.
|
140
|
+
NoSiteAttribute.site.should == Breadboard.config.NoSiteAttribute.send(environment.to_sym).site
|
141
141
|
end
|
142
142
|
|
143
143
|
Then /^I should recieve the value configured in the Breadboard "([^"]*)" environment settings for the ancestor of that model$/ do |environment|
|
144
|
-
NoSiteAttribute.site.
|
144
|
+
NoSiteAttribute.site.should == Breadboard.config.Parent.send(environment.to_sym).site
|
145
145
|
end
|
146
146
|
|
147
147
|
Then /^I should recieve the value configured in the Breadboard "([^"]*)" environment settings in the breadboard defaults section$/ do |environment|
|
148
|
-
NoSiteAttribute.site.
|
148
|
+
NoSiteAttribute.site.should == Breadboard.config.default.send(environment.to_sym).site
|
149
149
|
end
|
150
150
|
|
151
151
|
Then /^ActiveResource should ignore more generic configurations in Breadboard$/ do
|
@@ -87,3 +87,51 @@ Then /^I should be able to override the default Rails\.env environment retrieval
|
|
87
87
|
end
|
88
88
|
Breadboard.env.should == "override!"
|
89
89
|
end
|
90
|
+
|
91
|
+
Then /^I should be able to configure breadboard with hash$/ do
|
92
|
+
Breadboard.configure do
|
93
|
+
default do
|
94
|
+
all do
|
95
|
+
site "http://localhost:3000"
|
96
|
+
user "admin"
|
97
|
+
password "password"
|
98
|
+
end
|
99
|
+
|
100
|
+
development "http://test"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
Breadboard.config.default.all.to_s.should == "http://localhost:3000"
|
105
|
+
Breadboard.config.default.all.site.to_s.should == "http://localhost:3000"
|
106
|
+
Breadboard.config.default.all.user.should == "admin"
|
107
|
+
Breadboard.config.default.all.password.should == "password"
|
108
|
+
|
109
|
+
Breadboard.config.default.development.to_s.should == "http://test"
|
110
|
+
end
|
111
|
+
|
112
|
+
Then /^I should be able to configure model with user, password$/ do
|
113
|
+
class Venue < ActiveResource::Base
|
114
|
+
end
|
115
|
+
|
116
|
+
Breadboard.configure do
|
117
|
+
env {"production"}
|
118
|
+
|
119
|
+
model Venue do
|
120
|
+
all do
|
121
|
+
site "http://localhost:3000"
|
122
|
+
user "admin"
|
123
|
+
password "password"
|
124
|
+
end
|
125
|
+
|
126
|
+
production do
|
127
|
+
site "http://livesite"
|
128
|
+
user "admin"
|
129
|
+
password "secret"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
Venue.site.to_s.should == "http://livesite"
|
135
|
+
Venue.password.should == "secret"
|
136
|
+
end
|
137
|
+
|
data/lib/breadboard.rb
CHANGED
@@ -1,16 +1,22 @@
|
|
1
1
|
module ActiveResource
|
2
2
|
class Base
|
3
3
|
class << self
|
4
|
-
|
5
|
-
|
4
|
+
class_eval do
|
5
|
+
%w(site user password).each do |attr|
|
6
|
+
define_method "#{attr}_with_breadboard" do
|
7
|
+
@site || begin
|
8
|
+
setting = Breadboard.service_for(self)
|
9
|
+
setting.kind_of?(Breadboard::Config::EnvConfig) ? setting.send(attr) : setting
|
10
|
+
end
|
11
|
+
end
|
12
|
+
alias_method_chain attr, :breadboard
|
13
|
+
end
|
6
14
|
end
|
7
15
|
|
8
16
|
def connection_with_breadboard(reset=false)
|
9
17
|
@connection ||= nil
|
10
18
|
connection_without_breadboard(reset)
|
11
19
|
end
|
12
|
-
|
13
|
-
alias_method_chain :site, :breadboard
|
14
20
|
alias_method_chain :connection, :breadboard
|
15
21
|
end
|
16
22
|
end
|
@@ -19,19 +19,11 @@ module Breadboard
|
|
19
19
|
model_superclass_chain.each do |klass|
|
20
20
|
klass_symbol = klass.to_s.to_sym
|
21
21
|
site = config.send(klass_symbol).send(environment) || config.send(klass_symbol).send(:all)
|
22
|
-
if site
|
23
|
-
site = site.call if site.respond_to? :call
|
24
|
-
site = URI.parse site
|
22
|
+
if site and !site.empty?
|
25
23
|
return site
|
26
24
|
end
|
27
25
|
end
|
28
|
-
|
29
|
-
site = config.default.send(environment) || config.default.send(:all)
|
30
|
-
if site
|
31
|
-
site = site.call if site.respond_to? :call
|
32
|
-
site = URI.parse site
|
33
|
-
return site
|
34
|
-
end
|
26
|
+
return config.default.send(environment) || config.default.send(:all)
|
35
27
|
end
|
36
28
|
|
37
29
|
def reset
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Breadboard
|
2
|
+
module Config
|
3
|
+
# holds site, user, password values for an environment instance
|
4
|
+
class EnvConfig
|
5
|
+
def initialize
|
6
|
+
@config = {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def site=(url)
|
10
|
+
@config[:site] = url
|
11
|
+
end
|
12
|
+
|
13
|
+
def method_missing(method_name, *args, &block)
|
14
|
+
return @config[method_name] if args.length == 0
|
15
|
+
@config[method_name] = args.first
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_s
|
19
|
+
@config[:site].to_s
|
20
|
+
end
|
21
|
+
|
22
|
+
def empty?
|
23
|
+
@config.empty?
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -7,12 +7,21 @@ module Breadboard
|
|
7
7
|
|
8
8
|
def test(url=nil)
|
9
9
|
return @environments[:test] if url.nil?
|
10
|
-
@environments[:test] = url
|
10
|
+
@environments[:test] = URI.parse url
|
11
11
|
end
|
12
12
|
|
13
13
|
def method_missing(method_name, *args, &block)
|
14
|
-
|
15
|
-
|
14
|
+
if block_given?
|
15
|
+
@environments[method_name] ||= EnvConfig.new
|
16
|
+
@environments[method_name].instance_eval &block
|
17
|
+
else
|
18
|
+
if args.length == 0
|
19
|
+
@environments[method_name]
|
20
|
+
else
|
21
|
+
@environments[method_name] ||= EnvConfig.new
|
22
|
+
@environments[method_name].site URI.parse args.first
|
23
|
+
end
|
24
|
+
end
|
16
25
|
end
|
17
26
|
end
|
18
27
|
end
|
data/readme.md
CHANGED
@@ -76,6 +76,19 @@ Now suppose you have a 'Book' model that needs to connect to a different service
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
+
If you need to set user and password for a restful service, you can do so with a block
|
80
|
+
|
81
|
+
Breadboard.configure do
|
82
|
+
model Book do
|
83
|
+
production do
|
84
|
+
site "http://my.book.production.service.provider"
|
85
|
+
user "user1"
|
86
|
+
password "password"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
|
79
92
|
## Configuring the environment
|
80
93
|
|
81
94
|
By default, Breadboard will check `Rails.env` to see what environment your app is in.
|
metadata
CHANGED
@@ -1,72 +1,80 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: breadboard
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15424039
|
5
|
+
prerelease: 6
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
- rc
|
11
|
+
- 1
|
12
|
+
version: 1.1.0.rc1
|
6
13
|
platform: ruby
|
7
|
-
authors:
|
14
|
+
authors:
|
8
15
|
- Matt Parker
|
9
16
|
autorequire:
|
10
17
|
bindir: bin
|
11
18
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
19
|
+
|
20
|
+
date: 2011-04-26 00:00:00 Z
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
15
23
|
name: activeresource
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '3.0'
|
22
|
-
type: :runtime
|
23
24
|
prerelease: false
|
24
|
-
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
26
|
none: false
|
26
|
-
requirements:
|
27
|
+
requirements:
|
27
28
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 7
|
31
|
+
segments:
|
32
|
+
- 3
|
33
|
+
- 0
|
34
|
+
version: "3.0"
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
31
38
|
name: cucumber
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 0.10.0
|
38
|
-
type: :development
|
39
39
|
prerelease: false
|
40
|
-
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
|
-
requirements:
|
42
|
+
requirements:
|
43
43
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 55
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 10
|
49
|
+
- 0
|
45
50
|
version: 0.10.0
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ~>
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 2.4.0
|
54
51
|
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: rspec
|
55
55
|
prerelease: false
|
56
|
-
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
|
-
requirements:
|
58
|
+
requirements:
|
59
59
|
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 31
|
62
|
+
segments:
|
63
|
+
- 2
|
64
|
+
- 4
|
65
|
+
- 0
|
61
66
|
version: 2.4.0
|
62
|
-
|
63
|
-
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
69
|
+
description: "Breadboard allows you to define what services your ActiveResource derived classes connect to based on your rails environment. "
|
64
70
|
email: moonmaster9000@gmail.com
|
65
71
|
executables: []
|
72
|
+
|
66
73
|
extensions: []
|
67
|
-
|
74
|
+
|
75
|
+
extra_rdoc_files:
|
68
76
|
- readme.md
|
69
|
-
files:
|
77
|
+
files:
|
70
78
|
- .gitignore
|
71
79
|
- .rvmrc
|
72
80
|
- CHANGELOG
|
@@ -87,33 +95,43 @@ files:
|
|
87
95
|
- lib/breadboard/active_resource.rb
|
88
96
|
- lib/breadboard/breadboard.rb
|
89
97
|
- lib/breadboard/config.rb
|
98
|
+
- lib/breadboard/env_config.rb
|
90
99
|
- lib/breadboard/environment.rb
|
91
100
|
- readme.md
|
92
101
|
homepage: http://github.com/moonmaster9000/breadboard
|
93
102
|
licenses: []
|
103
|
+
|
94
104
|
post_install_message:
|
95
105
|
rdoc_options: []
|
96
|
-
|
106
|
+
|
107
|
+
require_paths:
|
97
108
|
- lib
|
98
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
110
|
none: false
|
100
|
-
requirements:
|
101
|
-
- -
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
|
104
|
-
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
hash: 3
|
115
|
+
segments:
|
116
|
+
- 0
|
117
|
+
version: "0"
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
119
|
none: false
|
106
|
-
requirements:
|
107
|
-
- -
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
hash: 3
|
124
|
+
segments:
|
125
|
+
- 0
|
126
|
+
version: "0"
|
110
127
|
requirements: []
|
128
|
+
|
111
129
|
rubyforge_project:
|
112
|
-
rubygems_version: 1.8.
|
130
|
+
rubygems_version: 1.8.10
|
113
131
|
signing_key:
|
114
132
|
specification_version: 3
|
115
133
|
summary: Simple, environment-based service provider configuration for ActiveResource
|
116
|
-
test_files:
|
134
|
+
test_files:
|
117
135
|
- features/active_resource.feature
|
118
136
|
- features/configure.feature
|
119
137
|
- features/reset.feature
|