deputy 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/Rakefile +15 -0
  2. data/Readme.md +11 -0
  3. data/VERSION +1 -0
  4. data/bin/deputy +27 -0
  5. data/lib/deputy.rb +25 -0
  6. metadata +66 -0
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ begin
2
+ require 'jeweler'
3
+ project_name = 'deputy'
4
+ Jeweler::Tasks.new do |gem|
5
+ gem.name = project_name
6
+ gem.summary = "Report to the sheriff"
7
+ gem.email = "mirko@dawanda.com"
8
+ gem.homepage = "http://github.com/dawanda/#{project_name}"
9
+ gem.authors = ["Michael Grosser"]
10
+ end
11
+
12
+ Jeweler::GemcutterTasks.new
13
+ rescue LoadError
14
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler"
15
+ end
data/Readme.md ADDED
@@ -0,0 +1,11 @@
1
+ Work in progress do not use.
2
+
3
+ Use with [sheriff](http://github.com/dawanda/sheriff).
4
+
5
+ sudo gem install deputy
6
+
7
+ Put sheriff url into `~/.deputy.yml`
8
+ sheriff_url: http://sheriff.mydomain.com
9
+
10
+ - report something: `deputy Cronjob.ran 1`
11
+ - TODO add plugins via sheriff && install deputy cron with deputy --install-cron
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/deputy ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'optparse'
4
+ $LOAD_PATH << "#{File.dirname(__FILE__)}/../lib"
5
+ require 'deputy'
6
+
7
+ options = {}
8
+ OptionParser.new do |opts|
9
+ opts.banner = <<BANNER
10
+ Report to the sheriff
11
+
12
+ Usage:
13
+ deputy /System.metric/value
14
+
15
+ Options:
16
+ BANNER
17
+ opts.on("-h", "--help","Show this.") { puts opts; exit }
18
+ opts.on('-v', '--version','Show Version'){ puts Deputy::VERSION; exit}
19
+ end.parse!
20
+
21
+ metric, value = ARGV[0..1]
22
+ if metric.to_s.empty?
23
+ puts "Usage instructions: deputy --help"
24
+ exit
25
+ end
26
+
27
+ Deputy.send_report metric, value
data/lib/deputy.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'yaml'
2
+ require 'open-uri'
3
+
4
+ module Deputy
5
+ VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
6
+
7
+ def self.send_report(metric, value)
8
+ url = "#{sheriff_url}/report/#{metric}/#{value}"
9
+ open(url).read
10
+ rescue => e
11
+ e.message << url
12
+ raise e
13
+ end
14
+
15
+ def self.sheriff_url
16
+ config['sheriff_url'].sub(%r{/$},'')
17
+ end
18
+
19
+ def self.config
20
+ file = File.expand_path('~/.deputy.yml')
21
+ YAML.load(File.read(file))
22
+ rescue => e
23
+ e.message << " -- do you have a #{file} ?"
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: deputy
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Michael Grosser
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-06-01 00:00:00 +02:00
18
+ default_executable: deputy
19
+ dependencies: []
20
+
21
+ description:
22
+ email: mirko@dawanda.com
23
+ executables:
24
+ - deputy
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - Rakefile
31
+ - Readme.md
32
+ - VERSION
33
+ - bin/deputy
34
+ - lib/deputy.rb
35
+ has_rdoc: true
36
+ homepage: http://github.com/dawanda/deputy
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options:
41
+ - --charset=UTF-8
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ segments:
49
+ - 0
50
+ version: "0"
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ requirements: []
59
+
60
+ rubyforge_project:
61
+ rubygems_version: 1.3.6
62
+ signing_key:
63
+ specification_version: 3
64
+ summary: Report to the sheriff
65
+ test_files: []
66
+