lita-github-status 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6ec6fc5b4a6825efd6738d5be5ff30795b6d33e2
4
+ data.tar.gz: ce9b485cbab2c322a720af0f66fe92a49742be1a
5
+ SHA512:
6
+ metadata.gz: 4dc7dab89353e5d4f107ee1bd933bcd7aaae99e5384b9b6149fa99c06b1a79daa17d7508b0ae0e1c2234b8e38aa37f8e34b3d3a72379d3233b976c5b9db0fab1
7
+ data.tar.gz: 65b7a9318a91104abd1ce9726252713e737979f30218fa26081ab5172855b226585ebad7582b4cf805483fdab1d1f1e127855b787e28485fc90076edff4dcba6
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache: bundler
4
+
5
+ services:
6
+ - redis-server
7
+
8
+ rvm:
9
+ - 2.0
10
+ - 2.2
11
+
12
+ before_install:
13
+ - gem update --system
14
+
15
+ script: bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,14 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
5
+
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+
10
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
11
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
12
+
13
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
14
+
@@ -0,0 +1,31 @@
1
+ # lita-github-status
2
+
3
+ [![Build Status](https://travis-ci.org/miketheman/lita-github-status.svg?branch=master)](https://travis-ci.org/miketheman/lita-github-status)
4
+ [![Coverage Status](https://coveralls.io/repos/miketheman/lita-github-status/badge.svg)](https://coveralls.io/r/miketheman/lita-github-status)
5
+
6
+ A [Lita](http://lita.io) handler to display current GitHub Status.
7
+
8
+ ## Installation
9
+
10
+ Add `lita-github-status` to your Lita instance's `Gemfile`:
11
+
12
+ ``` ruby
13
+ gem 'lita-github-status'
14
+ ```
15
+
16
+ ## Configuration
17
+
18
+ None
19
+
20
+ ## Usage
21
+
22
+ Ask the bot how GitHub is doing:
23
+
24
+ Lita github status
25
+ Status: good (300 seconds ago)
26
+
27
+ See `Lita: help github` for all commands.
28
+
29
+ ## Prior Art
30
+
31
+ Pretty much a direct port of Hubot's [GitHub Status plugin](https://github.com/github/hubot-scripts/blob/master/src/scripts/github-status.coffee).
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -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/github_status'
8
+
9
+ Lita::Handlers::GithubStatus.template_root File.expand_path(
10
+ File.join('..', '..', 'templates'),
11
+ __FILE__
12
+ )
@@ -0,0 +1,43 @@
1
+ module Lita
2
+ module Handlers
3
+ class GithubStatus < Handler
4
+ route('github status', :status, command: true)
5
+ route('github status last', :status_last_message, command: true)
6
+ route('github status messages', :status_messages, command: true)
7
+
8
+ BASE_URL = 'https://status.github.com/api'
9
+
10
+ def status(response)
11
+ data = MultiJson.load(http.get(BASE_URL + '/status.json').body)
12
+
13
+ now = Time.now
14
+ updated = Time.parse data['last_updated']
15
+ seconds_ago = (now - updated).round
16
+
17
+ response.reply "Status: #{data['status']} (#{seconds_ago} seconds ago)"
18
+ end
19
+
20
+ def status_last_message(response)
21
+ data = MultiJson.load(http.get(BASE_URL + '/last-message.json').body)
22
+
23
+ response.reply "Status: #{data['status']}\n" \
24
+ "Message: #{data['body']}\n" \
25
+ "Time: #{Time.parse data['created_on']}"
26
+ end
27
+
28
+ def status_messages(response)
29
+ data = MultiJson.load(http.get(BASE_URL + '/messages.json').body)
30
+
31
+ replies = data.map do |message|
32
+ "[#{message['status']}] #{message['body']} (#{Time.parse message['created_on']})"
33
+ end
34
+
35
+ replies.each do |reply|
36
+ response.reply reply
37
+ end
38
+ end
39
+ end
40
+
41
+ Lita.register_handler(GithubStatus)
42
+ end
43
+ end
@@ -0,0 +1,26 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = 'lita-github-status'
3
+ spec.version = '0.1.0'
4
+ spec.authors = ['Mike Fiedler']
5
+ spec.email = ['miketheman@gmail.com']
6
+ spec.description = 'Ask your bot how GitHub is doing'
7
+ spec.summary = 'Lita Handler to query GitHub status API'
8
+ spec.homepage = 'https://github.com/miketheman/lita-github-status'
9
+ spec.license = 'WTFPL'
10
+ spec.metadata = { 'lita_plugin_type' => 'handler' }
11
+
12
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ['lib']
16
+
17
+ spec.add_runtime_dependency 'lita', '>= 4.3'
18
+
19
+ spec.add_development_dependency 'bundler', '~> 1.3'
20
+ spec.add_development_dependency 'pry-byebug'
21
+ spec.add_development_dependency 'rake'
22
+ spec.add_development_dependency 'rack-test'
23
+ spec.add_development_dependency 'rspec', '>= 3.0.0'
24
+ spec.add_development_dependency 'simplecov'
25
+ spec.add_development_dependency 'coveralls'
26
+ end
@@ -0,0 +1,4 @@
1
+ en:
2
+ lita:
3
+ handlers:
4
+ github_status:
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+ describe Lita::Handlers::GithubStatus, lita_handler: true do
4
+ it 'routes commands correctly' do
5
+ expect(subject).to route_command('github status').to :status
6
+ expect(subject).to route_command('github status last').to :status_last_message
7
+ expect(subject).to route_command('github status messages').to :status_messages
8
+ end
9
+
10
+ describe '#status' do
11
+ let(:status) { %({"status":"good","last_updated":"2015-05-06T12:32:08Z"}) }
12
+
13
+ before do
14
+ allow_any_instance_of(Faraday::Connection).to receive(:get).with(
15
+ 'https://status.github.com/api/status.json'
16
+ ).and_return(double('Faraday::Response', status: 200, body: status))
17
+ end
18
+
19
+ it 'retrieves the status' do
20
+ send_command('github status')
21
+
22
+ expect(replies.last).to include('Status: good')
23
+ expect(replies.last).to include('seconds ago')
24
+ end
25
+ end
26
+
27
+ describe '#status_last_message' do
28
+ let(:last_message) do
29
+ %({"status":"good",
30
+ "body":"Everything operating normally.",
31
+ "created_on":"2015-05-06T12:20:14Z"})
32
+ end
33
+
34
+ before do
35
+ allow_any_instance_of(Faraday::Connection).to receive(:get).with(
36
+ 'https://status.github.com/api/last-message.json'
37
+ ).and_return(double('Faraday::Response', status: 200, body: last_message))
38
+ end
39
+
40
+ it 'retrieves the last status message' do
41
+ send_command('github status last')
42
+
43
+ expect(replies.last).to include('Status: good')
44
+ expect(replies.last).to include('Message: Everything operating normally.')
45
+ expect(replies.last).to include('Time: 2015-05-06 12:20:14 UTC')
46
+ end
47
+ end
48
+
49
+ describe '#status_messages' do
50
+ let(:status_messages) do
51
+ %([
52
+ {"status":"good","body":"Everything operating normally.",
53
+ "created_on":"2015-05-06T12:20:14Z"},
54
+ {"status":"minor","body":"We've finished emergency maintenance and are monitoring closely.",
55
+ "created_on":"2015-05-06T11:54:37Z"},
56
+ {"status":"major","body":"We're doing emergency maintenance to recover the site.",
57
+ "created_on":"2015-05-06T11:40:07Z"},
58
+ {"status":"minor","body":"We're seeing high error rates on github.com and are investigating.",
59
+ "created_on":"2015-05-06T11:32:14Z"}
60
+ ])
61
+ end
62
+
63
+ before do
64
+ allow_any_instance_of(Faraday::Connection).to receive(:get).with(
65
+ 'https://status.github.com/api/messages.json'
66
+ ).and_return(double('Faraday::Response', status: 200, body: status_messages))
67
+ end
68
+
69
+ it 'retrieves the last status message' do
70
+ send_command('github status messages')
71
+
72
+ expect(replies.first).to include('[good] Everything operating normally.')
73
+ expect(replies.first).to include('(2015-05-06 12:20:14 UTC)')
74
+
75
+ expect(replies.last).to include("[minor] We're seeing high error rates")
76
+ expect(replies.last).to include('(2015-05-06 11:32:14 UTC)')
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,15 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
4
+ SimpleCov::Formatter::HTMLFormatter,
5
+ Coveralls::SimpleCov::Formatter
6
+ ]
7
+ SimpleCov.start { add_filter '/spec/' }
8
+
9
+ require 'lita-github-status'
10
+ require 'lita/rspec'
11
+
12
+ # A compatibility mode is provided for older plugins upgrading from Lita 3.
13
+ # Since this plugin was generated with Lita 4, the compatibility mode should be
14
+ # left disabled.
15
+ Lita.version_3_compatibility_mode = false
File without changes
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-github-status
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mike Fiedler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-06 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.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.3'
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: pry-byebug
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: rake
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: rack-test
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 3.0.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 3.0.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: coveralls
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Ask your bot how GitHub is doing
126
+ email:
127
+ - miketheman@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".travis.yml"
134
+ - Gemfile
135
+ - LICENSE
136
+ - README.md
137
+ - Rakefile
138
+ - lib/lita-github-status.rb
139
+ - lib/lita/handlers/github_status.rb
140
+ - lita-github-status.gemspec
141
+ - locales/en.yml
142
+ - spec/lita/handlers/github_status_spec.rb
143
+ - spec/spec_helper.rb
144
+ - templates/.gitkeep
145
+ homepage: https://github.com/miketheman/lita-github-status
146
+ licenses:
147
+ - WTFPL
148
+ metadata:
149
+ lita_plugin_type: handler
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ requirements: []
165
+ rubyforge_project:
166
+ rubygems_version: 2.4.5
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: Lita Handler to query GitHub status API
170
+ test_files:
171
+ - spec/lita/handlers/github_status_spec.rb
172
+ - spec/spec_helper.rb