exprc 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "rest-client", "1.6.7"
4
- gem "json", "1.6.6"
3
+ gemspec
@@ -1,8 +1,16 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ exprc (0.0.9)
5
+ json (= 1.6.6)
6
+ rest-client (= 1.6.7)
7
+
1
8
  GEM
2
9
  remote: http://rubygems.org/
3
10
  specs:
4
11
  json (1.6.6)
5
- mime-types (1.18)
12
+ mime-types (1.19)
13
+ rake (0.9.2.2)
6
14
  rest-client (1.6.7)
7
15
  mime-types (>= 1.16)
8
16
 
@@ -10,5 +18,5 @@ PLATFORMS
10
18
  ruby
11
19
 
12
20
  DEPENDENCIES
13
- json (= 1.6.6)
14
- rest-client (= 1.6.7)
21
+ exprc!
22
+ rake
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
data/Readme.md CHANGED
@@ -1,3 +1,16 @@
1
1
  ## exprc
2
2
 
3
3
  Command line client to [exprd](https://github.com/heroku/exprd).
4
+
5
+ ``` bash
6
+ API_KEY=`heroku sudo config:get API_PASSWORD -a exprd-core-production`
7
+
8
+ export EXPRD_API_URL=https://:$API_KEY@exprd-core-production.herokuapp.com
9
+
10
+ bin/exprc create --name api.production.jobs.queue-count.last \
11
+ --type last \
12
+ --window 60 \
13
+ --predicate '["?", "background_job_queue_check"]' \
14
+ --value count
15
+ * creating metric api.production.jobs.queue-count.last... done
16
+ ```
data/bin/exprc CHANGED
@@ -8,6 +8,22 @@ require "optparse"
8
8
  require "uri"
9
9
  require "rest-client"
10
10
  require "json"
11
+ require "exprc"
12
+
13
+ def dump(name, info)
14
+ print("exprc create ")
15
+ print("--name '#{name}' ")
16
+ print("--type '#{info["type"]}' ")
17
+ print("--window '#{info["window"]}' ")
18
+ print("--predicate '#{info["predicate"]}' ") if info["predicate"]
19
+ print("--predicate2 '#{info["predicate2"]}' ") if info["predicate2"]
20
+ print("--value '#{info["value"]}' ") if info["value"]
21
+ print("--key '#{info["key"]}' ") if info["key"]
22
+ print("--divisor '#{info["divisor"]}' ") if info["divisor"]
23
+ print("--percentile '#{info["percentile"]}' ") if info["percentile"]
24
+ print("--frequency: '#{info["frequency"]}' ")
25
+ print("\n")
26
+ end
11
27
 
12
28
  ARGV.options do |o|
13
29
  action = nil
@@ -22,7 +38,7 @@ ARGV.options do |o|
22
38
  percentile = nil
23
39
  frequency = nil
24
40
 
25
- o.banner = "usage: exprc list|show|explain|test|create|destroy|version [options]"
41
+ o.banner = "usage: exprc list|show|dump|dumpall|explain|test|create|destroy|version [options]"
26
42
  o.on("-n", "--name n", String, "name of metric") { |n| name = n }
27
43
  o.on("-t", "--type t", String, "type of metric") { |t| type = t }
28
44
  o.on("-w", "--window w", Integer, "window of metric in seconds") { |w| window = w }
@@ -37,6 +53,7 @@ ARGV.options do |o|
37
53
  o.parse!
38
54
  action = ARGV.shift
39
55
  exprd_api_url = ENV["EXPRD_API_URL"]
56
+ exprc_version = Exprc::VERSION
40
57
 
41
58
  params = {
42
59
  "type" => type,
@@ -50,7 +67,7 @@ ARGV.options do |o|
50
67
  "frequency" => frequency}
51
68
 
52
69
  abort("! error: an action is required (e.g list).\n\n#{o}") if (!action || action.empty?)
53
- abort("! error: unrecognized action #{action}.") if !%w{list show explain test create update destroy version}.include?(action)
70
+ abort("! error: unrecognized action #{action}.") if !%w{list show dump dumpall explain test create update destroy version}.include?(action)
54
71
  abort("! error: missing EXPRD_API_URL.\n\n#{o}") if (!exprd_api_url || exprd_api_url.empty?)
55
72
  abort("! error: --dealy is no longer required and should be omitted.") if (ARGV.include?("-d") || ARGV.include?("--delay"))
56
73
  abort("! error: unrecognized args: #{ARGV.join(" ")}.") if !ARGV.empty?
@@ -58,15 +75,15 @@ ARGV.options do |o|
58
75
  begin
59
76
  case action
60
77
  when "version"
61
- puts("0.0.8")
78
+ puts(exprc_version)
62
79
  when "list"
63
- names = JSON.parse(RestClient.get("#{exprd_api_url}/metrics"))
80
+ names = JSON.parse(RestClient.get("#{exprd_api_url}/metrics", :exprc_version => exprc_version))
64
81
  names.each do |name|
65
82
  puts("- #{name}")
66
83
  end
67
84
  when "show"
68
85
  abort("! error: missing --name.\n\n#{o}") if (!name || name.empty?)
69
- info = JSON.parse(RestClient.get("#{exprd_api_url}/metrics/#{name}"))
86
+ info = JSON.parse(RestClient.get("#{exprd_api_url}/metrics/#{name}", :exprc_version => exprc_version))
70
87
  puts("= name: #{name}")
71
88
  puts("= type: #{info["type"]}")
72
89
  puts("= window: #{info["window"]}")
@@ -77,22 +94,32 @@ ARGV.options do |o|
77
94
  puts("= divisor: #{info["divisor"]}") if info["divisor"]
78
95
  puts("= percentile: #{info["percentile"]}") if info["percentile"]
79
96
  puts("= frequency: #{info["frequency"]}")
97
+ when "dumpall"
98
+ names = JSON.parse(RestClient.get("#{exprd_api_url}/metrics", :exprc_version => exprc_version))
99
+ names.each do |name|
100
+ info = JSON.parse(RestClient.get("#{exprd_api_url}/metrics/#{name}", :exprc_version => exprc_version))
101
+ dump(name, info)
102
+ end
103
+ when "dump"
104
+ abort("! error: missing --name.\n\n#{o}") if (!name || name.empty?)
105
+ info = JSON.parse(RestClient.get("#{exprd_api_url}/metrics/#{name}", :exprc_version => exprc_version))
106
+ dump(name, info)
80
107
  when "explain"
81
108
  abort("! error: missing --name.\n\n#{o}") if (!name || name.empty?)
82
109
 
83
110
  if type
84
111
  # we are sending the params
85
- info = JSON.parse(RestClient.put("#{exprd_api_url}/metrics/#{name}/tests", JSON.dump(params)))
112
+ info = JSON.parse(RestClient.put("#{exprd_api_url}/metrics/#{name}/tests", JSON.dump(params), :exprc_version => exprc_version))
86
113
  else
87
114
  # we are getting a known metric
88
- info = JSON.parse(RestClient.get("#{exprd_api_url}/metrics/#{name}"))
115
+ info = JSON.parse(RestClient.get("#{exprd_api_url}/metrics/#{name}", :exprc_version => exprc_version))
89
116
  end
90
117
  puts("= name: #{name}")
91
118
  puts("= compiled:\n#{info["compiled"]}")
92
119
  when "test"
93
120
  abort("! error: missing --name.\n\n#{o}") if (!name || name.empty?)
94
121
  $stdout.print("* testing metric #{name}...")
95
- results = JSON.parse(RestClient.put("#{exprd_api_url}/metrics/#{name}/tests", JSON.dump(params)))
122
+ results = JSON.parse(RestClient.put("#{exprd_api_url}/metrics/#{name}/tests", JSON.dump(params), :exprc_version => exprc_version))
96
123
  puts(" done")
97
124
  puts("= name: #{name}")
98
125
  puts("= value: #{results["value"]}")
@@ -100,12 +127,12 @@ ARGV.options do |o|
100
127
  when "create"
101
128
  abort("! error: missing --name.\n\n#{o}") if (!name || name.empty?)
102
129
  $stdout.print("* creating metric #{name}...")
103
- RestClient.put("#{exprd_api_url}/metrics/#{name}", JSON.dump(params))
130
+ RestClient.put("#{exprd_api_url}/metrics/#{name}", JSON.dump(params), :exprc_version => exprc_version)
104
131
  puts(" done")
105
132
  when "destroy"
106
133
  abort("! error: missing --name.\n\n#{o}") if (!name || name.empty?)
107
134
  $stdout.print("* destroying metric #{name}...")
108
- RestClient.delete("#{exprd_api_url}/metrics/#{name}")
135
+ RestClient.delete("#{exprd_api_url}/metrics/#{name}", :exprc_version => exprc_version)
109
136
  puts(" done")
110
137
  end
111
138
  rescue => e
@@ -1,3 +1,5 @@
1
+ require File.expand_path("../lib/exprc/version", __FILE__)
2
+
1
3
  Gem::Specification.new do |gem|
2
4
  gem.authors = ["Mark McGranaghan"]
3
5
  gem.email = ["mark@heroku.com"]
@@ -9,5 +11,8 @@ Gem::Specification.new do |gem|
9
11
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
10
12
  gem.name = "exprc"
11
13
  gem.require_paths = ["lib"]
12
- gem.version = "0.0.8"
14
+ gem.version = Exprc::VERSION
15
+ gem.add_dependency("json", "1.6.6")
16
+ gem.add_dependency("rest-client", "1.6.7")
17
+ gem.add_development_dependency("rake")
13
18
  end
@@ -0,0 +1 @@
1
+ require "exprc/version"
@@ -0,0 +1,3 @@
1
+ module Exprc
2
+ VERSION='0.0.9'
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exprc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,41 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-02 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-10-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: &70259532955900 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - =
20
+ - !ruby/object:Gem::Version
21
+ version: 1.6.6
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70259532955900
25
+ - !ruby/object:Gem::Dependency
26
+ name: rest-client
27
+ requirement: &70259532954440 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - =
31
+ - !ruby/object:Gem::Version
32
+ version: 1.6.7
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70259532954440
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70259532952280 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70259532952280
14
47
  description: CLI to exprd.
15
48
  email:
16
49
  - mark@heroku.com
@@ -22,9 +55,12 @@ files:
22
55
  - .gitignore
23
56
  - Gemfile
24
57
  - Gemfile.lock
58
+ - Rakefile
25
59
  - Readme.md
26
60
  - bin/exprc
27
61
  - exprc.gemspec
62
+ - lib/exprc.rb
63
+ - lib/exprc/version.rb
28
64
  homepage: https://github.com/heroku/exprc
29
65
  licenses: []
30
66
  post_install_message:
@@ -37,17 +73,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
37
73
  - - ! '>='
38
74
  - !ruby/object:Gem::Version
39
75
  version: '0'
76
+ segments:
77
+ - 0
78
+ hash: 2485921414130932160
40
79
  required_rubygems_version: !ruby/object:Gem::Requirement
41
80
  none: false
42
81
  requirements:
43
82
  - - ! '>='
44
83
  - !ruby/object:Gem::Version
45
84
  version: '0'
85
+ segments:
86
+ - 0
87
+ hash: 2485921414130932160
46
88
  requirements: []
47
89
  rubyforge_project:
48
- rubygems_version: 1.8.21
90
+ rubygems_version: 1.8.10
49
91
  signing_key:
50
92
  specification_version: 3
51
93
  summary: CLI to exprd.
52
94
  test_files: []
53
- has_rdoc: