daikon 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/daikon.gemspec +2 -2
- data/lib/daikon.rb +4 -2
- data/lib/daikon/client.rb +7 -5
- data/spec/client_spec.rb +22 -1
- metadata +5 -5
data/daikon.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{daikon}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nick Quaranto"]
|
12
|
-
s.date = %q{2010-11-
|
12
|
+
s.date = %q{2010-11-23}
|
13
13
|
s.default_executable = %q{daikon}
|
14
14
|
s.description = %q{daikon, a radishapp.com client}
|
15
15
|
s.email = %q{nick@quaran.to}
|
data/lib/daikon.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
|
2
|
+
|
3
3
|
require 'logger'
|
4
|
+
require 'pp'
|
4
5
|
require 'shellwords'
|
5
6
|
require 'socket'
|
7
|
+
require 'stringio'
|
6
8
|
|
7
9
|
require 'system_timer'
|
8
10
|
require 'daemons'
|
@@ -22,5 +24,5 @@ require 'daikon/client'
|
|
22
24
|
require 'daikon/daemon'
|
23
25
|
|
24
26
|
module Daikon
|
25
|
-
VERSION = "0.
|
27
|
+
VERSION = "0.2.0"
|
26
28
|
end
|
data/lib/daikon/client.rb
CHANGED
@@ -54,9 +54,11 @@ module Daikon
|
|
54
54
|
|
55
55
|
commands.each do |id, command|
|
56
56
|
result = evaluate_redis(command)
|
57
|
+
pretty = StringIO.new
|
58
|
+
PP.pp(result, pretty)
|
57
59
|
|
58
60
|
http_request(:put, "api/v1/commands/#{id}.json") do |request|
|
59
|
-
request.body =
|
61
|
+
request.body = {"response" => pretty.string.strip}.to_json
|
60
62
|
request.add_field "Content-Length", request.body.size.to_s
|
61
63
|
request.add_field "Content-Type", "application/json"
|
62
64
|
end
|
@@ -96,16 +98,16 @@ module Daikon
|
|
96
98
|
rescue Exception => e
|
97
99
|
STDERR.puts e.message
|
98
100
|
e.backtrace.each {|bt| STDERR.puts bt}
|
99
|
-
return
|
101
|
+
return e.message
|
100
102
|
end
|
101
|
-
return
|
103
|
+
return "No command received." unless argv[0]
|
102
104
|
|
103
105
|
begin
|
104
|
-
|
106
|
+
execute_redis(argv)
|
105
107
|
rescue Exception => e
|
106
108
|
STDERR.puts e.message
|
107
109
|
e.backtrace.each {|bt| STDERR.puts bt}
|
108
|
-
|
110
|
+
e.message
|
109
111
|
end
|
110
112
|
end
|
111
113
|
|
data/spec/client_spec.rb
CHANGED
@@ -70,7 +70,7 @@ describe Daikon::Client, "fetching commands" do
|
|
70
70
|
let(:body) { {"42" => "INCR foo", "43" => "DECR foo"}.to_json }
|
71
71
|
|
72
72
|
before do
|
73
|
-
subject.stubs(:evaluate_redis =>
|
73
|
+
subject.stubs(:evaluate_redis => 9999)
|
74
74
|
stub_request(:get, "#{server}/api/v1/commands.json").to_return(:body => body)
|
75
75
|
stub_request(:put, %r{#{server}/api/v1/commands/\d+\.json})
|
76
76
|
|
@@ -209,3 +209,24 @@ describe Daikon::Client, "rotate monitor" do
|
|
209
209
|
it_should_behave_like "a monitor api consumer"
|
210
210
|
end
|
211
211
|
end
|
212
|
+
|
213
|
+
describe Daikon::Client, "pretty printing results" do
|
214
|
+
subject { Daikon::Client.new }
|
215
|
+
let(:body) { {"13" => "LRANGE foo 0 -1"}.to_json }
|
216
|
+
let(:list) { %w[apples bananas carrots] }
|
217
|
+
let(:server) { "https://radishapp.com" }
|
218
|
+
let(:config) { Daikon::Configuration.new }
|
219
|
+
|
220
|
+
before do
|
221
|
+
subject.stubs(:evaluate_redis => list)
|
222
|
+
stub_request(:get, "#{server}/api/v1/commands.json").to_return(:body => body)
|
223
|
+
stub_request(:put, %r{#{server}/api/v1/commands/\d+\.json})
|
224
|
+
subject.setup(config)
|
225
|
+
subject.fetch_commands
|
226
|
+
end
|
227
|
+
|
228
|
+
it "returns pretty printed results" do
|
229
|
+
WebMock.should have_requested(:put, "#{server}/api/v1/commands/13.json").
|
230
|
+
with(:body => {"response" => "[\"apples\", \"bananas\", \"carrots\"]"})
|
231
|
+
end
|
232
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daikon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Nick Quaranto
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-23 00:00:00 -05:00
|
19
19
|
default_executable: daikon
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|