daikon 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/daikon +1 -1
- data/daikon.gemspec +4 -2
- data/lib/daikon.rb +1 -1
- data/lib/daikon/client.rb +1 -1
- data/lib/daikon/configuration.rb +5 -5
- data/lib/daikon/daemon.rb +8 -3
- data/spec/client_spec.rb +5 -5
- data/spec/configuration_spec.rb +3 -1
- data/spec/daemon_spec.rb +13 -0
- metadata +6 -4
data/bin/daikon
CHANGED
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.3.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-29}
|
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}
|
@@ -38,6 +38,7 @@ Gem::Specification.new do |s|
|
|
38
38
|
"lib/daikon/namespace_tools.rb",
|
39
39
|
"spec/client_spec.rb",
|
40
40
|
"spec/configuration_spec.rb",
|
41
|
+
"spec/daemon_spec.rb",
|
41
42
|
"spec/daikon_spec.rb",
|
42
43
|
"spec/spec_helper.rb"
|
43
44
|
]
|
@@ -49,6 +50,7 @@ Gem::Specification.new do |s|
|
|
49
50
|
s.test_files = [
|
50
51
|
"spec/client_spec.rb",
|
51
52
|
"spec/configuration_spec.rb",
|
53
|
+
"spec/daemon_spec.rb",
|
52
54
|
"spec/daikon_spec.rb",
|
53
55
|
"spec/spec_helper.rb"
|
54
56
|
]
|
data/lib/daikon.rb
CHANGED
data/lib/daikon/client.rb
CHANGED
@@ -17,7 +17,7 @@ module Daikon
|
|
17
17
|
def setup(config, logger = nil)
|
18
18
|
self.config = config
|
19
19
|
self.logger = logger
|
20
|
-
self.redis = Redis.new(:port => config.redis_port)
|
20
|
+
self.redis = Redis.new(:host => config.redis_host, :port => config.redis_port)
|
21
21
|
self.http = Net::HTTP::Persistent.new
|
22
22
|
http.headers['Authorization'] = config.api_key
|
23
23
|
|
data/lib/daikon/configuration.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Daikon
|
2
2
|
class Configuration
|
3
|
-
FLAGS = %w[-p -k -f -s]
|
4
|
-
OPTIONS = %w[redis_port api_key field_id server_prefix]
|
5
|
-
DEFAULTS = %w[6379 1234567890 1 https://radishapp.com]
|
3
|
+
FLAGS = %w[-h -p -k -f -s]
|
4
|
+
OPTIONS = %w[redis_host redis_port api_key field_id server_prefix]
|
5
|
+
DEFAULTS = %w[127.0.0.1 6379 1234567890 1 https://radishapp.com]
|
6
6
|
|
7
7
|
attr_accessor *OPTIONS
|
8
8
|
|
@@ -18,8 +18,8 @@ module Daikon
|
|
18
18
|
send "#{OPTIONS[flag_index]}=", value
|
19
19
|
end
|
20
20
|
|
21
|
-
if api_key == DEFAULTS[
|
22
|
-
abort "Must supply an api key to start the daemon.\nExample: daikon start #{FLAGS[
|
21
|
+
if api_key == DEFAULTS[2] && argv.any? { |arg| arg =~ /start|run/ }
|
22
|
+
abort "Must supply an api key to start the daemon.\nExample: daikon start #{FLAGS[2]} #{DEFAULTS[2]}"
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
data/lib/daikon/daemon.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
module Daikon
|
2
2
|
class Daemon
|
3
|
-
def self.start
|
4
|
-
config = Daikon::Configuration.new(
|
3
|
+
def self.start(argv)
|
4
|
+
config = Daikon::Configuration.new(argv)
|
5
|
+
|
6
|
+
if argv.include?("-v") || argv.include?("--version")
|
7
|
+
puts "Daikon v#{VERSION}"
|
8
|
+
return
|
9
|
+
end
|
5
10
|
|
6
11
|
Daemons.run_proc("daikon", :log_output => true, :backtrace => true) do
|
7
|
-
if
|
12
|
+
if argv.include?("run")
|
8
13
|
logger = Logger.new(STDOUT)
|
9
14
|
else
|
10
15
|
logger = Logger.new("/tmp/radish.log")
|
data/spec/client_spec.rb
CHANGED
@@ -10,20 +10,20 @@ describe Daikon::Client, "setup" do
|
|
10
10
|
subject.stubs(:redis=)
|
11
11
|
end
|
12
12
|
|
13
|
-
context "with
|
14
|
-
let(:config) { Daikon::Configuration.new(%w[-p 1234]) }
|
13
|
+
context "with overrides" do
|
14
|
+
let(:config) { Daikon::Configuration.new(%w[-h 8.8.8.8 -p 1234]) }
|
15
15
|
|
16
16
|
before do
|
17
17
|
subject.setup(config, logger)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "sets redis to listen on the given port" do
|
21
|
-
Redis.should have_received(:new).with(:port => "1234")
|
21
|
+
Redis.should have_received(:new).with(:host => "8.8.8.8", :port => "1234")
|
22
22
|
subject.should have_received(:redis=).with(redis)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
context "with
|
26
|
+
context "with defaults" do
|
27
27
|
let(:config) { Daikon::Configuration.new([]) }
|
28
28
|
|
29
29
|
before do
|
@@ -31,7 +31,7 @@ describe Daikon::Client, "setup" do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "sets redis to listen on the given port" do
|
34
|
-
Redis.should have_received(:new).with(:port => "6379")
|
34
|
+
Redis.should have_received(:new).with(:host => "127.0.0.1", :port => "6379")
|
35
35
|
subject.should have_received(:redis=).with(redis)
|
36
36
|
end
|
37
37
|
end
|
data/spec/configuration_spec.rb
CHANGED
@@ -2,9 +2,10 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Daikon::Configuration do
|
4
4
|
subject { Daikon::Configuration.new(flags) }
|
5
|
-
let(:flags) { %w[-p 9001 -k deadbeef -s localhost:9337 -f 1337] }
|
5
|
+
let(:flags) { %w[-h 4.2.2.2 -p 9001 -k deadbeef -s localhost:9337 -f 1337] }
|
6
6
|
|
7
7
|
it "parses the given flags" do
|
8
|
+
subject.redis_host.should == "4.2.2.2"
|
8
9
|
subject.redis_port.should == "9001"
|
9
10
|
subject.api_key.should == "deadbeef"
|
10
11
|
subject.field_id.should == "1337"
|
@@ -16,6 +17,7 @@ describe Daikon::Configuration do
|
|
16
17
|
subject { Daikon::Configuration.new(%w[-k 1234567890]) }
|
17
18
|
|
18
19
|
it "uses the default keys" do
|
20
|
+
subject.redis_host.should == "127.0.0.1"
|
19
21
|
subject.redis_port.should == "6379"
|
20
22
|
subject.api_key.should == "1234567890"
|
21
23
|
subject.field_id.should == "1"
|
data/spec/daemon_spec.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Daikon::Daemon do
|
4
|
+
%w[-v --version].each do |flag|
|
5
|
+
it "shows the daikon version with #{flag}" do
|
6
|
+
old_stdout = $stdout
|
7
|
+
$stdout = StringIO.new("")
|
8
|
+
Daikon::Daemon.start([flag])
|
9
|
+
$stdout.string.should include(Daikon::VERSION)
|
10
|
+
$stdout = old_stdout
|
11
|
+
end
|
12
|
+
end
|
13
|
+
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: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.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-29 00:00:00 -05:00
|
19
19
|
default_executable: daikon
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- lib/daikon/namespace_tools.rb
|
198
198
|
- spec/client_spec.rb
|
199
199
|
- spec/configuration_spec.rb
|
200
|
+
- spec/daemon_spec.rb
|
200
201
|
- spec/daikon_spec.rb
|
201
202
|
- spec/spec_helper.rb
|
202
203
|
has_rdoc: true
|
@@ -236,5 +237,6 @@ summary: daikon, a radishapp.com client
|
|
236
237
|
test_files:
|
237
238
|
- spec/client_spec.rb
|
238
239
|
- spec/configuration_spec.rb
|
240
|
+
- spec/daemon_spec.rb
|
239
241
|
- spec/daikon_spec.rb
|
240
242
|
- spec/spec_helper.rb
|