copycopter_client 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -0
- data/lib/copycopter_client.rb +8 -8
- data/lib/copycopter_client/configuration.rb +11 -8
- data/lib/copycopter_client/version.rb +2 -2
- data/spec/copycopter_client/cache_spec.rb +3 -1
- data/spec/copycopter_client/client_spec.rb +3 -1
- data/spec/copycopter_client/configuration_spec.rb +3 -11
- data/spec/copycopter_client/process_guard_spec.rb +1 -1
- data/spec/copycopter_client_spec.rb +19 -0
- metadata +12 -13
data/README.md
CHANGED
data/lib/copycopter_client.rb
CHANGED
@@ -8,19 +8,11 @@ require 'copycopter_client/configuration'
|
|
8
8
|
# appropriate.
|
9
9
|
module CopycopterClient
|
10
10
|
class << self
|
11
|
-
# @return [Client] instance used to communicate with the Copycopter server.
|
12
|
-
# This is set when {.configure} is called.
|
13
|
-
attr_accessor :client
|
14
|
-
|
15
11
|
# @return [Configuration] current client configuration
|
16
12
|
# Must act like a hash and return sensible values for all Copycopter
|
17
13
|
# configuration options. Usually set when {.configure} is called.
|
18
14
|
attr_accessor :configuration
|
19
15
|
|
20
|
-
# @return [Cache] instance used to synchronize changes.
|
21
|
-
# This is set when {.configure} is called.
|
22
|
-
attr_accessor :cache
|
23
|
-
|
24
16
|
# @return [Poller] instance used to poll for changes.
|
25
17
|
# This is set when {.configure} is called.
|
26
18
|
attr_accessor :poller
|
@@ -42,6 +34,14 @@ module CopycopterClient
|
|
42
34
|
cache.flush
|
43
35
|
end
|
44
36
|
|
37
|
+
def self.cache
|
38
|
+
CopycopterClient.configuration.cache
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.client
|
42
|
+
CopycopterClient.configuration.client
|
43
|
+
end
|
44
|
+
|
45
45
|
# Call this method to modify defaults in your initializers.
|
46
46
|
#
|
47
47
|
# @example
|
@@ -84,6 +84,12 @@ module CopycopterClient
|
|
84
84
|
# @return [String] the path to a root certificate file used to verify ssl sessions. Default's to the root certificate file for copycopter.com.
|
85
85
|
attr_accessor :ca_file
|
86
86
|
|
87
|
+
# @return [Cache] instance used internally to synchronize changes.
|
88
|
+
attr_accessor :cache
|
89
|
+
|
90
|
+
# @return [Client] instance used to communicate with the Copycopter server.
|
91
|
+
attr_accessor :client
|
92
|
+
|
87
93
|
alias_method :secure?, :secure
|
88
94
|
|
89
95
|
# Instantiated from {CopycopterClient.configure}. Sets defaults.
|
@@ -100,7 +106,6 @@ module CopycopterClient
|
|
100
106
|
self.polling_delay = 300
|
101
107
|
self.logger = Logger.new($stdout)
|
102
108
|
self.ca_file = CA_FILE
|
103
|
-
|
104
109
|
@applied = false
|
105
110
|
end
|
106
111
|
|
@@ -158,17 +163,15 @@ module CopycopterClient
|
|
158
163
|
#
|
159
164
|
# Called automatically when {CopycopterClient.configure} is called in the application.
|
160
165
|
#
|
161
|
-
# This creates the {
|
166
|
+
# This creates the {I18nBackend} and puts them together.
|
162
167
|
#
|
163
168
|
# When {#test?} returns +false+, the poller will be started.
|
164
169
|
def apply
|
165
|
-
client
|
166
|
-
cache
|
167
|
-
poller
|
170
|
+
self.client ||= Client.new(to_hash)
|
171
|
+
self.cache ||= Cache.new(client, to_hash)
|
172
|
+
poller = Poller.new(cache, to_hash)
|
168
173
|
process_guard = ProcessGuard.new(cache, poller, to_hash)
|
169
|
-
I18n.backend
|
170
|
-
CopycopterClient.client = client
|
171
|
-
CopycopterClient.cache = cache
|
174
|
+
I18n.backend = I18nBackend.new(cache)
|
172
175
|
middleware.use(RequestSync, :cache => cache) if middleware && development?
|
173
176
|
@applied = true
|
174
177
|
logger.info("Client #{VERSION} ready")
|
@@ -196,7 +196,9 @@ describe CopycopterClient::Cache do
|
|
196
196
|
|
197
197
|
it "flushes from the top level" do
|
198
198
|
cache = build_cache
|
199
|
-
CopycopterClient.
|
199
|
+
CopycopterClient.configure do |config|
|
200
|
+
config.cache = cache
|
201
|
+
end
|
200
202
|
cache.stubs(:flush)
|
201
203
|
|
202
204
|
CopycopterClient.flush
|
@@ -195,7 +195,9 @@ describe CopycopterClient do
|
|
195
195
|
|
196
196
|
it "deploys from the top-level constant" do
|
197
197
|
client = build_client
|
198
|
-
CopycopterClient.
|
198
|
+
CopycopterClient.configure do |config|
|
199
|
+
config.client = client
|
200
|
+
end
|
199
201
|
client.stubs(:deploy)
|
200
202
|
|
201
203
|
CopycopterClient.deploy
|
@@ -43,6 +43,8 @@ describe CopycopterClient::Configuration do
|
|
43
43
|
it { should have_config_option(:polling_delay). overridable.default(300) }
|
44
44
|
it { should have_config_option(:framework). overridable }
|
45
45
|
it { should have_config_option(:middleware). overridable }
|
46
|
+
it { should have_config_option(:client). overridable }
|
47
|
+
it { should have_config_option(:cache). overridable }
|
46
48
|
|
47
49
|
it "provides the root ssl certificate" do
|
48
50
|
should have_config_option(:ca_file).
|
@@ -194,7 +196,7 @@ end
|
|
194
196
|
|
195
197
|
share_examples_for "applied configuration" do
|
196
198
|
let(:backend) { stub('i18n-backend') }
|
197
|
-
let(:cache)
|
199
|
+
let(:cache) { stub('cache') }
|
198
200
|
let(:client) { stub('client') }
|
199
201
|
let(:poller) { stub('poller') }
|
200
202
|
let(:process_guard) { stub('process_guard', :start => nil) }
|
@@ -214,8 +216,6 @@ share_examples_for "applied configuration" do
|
|
214
216
|
it { should be_applied }
|
215
217
|
|
216
218
|
it "builds and assigns an I18n backend" do
|
217
|
-
CopycopterClient::Client.should have_received(:new).with(subject.to_hash)
|
218
|
-
CopycopterClient::Cache.should have_received(:new).with(client, subject.to_hash)
|
219
219
|
CopycopterClient::I18nBackend.should have_received(:new).with(cache)
|
220
220
|
I18n.backend.should == backend
|
221
221
|
end
|
@@ -236,14 +236,6 @@ share_examples_for "applied configuration" do
|
|
236
236
|
it "logs environment info" do
|
237
237
|
logger.should have_entry(:info, "Environment Info: #{subject.environment_info}")
|
238
238
|
end
|
239
|
-
|
240
|
-
it "stores the client" do
|
241
|
-
CopycopterClient.client.should == client
|
242
|
-
end
|
243
|
-
|
244
|
-
it "stores the cache" do
|
245
|
-
CopycopterClient.cache.should == cache
|
246
|
-
end
|
247
239
|
end
|
248
240
|
|
249
241
|
describe CopycopterClient::Configuration, "applied when testing" do
|
@@ -16,7 +16,7 @@ describe CopycopterClient::ProcessGuard do
|
|
16
16
|
|
17
17
|
def build_process_guard(options = {})
|
18
18
|
options[:logger] ||= FakeLogger.new
|
19
|
-
options[:cache]
|
19
|
+
options[:cache] ||= cache
|
20
20
|
CopycopterClient::ProcessGuard.new(options[:cache], poller, options)
|
21
21
|
end
|
22
22
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CopycopterClient do
|
4
|
+
|
5
|
+
before do
|
6
|
+
CopycopterClient.configuration.stubs(:cache => 'cache',
|
7
|
+
:client => 'client')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'delegates cache to the configuration object' do
|
11
|
+
CopycopterClient.cache.should == 'cache'
|
12
|
+
CopycopterClient.configuration.should have_received(:cache).once
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'delegates client to the configuration object' do
|
16
|
+
CopycopterClient.client.should == 'client'
|
17
|
+
CopycopterClient.configuration.should have_received(:client).once
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: copycopter_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 4
|
10
|
+
version: 1.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- thoughtbot
|
@@ -15,12 +15,9 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-08-31 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
|
-
name: i18n
|
23
|
-
prerelease: false
|
24
21
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
22
|
none: false
|
26
23
|
requirements:
|
@@ -32,11 +29,11 @@ dependencies:
|
|
32
29
|
- 5
|
33
30
|
- 0
|
34
31
|
version: 0.5.0
|
35
|
-
type: :runtime
|
36
32
|
version_requirements: *id001
|
37
|
-
|
38
|
-
name: json
|
33
|
+
name: i18n
|
39
34
|
prerelease: false
|
35
|
+
type: :runtime
|
36
|
+
- !ruby/object:Gem::Dependency
|
40
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
38
|
none: false
|
42
39
|
requirements:
|
@@ -46,8 +43,10 @@ dependencies:
|
|
46
43
|
segments:
|
47
44
|
- 0
|
48
45
|
version: "0"
|
49
|
-
type: :runtime
|
50
46
|
version_requirements: *id002
|
47
|
+
name: json
|
48
|
+
prerelease: false
|
49
|
+
type: :runtime
|
51
50
|
description:
|
52
51
|
email: support@thoughtbot.com
|
53
52
|
executables: []
|
@@ -84,6 +83,7 @@ files:
|
|
84
83
|
- spec/copycopter_client/prefixed_logger_spec.rb
|
85
84
|
- spec/copycopter_client/process_guard_spec.rb
|
86
85
|
- spec/copycopter_client/request_sync_spec.rb
|
86
|
+
- spec/copycopter_client_spec.rb
|
87
87
|
- spec/spec_helper.rb
|
88
88
|
- spec/support/client_spec_helpers.rb
|
89
89
|
- spec/support/defines_constants.rb
|
@@ -101,7 +101,6 @@ files:
|
|
101
101
|
- features/step_definitions/rails_steps.rb
|
102
102
|
- features/support/env.rb
|
103
103
|
- features/support/rails_server.rb
|
104
|
-
has_rdoc: true
|
105
104
|
homepage: http://github.com/thoughtbot/copycopter_client
|
106
105
|
licenses: []
|
107
106
|
|
@@ -131,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
130
|
requirements: []
|
132
131
|
|
133
132
|
rubyforge_project: copycopter_client
|
134
|
-
rubygems_version: 1.
|
133
|
+
rubygems_version: 1.8.6
|
135
134
|
signing_key:
|
136
135
|
specification_version: 3
|
137
136
|
summary: Client for the Copycopter content management service
|