exprc 0.0.5 → 0.0.6
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/bin/exprc +46 -68
- data/exprc.gemspec +1 -1
- metadata +3 -2
data/bin/exprc
CHANGED
@@ -23,7 +23,7 @@ ARGV.options do |o|
|
|
23
23
|
divisor = nil
|
24
24
|
percentile = nil
|
25
25
|
|
26
|
-
o.banner = "usage: exprc list|show|test|create|destroy|version [options]"
|
26
|
+
o.banner = "usage: exprc list|show|explain|test|create|destroy|version [options]"
|
27
27
|
o.on("-n", "--name n", String, "name of metric") { |n| name = n }
|
28
28
|
o.on("-t", "--type t", String, "type of metric") { |t| type = t }
|
29
29
|
o.on("-w", "--window w", Integer, "window of metric in seconds") { |w| window = w }
|
@@ -40,28 +40,34 @@ ARGV.options do |o|
|
|
40
40
|
action = ARGV.shift
|
41
41
|
exprd_api_url = ENV["EXPRD_API_URL"]
|
42
42
|
|
43
|
+
params = {
|
44
|
+
"type" => type,
|
45
|
+
"window" => window,
|
46
|
+
"delay" => delay,
|
47
|
+
"predicate" => (predicate && JSON.parse(predicate)),
|
48
|
+
"predicate2" => (predicate2 && JSON.parse(predicate2)),
|
49
|
+
"value" => value,
|
50
|
+
"key" => key,
|
51
|
+
"divisor" => divisor,
|
52
|
+
"percentile" => percentile,
|
53
|
+
"frequency" => frequency}
|
54
|
+
|
43
55
|
abort("! error: an action is required (e.g list).\n\n#{o}") if (!action || action.empty?)
|
44
|
-
abort("! error: unrecognized action #{action}.") if !%w{list show test create update destroy version}.include?(action)
|
56
|
+
abort("! error: unrecognized action #{action}.") if !%w{list show explain test create update destroy version}.include?(action)
|
45
57
|
abort("! error: missing EXPRD_API_URL.\n\n#{o}") if (!exprd_api_url || exprd_api_url.empty?)
|
46
58
|
abort("! error: unrecognized args: #{ARGV.join(" ")}.") if !ARGV.empty?
|
47
59
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
60
|
+
begin
|
61
|
+
case action
|
62
|
+
when "version"
|
63
|
+
puts("0.0.6")
|
64
|
+
when "list"
|
53
65
|
names = JSON.parse(RestClient.get("#{exprd_api_url}/metrics"))
|
54
66
|
names.each do |name|
|
55
67
|
puts("- #{name}")
|
56
68
|
end
|
57
|
-
|
58
|
-
|
59
|
-
message = e.is_a?(RestClient::Exception) ? JSON.parse(e.response.body)["message"] : e.message
|
60
|
-
abort("! error: #{message}")
|
61
|
-
end
|
62
|
-
when "show"
|
63
|
-
abort("! error: missing --name.\n\n#{o}") if (!name || name.empty?)
|
64
|
-
begin
|
69
|
+
when "show"
|
70
|
+
abort("! error: missing --name.\n\n#{o}") if (!name || name.empty?)
|
65
71
|
info = JSON.parse(RestClient.get("#{exprd_api_url}/metrics/#{name}"))
|
66
72
|
puts("= name: #{name}")
|
67
73
|
puts("= type: #{info["type"]}")
|
@@ -74,68 +80,40 @@ ARGV.options do |o|
|
|
74
80
|
puts("= divisor: #{info["divisor"]}") if info["divisor"]
|
75
81
|
puts("= percentile: #{info["percentile"]}") if info["percentile"]
|
76
82
|
puts("= frequency: #{info["frequency"]}")
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
"value" => value,
|
93
|
-
"key" => key,
|
94
|
-
"divisor" => divisor,
|
95
|
-
"percentile" => percentile,
|
96
|
-
"frequency" => frequency}
|
83
|
+
when "explain"
|
84
|
+
abort("! error: missing --name.\n\n#{o}") if (!name || name.empty?)
|
85
|
+
|
86
|
+
if type
|
87
|
+
#we are sending the params
|
88
|
+
info = JSON.parse(RestClient.put("#{exprd_api_url}/metrics/#{name}/tests", JSON.dump(params)))
|
89
|
+
else
|
90
|
+
#we are getting a known metric
|
91
|
+
info = JSON.parse(RestClient.get("#{exprd_api_url}/metrics/#{name}"))
|
92
|
+
end
|
93
|
+
puts("= name: #{name}")
|
94
|
+
puts("= compiled:\n#{info["compiled"]}")
|
95
|
+
when "test"
|
96
|
+
abort("! error: missing --name.\n\n#{o}") if (!name || name.empty?)
|
97
|
+
$stdout.print("* testing metric #{name}...")
|
97
98
|
results = JSON.parse(RestClient.put("#{exprd_api_url}/metrics/#{name}/tests", JSON.dump(params)))
|
98
99
|
puts(" done")
|
99
100
|
puts("= name: #{name}")
|
100
101
|
puts("= value: #{results["value"]}")
|
101
102
|
puts("= time: #{Time.at(results["time"])}")
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
abort("! error: #{message}")
|
106
|
-
end
|
107
|
-
when "create"
|
108
|
-
abort("! error: missing --name.\n\n#{o}") if (!name || name.empty?)
|
109
|
-
$stdout.print("* creating metric #{name}...")
|
110
|
-
begin
|
111
|
-
params = {
|
112
|
-
"type" => type,
|
113
|
-
"window" => window,
|
114
|
-
"delay" => delay,
|
115
|
-
"predicate" => (predicate && JSON.parse(predicate)),
|
116
|
-
"predicate2" => (predicate2 && JSON.parse(predicate2)),
|
117
|
-
"value" => value,
|
118
|
-
"key" => key,
|
119
|
-
"divisor" => divisor,
|
120
|
-
"percentile" => percentile,
|
121
|
-
"frequency" => frequency}
|
103
|
+
when "create"
|
104
|
+
abort("! error: missing --name.\n\n#{o}") if (!name || name.empty?)
|
105
|
+
$stdout.print("* creating metric #{name}...")
|
122
106
|
RestClient.put("#{exprd_api_url}/metrics/#{name}", JSON.dump(params))
|
123
107
|
puts(" done")
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
abort("! error: #{message}")
|
128
|
-
end
|
129
|
-
when "destroy"
|
130
|
-
abort("! error: missing --name.\n\n#{o}") if (!name || name.empty?)
|
131
|
-
$stdout.print("* destroying metric #{name}...")
|
132
|
-
begin
|
108
|
+
when "destroy"
|
109
|
+
abort("! error: missing --name.\n\n#{o}") if (!name || name.empty?)
|
110
|
+
$stdout.print("* destroying metric #{name}...")
|
133
111
|
RestClient.delete("#{exprd_api_url}/metrics/#{name}")
|
134
112
|
puts(" done")
|
135
|
-
rescue => e
|
136
|
-
puts(" failed")
|
137
|
-
message = e.is_a?(RestClient::Exception) ? JSON.parse(e.response.body)["message"] : e.message
|
138
|
-
abort("! error: #{message}")
|
139
113
|
end
|
114
|
+
rescue => e
|
115
|
+
puts(" failed")
|
116
|
+
message = e.is_a?(RestClient::Exception) ? JSON.parse(e.response.body)["message"] : e.message
|
117
|
+
abort("! error: #{message}")
|
140
118
|
end
|
141
119
|
end
|
data/exprc.gemspec
CHANGED
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.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: CLI to exprd.
|
15
15
|
email:
|
@@ -50,3 +50,4 @@ signing_key:
|
|
50
50
|
specification_version: 3
|
51
51
|
summary: CLI to exprd.
|
52
52
|
test_files: []
|
53
|
+
has_rdoc:
|