lita-libratoo 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/lib/lita/handlers/libratoo.rb +47 -16
- data/lita-libratoo.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 641821ba24a20cbbf66cb240ad8a2b820d4a5a39
|
4
|
+
data.tar.gz: f445a0003b17f61c080c7e14e6a7b896cfef9313
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9baa4cd5c0b0910c7e14f4ee6db2e4326300bfd32613c29156c0f501b69756ca0d6bd0a2a9efc02f33ee91367dd444d4f26d067d5a03dc0f111c04318ff234cb
|
7
|
+
data.tar.gz: f0029a05d3ab3a37d93390a82e2257fe6b02fead29b58fc2dce7514a53d92ae5ba7dc8e8a69ae00c6a0ee454b3f49ff3419bac96b60cce100987dfd0f51acf8d
|
@@ -19,12 +19,7 @@ module Lita
|
|
19
19
|
metrics = Librato::Metrics.metrics.map{|v| v["name"] }
|
20
20
|
response_text = metrics.grep(/#{arguments[1]}/i).join(', ')
|
21
21
|
response_text = "No results" if response_text.empty?
|
22
|
-
|
23
|
-
response.reply "Large result set. Sending you a direct message."
|
24
|
-
return response.reply_privately response_text
|
25
|
-
else
|
26
|
-
return response.reply response_text
|
27
|
-
end
|
22
|
+
return reply_or_whisper_long response, response_text
|
28
23
|
end
|
29
24
|
|
30
25
|
metric, options = arguments[0].to_sym, arguments[1..-1]
|
@@ -45,12 +40,39 @@ module Lita
|
|
45
40
|
response_text = results.map{|k,v| "#{k}: #{v.join ', '}" }.join "\n"
|
46
41
|
end
|
47
42
|
|
48
|
-
|
49
|
-
|
50
|
-
|
43
|
+
reply_or_whisper_long response, response_text
|
44
|
+
rescue Exception => e
|
45
|
+
reply_or_whisper_long response, e.message
|
46
|
+
end
|
47
|
+
|
48
|
+
route(/^librato sum\s(.+)/, :librato_sum, command: true, help: {
|
49
|
+
"librato sum [metric] [options]" =>
|
50
|
+
"example: 'lita librato sum payments_controller.stripe.success start_time: 2016-03-11-02:00'"
|
51
|
+
})
|
52
|
+
|
53
|
+
def librato_sum(response)
|
54
|
+
Librato::Metrics.authenticate config.email, config.api_key
|
55
|
+
|
56
|
+
arguments = response.matches[0][0].delete(':').split
|
57
|
+
|
58
|
+
metric, options = arguments[0].to_sym, arguments[1..-1]
|
59
|
+
options = symbolize_keys Hash[*options]
|
60
|
+
options = { resolution: 1 }.merge options
|
61
|
+
if options.key?(:start_time) && !options[:start_time].is_a?(Numeric)
|
62
|
+
options[:start_time] = DateTime.parse(options[:start_time]).to_time.to_i
|
63
|
+
end
|
64
|
+
|
65
|
+
results = Librato::Metrics.get_composite %Q[sum(s("#{metric}", "*", {function: "sum"}))], options
|
66
|
+
|
67
|
+
if results["measurements"].any?
|
68
|
+
response_text = results["measurements"][0]["series"].reduce(0){|c,e| c + e["value"] }
|
51
69
|
else
|
52
|
-
|
70
|
+
response_text = "No results"
|
53
71
|
end
|
72
|
+
|
73
|
+
reply_or_whisper_long response, response_text
|
74
|
+
rescue Exception => e
|
75
|
+
reply_or_whisper_long response, e.message
|
54
76
|
end
|
55
77
|
|
56
78
|
route(/^librato search\s(.+)/, :librato_search, command: true, help: {
|
@@ -65,12 +87,9 @@ module Lita
|
|
65
87
|
metrics = Librato::Metrics.metrics.map{|v| v["name"] }
|
66
88
|
response_text = metrics.grep(/#{search}/i).join(', ')
|
67
89
|
response_text = "No results" if response_text.empty?
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
else
|
72
|
-
return response.reply response_text
|
73
|
-
end
|
90
|
+
reply_or_whisper_long response, response_text
|
91
|
+
rescue Exception => e
|
92
|
+
reply_or_whisper_long response, e.message
|
74
93
|
end
|
75
94
|
|
76
95
|
def symbolize_keys(hash)
|
@@ -78,6 +97,18 @@ module Lita
|
|
78
97
|
end
|
79
98
|
|
80
99
|
Lita.register_handler(self)
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
def reply_or_whisper_long(response, response_text)
|
104
|
+
response_text = response_text.to_s
|
105
|
+
if response_text.length > 400 && !response.message.source.private_message
|
106
|
+
response.reply "Large result set. Sending you a direct message."
|
107
|
+
response.reply_privately response_text
|
108
|
+
else
|
109
|
+
response.reply response_text
|
110
|
+
end
|
111
|
+
end
|
81
112
|
end
|
82
113
|
end
|
83
114
|
end
|
data/lita-libratoo.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-libratoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Boehs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|