breadboard 0.0.2 → 0.1.0
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/lib/breadboard.rb +1 -1
- data/lib/breadboard/breadboard.rb +16 -8
- data/spec/lib_specs/breadboard_spec.rb +2 -2
- metadata +1 -1
data/lib/breadboard.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
require 'active_resource'
|
2
2
|
require 'breadboard/breadboard'
|
3
|
-
Breadboard.new((File.open(RAILS_ROOT + "/config/breadboard.yml") rescue "")) if defined?(RAILS_ROOT)
|
3
|
+
BREAD_BOARD = Breadboard.new((File.open(RAILS_ROOT + "/config/breadboard.yml") rescue "")) if defined?(RAILS_ROOT)
|
@@ -5,7 +5,6 @@ class Breadboard
|
|
5
5
|
|
6
6
|
def initialize(config_yml)
|
7
7
|
@config = YAML.load config_yml
|
8
|
-
configure_services
|
9
8
|
end
|
10
9
|
|
11
10
|
def environment
|
@@ -24,12 +23,21 @@ class Breadboard
|
|
24
23
|
(@config['default']['all'] rescue nil) ||
|
25
24
|
''
|
26
25
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
end
|
27
|
+
|
28
|
+
class ActiveResource::Base
|
29
|
+
class << self
|
30
|
+
def site_with_breadboard
|
31
|
+
if defined?(BREAD_BOARD)
|
32
|
+
unless @site
|
33
|
+
self.site = BREAD_BOARD.service_for(self.to_s)
|
34
|
+
end
|
35
|
+
@site
|
36
|
+
else
|
37
|
+
self.site_without_breadboard
|
38
|
+
end
|
33
39
|
end
|
40
|
+
|
41
|
+
alias_method_chain :site, :breadboard
|
34
42
|
end
|
35
|
-
end
|
43
|
+
end
|
@@ -28,7 +28,7 @@ describe Breadboard do
|
|
28
28
|
class Author < ActiveResource::Base; end
|
29
29
|
class Article < ActiveResource::Base; end
|
30
30
|
class Genre < ActiveResource::Base; end
|
31
|
-
Breadboard.new(@yml)
|
31
|
+
define_const "BREAD_BOARD", Breadboard.new(@yml)
|
32
32
|
Book.site.host.should == "all.book.services.com"
|
33
33
|
Author.site.host.should == "development.author.services.com"
|
34
34
|
Article.site.host.should == "services.com"
|
@@ -67,4 +67,4 @@ describe Breadboard do
|
|
67
67
|
@s.service_for('Book').should == 'http://all.book.services.com'
|
68
68
|
end
|
69
69
|
end
|
70
|
-
end
|
70
|
+
end
|