lita-uptimerobot 0.1.0.pre.beta
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/lib/lita-uptimerobot.rb +12 -0
- data/lib/lita/handlers/uptimerobot.rb +56 -0
- data/lita-uptimerobot.gemspec +22 -0
- data/spec/lita/handlers/uptimerobot_spec.rb +9 -0
- data/spec/spec_helper.rb +6 -0
- metadata +127 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e50c5bd86b50f6703ade24053d6ece0923aa5a24
|
4
|
+
data.tar.gz: 12e03e547db45fc5c1b67e0a226a0ace3ceaa457
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6847e7dc40393096d4ec25283319967565a886d242daad3c0eda70a69cdf6c824e0d5c4c764a9cddf9a057d488975fc06b84e08858480941ac4ae5a4438a30ec
|
7
|
+
data.tar.gz: aebfeacbda0756e054fef8dc81ed57629bcdff4ba5f7c1fa38100d933cca30d3ec6df542b92f08b39f4d78b4a7382ff1f02b9f0e190f989a9e7bf9983b2e56d1
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2015 Sophicware
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# lita-uptimerobot [](http://badge.fury.io/rb/lita-uptimerobot)
|
2
|
+
|
3
|
+
**lita-uptimerobot** is a handler for [Lita](https://www.lita.io) that gives your bot commands for retrieving monitor statuses and uptime ratios from [uptimerobot.com](https://uptimerobot.com)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add lita-uptimerobot to your Lita instance's Gemfile:
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
gem "lita-uptimerobot"
|
11
|
+
```
|
12
|
+
|
13
|
+
## Configuration
|
14
|
+
|
15
|
+
### Required attributes
|
16
|
+
|
17
|
+
* `api_key` (String) – Your master API key from your uptimerobot.com dashboard.
|
18
|
+
|
19
|
+
### Example
|
20
|
+
|
21
|
+
``` ruby
|
22
|
+
Lita.configure do |config|
|
23
|
+
config.handlers.uptimerobot.api_key= ENV["UPTIME_API_KEY"]
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Commands are called in the with the `uptime` prefix what can be optionally with the `upt` abbreviation. There's no need to prefix the command with your bot name.
|
30
|
+
|
31
|
+
```shell
|
32
|
+
uptime mysite (displays uptime and status for a monitor that matches)
|
33
|
+
upt all (displays uptime and statuses for all configured monitors)
|
34
|
+
upt example.com 15d (displays status and uptime for example.com where uptime is averaged over 15 days)
|
35
|
+
```
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
[MIT](http://opensource.org/licenses/MIT)
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require "lita"
|
2
|
+
|
3
|
+
Lita.load_locales Dir[File.expand_path(
|
4
|
+
File.join("..", "..", "locales", "*.yml"), __FILE__
|
5
|
+
)]
|
6
|
+
|
7
|
+
require "lita/handlers/uptimerobot"
|
8
|
+
|
9
|
+
Lita::Handlers::Uptimerobot.template_root File.expand_path(
|
10
|
+
File.join("..", "..", "templates"),
|
11
|
+
__FILE__
|
12
|
+
)
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'json'
|
2
|
+
module Lita
|
3
|
+
module Handlers
|
4
|
+
class Uptimerobot < Handler
|
5
|
+
|
6
|
+
config :api_key, required: true
|
7
|
+
|
8
|
+
@status = {
|
9
|
+
'0' => 'paused',
|
10
|
+
'1' => 'not checked',
|
11
|
+
'2' => 'up',
|
12
|
+
'8' => 'seems down',
|
13
|
+
'9' => 'down',
|
14
|
+
}
|
15
|
+
|
16
|
+
def self.status(key)
|
17
|
+
@status[key]
|
18
|
+
end
|
19
|
+
|
20
|
+
route /^upt(?:ime)?(?:\s([a-z\.\-\d]+))?(?:\s(\d+)\s?d(?:ays)?)?$/i, :uptime, command: false, help: {
|
21
|
+
'uptime all' => 'get default uptime ratios and statuses for all monitors',
|
22
|
+
'uptime piwik' => 'get uptime for matching friendly name',
|
23
|
+
'uptime example.com' => 'get uptime for given URL'
|
24
|
+
}
|
25
|
+
|
26
|
+
def uptime(msg)
|
27
|
+
what = msg.matches.flatten.first
|
28
|
+
span = msg.matches.flatten[1]
|
29
|
+
r = ''
|
30
|
+
response = http.get("https://api.uptimerobot.com/getMonitors") do |req|
|
31
|
+
req.params['apiKey'] = config.api_key
|
32
|
+
req.params['format'] = "json"
|
33
|
+
req.params['noJsonCallback'] = "1"
|
34
|
+
|
35
|
+
req.params['search'] = what unless what.nil? or what == 'all'
|
36
|
+
req.params['customUptimeRatio'] = span unless span.nil?
|
37
|
+
end
|
38
|
+
result = JSON.parse(response.body)
|
39
|
+
max_ratio_width = "uptime %".length
|
40
|
+
max_url_width = 0
|
41
|
+
max_status_width = self.class.status("1").length
|
42
|
+
result['monitors']['monitor'].each do |monitor|
|
43
|
+
max_url_width = monitor['url'].length if monitor['url'].length > max_url_width
|
44
|
+
r << "#{monitor['alltimeuptimeratio'].center(max_ratio_width)}\t"
|
45
|
+
r << "#{self.class.status(monitor['status']).center(max_status_width)}\t"
|
46
|
+
r << "#{monitor['url']}\n"
|
47
|
+
end
|
48
|
+
header = ''
|
49
|
+
header << "Uptime %\t" << "Status".center(max_status_width) << "\t" << "URL".center(max_url_width) << "\n"
|
50
|
+
msg.reply header << r
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
Lita.register_handler(Uptimerobot)
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-uptimerobot"
|
3
|
+
spec.version = "0.1.0-beta"
|
4
|
+
spec.authors = ["Jurnell Cockhren"]
|
5
|
+
spec.email = ["jurnell@sophicware.com"]
|
6
|
+
spec.description = %q{Lita Handler for interacting with uptimerobot.com}
|
7
|
+
spec.summary = spec.description
|
8
|
+
spec.homepage = "https://github.com/sophicware/lita-uptimerobot"
|
9
|
+
spec.license = "MIT"
|
10
|
+
spec.metadata = { "lita_plugin_type" => "handler" }
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split($/)
|
13
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
|
16
|
+
spec.add_runtime_dependency "lita", "~> 4.2"
|
17
|
+
|
18
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
19
|
+
spec.add_development_dependency "rake", "~> 0"
|
20
|
+
spec.add_development_dependency "rack-test"
|
21
|
+
spec.add_development_dependency "rspec", ">= 3.0.0"
|
22
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::Uptimerobot, lita_handler: true do
|
4
|
+
it { is_expected.to route_command('uptime all').to(:uptime) }
|
5
|
+
it { is_expected.to route_command('upt example.com').to(:uptime) }
|
6
|
+
it { is_expected.to route_command('uptime 7 days').to(:uptime) }
|
7
|
+
it { is_expected.to route_command('uptime mysite 17 days').to(:uptime) }
|
8
|
+
it { is_expected.to route_command('upt mysite 17d').to(:uptime) }
|
9
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
require "lita-uptimerobot"
|
2
|
+
require "lita/rspec"
|
3
|
+
|
4
|
+
# A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
|
5
|
+
# was generated with Lita 4, the compatibility mode should be left disabled.
|
6
|
+
Lita.version_3_compatibility_mode = false
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-uptimerobot
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.pre.beta
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jurnell Cockhren
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lita
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rack-test
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.0.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.0.0
|
83
|
+
description: Lita Handler for interacting with uptimerobot.com
|
84
|
+
email:
|
85
|
+
- jurnell@sophicware.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- lib/lita-uptimerobot.rb
|
96
|
+
- lib/lita/handlers/uptimerobot.rb
|
97
|
+
- lita-uptimerobot.gemspec
|
98
|
+
- spec/lita/handlers/uptimerobot_spec.rb
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
homepage: https://github.com/sophicware/lita-uptimerobot
|
101
|
+
licenses:
|
102
|
+
- MIT
|
103
|
+
metadata:
|
104
|
+
lita_plugin_type: handler
|
105
|
+
post_install_message:
|
106
|
+
rdoc_options: []
|
107
|
+
require_paths:
|
108
|
+
- lib
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 1.3.1
|
119
|
+
requirements: []
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.4.5
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Lita Handler for interacting with uptimerobot.com
|
125
|
+
test_files:
|
126
|
+
- spec/lita/handlers/uptimerobot_spec.rb
|
127
|
+
- spec/spec_helper.rb
|