deputy 0.1.44 → 0.1.45

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/Readme.md CHANGED
@@ -19,4 +19,5 @@ Usage
19
19
 
20
20
  ### Report something
21
21
  deputy Cronjob.ran
22
- deputy Cronjob.users_found 123
22
+ deputy Cronjob.users_found 123
23
+ Cron: xxx 2>&1 ; deputy Cron.success $?
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.44
1
+ 0.1.45
data/bin/deputy CHANGED
@@ -4,6 +4,8 @@ require 'optparse'
4
4
  $LOAD_PATH << "#{File.dirname(__FILE__)}/../lib"
5
5
  require 'deputy'
6
6
 
7
+ options = {}
8
+
7
9
  OptionParser.new do |opts|
8
10
  opts.banner = <<BANNER
9
11
  Report to the sheriff
@@ -23,12 +25,15 @@ BANNER
23
25
  Deputy.run_plugins
24
26
  exit
25
27
  end
28
+ opts.on('--host x', 'Use this host, when reporting') do |host|
29
+ options[:host] = host
30
+ end
26
31
  end.parse!
27
-
32
+
28
33
  metric, value = ARGV[0..1]
29
34
  if metric.to_s.empty?
30
35
  puts "Usage instructions: deputy --help"
31
36
  exit
32
37
  end
33
38
 
34
- Deputy.send_report metric, (value || Deputy::DEFAULT_VALUE)
39
+ Deputy.send_report metric, (value || Deputy::DEFAULT_VALUE), options
data/deputy.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{deputy}
8
- s.version = "0.1.44"
8
+ s.version = "0.1.45"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2010-08-05}
12
+ s.date = %q{2010-09-06}
13
13
  s.default_executable = %q{deputy}
14
14
  s.email = %q{mirko@dawanda.com}
15
15
  s.executables = ["deputy"]
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.homepage = %q{http://github.com/dawanda/deputy}
27
27
  s.rdoc_options = ["--charset=UTF-8"]
28
28
  s.require_paths = ["lib"]
29
- s.rubygems_version = %q{1.3.6}
29
+ s.rubygems_version = %q{1.3.7}
30
30
  s.summary = %q{Report to the sheriff}
31
31
  s.test_files = [
32
32
  "spec/deputy_spec.rb",
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
37
37
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
38
38
  s.specification_version = 3
39
39
 
40
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
40
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
41
41
  s.add_runtime_dependency(%q<SystemTimer>, [">= 0"])
42
42
  else
43
43
  s.add_dependency(%q<SystemTimer>, [">= 0"])
data/lib/deputy.rb CHANGED
@@ -120,13 +120,16 @@ module Deputy
120
120
  raise e
121
121
  end
122
122
 
123
- def self.send_report(group, value)
123
+ def self.send_report(group, value, options = {})
124
124
  raise "separate #{group} with a ." unless group.split('.',2).size == 2
125
- get "/notify?group=#{CGI.escape group}&value=#{CGI.escape value.to_s}&hostname=#{Socket.gethostname}"
125
+ host = options[:host] || Socket.gethostname
126
+
127
+ get "/notify?group=#{CGI.escape group}&value=#{CGI.escape value.to_s}&hostname=#{host}"
126
128
  end
127
129
 
128
130
  def self.get(path, options = {})
129
131
  url = "#{sheriff_url}#{path}"
132
+ url = "http://#{url}" unless url =~ %r{://}
130
133
  options[:http_basic_authentication] = extract_auth_from_url!(url)
131
134
 
132
135
  Timeout.timeout(config['timeout']||10) do
data/spec/deputy_spec.rb CHANGED
@@ -148,9 +148,12 @@ describe Deputy do
148
148
  end
149
149
 
150
150
  describe :run_plugins do
151
+ before do
152
+ Deputy.stub!(:config).and_return "sheriff_url" => 'http://sheri.ff'
153
+ end
154
+
151
155
  it "executes all plugins" do
152
156
  $notify = 0
153
- Deputy.stub!(:sheriff_url).and_return 'http://sheri.ff'
154
157
  FakeWeb.register_uri(:get, "http://sheri.ff/plugins.rb", :body => klass('C', :code => '$notify=1'))
155
158
  FakeWeb.register_uri(:get, "http://sheri.ff/notify?group=Deputies.finished&value=OK&hostname=my_host", :body => 'OK')
156
159
  Deputy.run_plugins
@@ -169,17 +172,24 @@ describe Deputy do
169
172
  end
170
173
 
171
174
  describe :send_report do
175
+ before do
176
+ Deputy.stub!(:config).and_return "sheriff_url" => 'http://sheri.ff'
177
+ end
178
+
172
179
  it "sends a report" do
173
- Deputy.stub!(:sheriff_url).and_return 'http://sheri.ff'
174
180
  FakeWeb.register_uri(:get, "http://sheri.ff/notify?group=Xxx.yyy&value=123&hostname=my_host", :body => 'OK')
175
181
  Deputy.send_report('Xxx.yyy', '123').should == 'OK'
176
182
  end
177
183
 
178
184
  it "escapes metric names" do
179
- Deputy.stub!(:sheriff_url).and_return 'http://sheri.ff'
180
185
  FakeWeb.register_uri(:get, "http://sheri.ff/notify?group=Xxx.yy%3Fy&value=123&hostname=my_host", :body => 'OK')
181
186
  Deputy.send_report('Xxx.yy?y', '123').should == 'OK'
182
187
  end
188
+
189
+ it "overrides host, if specified in options" do
190
+ FakeWeb.register_uri(:get, "http://sheri.ff/notify?group=Xxx.yy%3Fy&value=123&hostname=general", :body => 'OK')
191
+ Deputy.send_report('Xxx.yy?y', '123', {:host => 'general'}).should == 'OK'
192
+ end
183
193
  end
184
194
 
185
195
  describe :extract_auth_from_url! do
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deputy
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 65
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 44
9
- version: 0.1.44
9
+ - 45
10
+ version: 0.1.45
10
11
  platform: ruby
11
12
  authors:
12
13
  - Michael Grosser
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-08-05 00:00:00 +02:00
18
+ date: 2010-09-06 00:00:00 +02:00
18
19
  default_executable: deputy
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: SystemTimer
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  version: "0"
@@ -56,23 +59,27 @@ rdoc_options:
56
59
  require_paths:
57
60
  - lib
58
61
  required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
59
63
  requirements:
60
64
  - - ">="
61
65
  - !ruby/object:Gem::Version
66
+ hash: 3
62
67
  segments:
63
68
  - 0
64
69
  version: "0"
65
70
  required_rubygems_version: !ruby/object:Gem::Requirement
71
+ none: false
66
72
  requirements:
67
73
  - - ">="
68
74
  - !ruby/object:Gem::Version
75
+ hash: 3
69
76
  segments:
70
77
  - 0
71
78
  version: "0"
72
79
  requirements: []
73
80
 
74
81
  rubyforge_project:
75
- rubygems_version: 1.3.6
82
+ rubygems_version: 1.3.7
76
83
  signing_key:
77
84
  specification_version: 3
78
85
  summary: Report to the sheriff