lackie 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/lackie/cache_buster.rb +8 -0
- data/lib/lackie/remote_control.rb +11 -10
- data/lib/lackie.rb +1 -1
- data/spec/lackie/cache_buster_spec.rb +10 -0
- data/spec/lackie/remote_control_spec.rb +2 -4
- metadata +7 -4
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'restclient'
|
2
2
|
require 'json'
|
3
3
|
require 'lackie/poller'
|
4
|
+
require 'lackie/cache_buster'
|
4
5
|
|
5
6
|
module Lackie
|
6
7
|
class RemoteControl
|
@@ -17,15 +18,6 @@ module Lackie
|
|
17
18
|
poll_for_result(command, options)
|
18
19
|
end
|
19
20
|
|
20
|
-
def send_command(command)
|
21
|
-
url = "http://#{@host}:#{@port}/lackie/eval"
|
22
|
-
begin
|
23
|
-
RestClient.post(url, command)
|
24
|
-
rescue => e
|
25
|
-
raise ConnectionError.new(url, e)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
21
|
def await(expression, options={})
|
30
22
|
result = nil
|
31
23
|
begin
|
@@ -43,6 +35,15 @@ module Lackie
|
|
43
35
|
end
|
44
36
|
|
45
37
|
private
|
38
|
+
|
39
|
+
def send_command(command)
|
40
|
+
url = "http://#{@host}:#{@port}/lackie/eval"
|
41
|
+
begin
|
42
|
+
RestClient.post(url, command)
|
43
|
+
rescue => e
|
44
|
+
raise ConnectionError.new(url, e)
|
45
|
+
end
|
46
|
+
end
|
46
47
|
|
47
48
|
def poll_for_result(command, options={})
|
48
49
|
body = nil
|
@@ -55,7 +56,7 @@ module Lackie
|
|
55
56
|
|
56
57
|
def retrieve_result_body
|
57
58
|
begin
|
58
|
-
RestClient.get("http://#{@host}:#{@port}/lackie/result?#{
|
59
|
+
RestClient.get("http://#{@host}:#{@port}/lackie/result?#{CacheBuster.unique_string}").body
|
59
60
|
rescue RestClient::ResourceNotFound
|
60
61
|
nil
|
61
62
|
end
|
data/lib/lackie.rb
CHANGED
@@ -4,7 +4,7 @@ require 'lackie/javascript'
|
|
4
4
|
module Lackie
|
5
5
|
describe RemoteControl do
|
6
6
|
before(:each) do
|
7
|
-
|
7
|
+
CacheBuster.stub!(:unique_string).and_return("cachebust")
|
8
8
|
@poller = Poller.new(:sleeper => mock("sleeper", :sleep => true))
|
9
9
|
Poller.stub!(:new).and_return(@poller)
|
10
10
|
@rc = RemoteControl.new("host", 555, @poller)
|
@@ -35,9 +35,7 @@ module Lackie
|
|
35
35
|
end
|
36
36
|
|
37
37
|
it "cache-busts calls to GET /lackie/result" do
|
38
|
-
|
39
|
-
Time.should_receive(:now).and_return(now)
|
40
|
-
now.should_receive(:to_i).and_return("letmego")
|
38
|
+
CacheBuster.should_receive(:unique_string).and_return("letmego")
|
41
39
|
RestClient.should_receive(:get).with("http://host:555/lackie/result?letmego").and_return(
|
42
40
|
mock("response", :body => '{"value":"123"}')
|
43
41
|
)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lackie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 9
|
10
|
+
version: 0.1.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Josh Chisholm
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- features/support/example_app/app.html
|
152
152
|
- lackie.gemspec
|
153
153
|
- lib/lackie.rb
|
154
|
+
- lib/lackie/cache_buster.rb
|
154
155
|
- lib/lackie/javascript.rb
|
155
156
|
- lib/lackie/javascript/json2.js
|
156
157
|
- lib/lackie/javascript/surrender.js
|
@@ -160,6 +161,7 @@ files:
|
|
160
161
|
- lib/lackie/rack/logger.rb
|
161
162
|
- lib/lackie/rack/middleware.rb
|
162
163
|
- lib/lackie/remote_control.rb
|
164
|
+
- spec/lackie/cache_buster_spec.rb
|
163
165
|
- spec/lackie/javascript/surrender_spec.rb
|
164
166
|
- spec/lackie/poller_spec.rb
|
165
167
|
- spec/lackie/rack/logging_spec.rb
|
@@ -199,7 +201,7 @@ rubyforge_project:
|
|
199
201
|
rubygems_version: 1.4.1
|
200
202
|
signing_key:
|
201
203
|
specification_version: 3
|
202
|
-
summary: lackie-0.1.
|
204
|
+
summary: lackie-0.1.9
|
203
205
|
test_files:
|
204
206
|
- features/remote_control.feature
|
205
207
|
- features/step_definitions/lackie_steps.rb
|
@@ -207,6 +209,7 @@ test_files:
|
|
207
209
|
- features/support/env.rb
|
208
210
|
- features/support/example_app.rb
|
209
211
|
- features/support/example_app/app.html
|
212
|
+
- spec/lackie/cache_buster_spec.rb
|
210
213
|
- spec/lackie/javascript/surrender_spec.rb
|
211
214
|
- spec/lackie/poller_spec.rb
|
212
215
|
- spec/lackie/rack/logging_spec.rb
|