lita-redmine 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +8 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/lib/lita/handlers/redmine.rb +61 -0
- data/lib/lita-redmine.rb +1 -0
- data/lita-redmine.gemspec +24 -0
- data/spec/lita/handlers/redmine_spec.rb +117 -0
- data/spec/spec_helper.rb +10 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bb77a076ca9b410759b8c57d2cc83f8762730406
|
4
|
+
data.tar.gz: 1a4bb1f8680a4585fd0e0b3906445a28ef8cc990
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8a5e130c20ea447bc75672e08abe1e4187e52308089f5eac5903574ee160765260b1828fb50d0d4db3f231bdcfe5eae480be72ef44ca2d85af608e717c764b95
|
7
|
+
data.tar.gz: 331f363996464a37c1d897d3109250b1c314c2c717ca875ce9a593ce5b0ebc50b5c85efd783ace0f31b766fd91372b866128155f608334bfe00938ecd1352811
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2013 Jonathan Amiez
|
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-redmine
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/josqu4red/lita-redmine.png?branch=master)](https://travis-ci.org/josqu4red/lita-redmine)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/josqu4red/lita-redmine/badge.png)](https://coveralls.io/r/josqu4red/lita-redmine)
|
5
|
+
|
6
|
+
**lita-gerrit** is a handler for [Lita](https://github.com/josqu4red/lita) that allows interaction with Redmine project management tool (or its fork, Chiliproject).
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add lita-redmine to your Lita instance's Gemfile:
|
11
|
+
|
12
|
+
``` ruby
|
13
|
+
gem "lita-redmine"
|
14
|
+
```
|
15
|
+
|
16
|
+
## Configuration
|
17
|
+
|
18
|
+
* `url` (String) - Redmine service URL
|
19
|
+
* `type` (Symbol) - Redmine variant used (`:redmine` or `:chiliproject`)
|
20
|
+
* `apikey` (String) - Key for REST API access
|
21
|
+
|
22
|
+
### Example
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
Lita.configure do |config|
|
26
|
+
config.handlers.redmine.url = "https://redmine.example.com"
|
27
|
+
config.handlers.redmine.type = :redmine
|
28
|
+
config.handlers.redmine.apikey = "0000000000000000000000000000000000000000"
|
29
|
+
end
|
30
|
+
```
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
```
|
34
|
+
lita > redmine 42
|
35
|
+
https://redmine.example.com/issues/21206 : Chef-ize powerdns instalation
|
36
|
+
```
|
37
|
+
## License
|
38
|
+
|
39
|
+
[MIT](http://opensource.org/licenses/MIT)
|
data/Rakefile
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require "lita"
|
2
|
+
|
3
|
+
module Lita
|
4
|
+
module Handlers
|
5
|
+
class Redmine < Handler
|
6
|
+
|
7
|
+
def self.default_config(config)
|
8
|
+
config.url = nil
|
9
|
+
config.type = :redmine # :chiliproject
|
10
|
+
config.apikey = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
route /redmine\s+(\d+)/, :issue, help: { "redmine <issue #>" => "Displays issue url and subject" }
|
14
|
+
|
15
|
+
def issue(response)
|
16
|
+
if Lita.config.handlers.redmine.url
|
17
|
+
redmine_url = Lita.config.handlers.redmine.url.chomp("/")
|
18
|
+
else
|
19
|
+
raise "Redmine URL must be defined ('config.handlers.redmine.url')"
|
20
|
+
end
|
21
|
+
|
22
|
+
if Lita.config.handlers.redmine.apikey
|
23
|
+
apikey = Lita.config.handlers.redmine.apikey
|
24
|
+
else
|
25
|
+
raise "Redmine API key must be defined ('config.handlers.redmine.apikey')"
|
26
|
+
end
|
27
|
+
|
28
|
+
case Lita.config.handlers.redmine.type
|
29
|
+
when :redmine
|
30
|
+
apikey_header = "X-Redmine-API-Key"
|
31
|
+
when :chiliproject
|
32
|
+
apikey_header = "X-ChiliProject-API-Key"
|
33
|
+
else
|
34
|
+
raise "Redmine type must be :redmine (default) or :chiliproject ('config.handlers.redmine.type')"
|
35
|
+
end
|
36
|
+
|
37
|
+
issue_id = response.matches.flatten.first
|
38
|
+
issue_url = URI.parse("#{redmine_url}/issues/#{issue_id}")
|
39
|
+
issue_json_url = "#{issue_url}.json"
|
40
|
+
|
41
|
+
http_resp = http.get(issue_json_url, {}, { apikey_header => apikey })
|
42
|
+
|
43
|
+
case http_resp.status
|
44
|
+
when 200
|
45
|
+
resp = MultiJson.load(http_resp.body)
|
46
|
+
message = "#{issue_url} : #{resp["issue"]["subject"]}"
|
47
|
+
when 404
|
48
|
+
message = "Issue ##{issue_id} does not exist"
|
49
|
+
else
|
50
|
+
raise "Failed to fetch #{issue_json_url} (#{http_resp.status})"
|
51
|
+
end
|
52
|
+
|
53
|
+
response.reply(message)
|
54
|
+
rescue Exception => e
|
55
|
+
response.reply("Error: #{e.message}")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
Lita.register_handler(Redmine)
|
60
|
+
end
|
61
|
+
end
|
data/lib/lita-redmine.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "lita/handlers/redmine"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-redmine"
|
3
|
+
spec.version = "0.0.1"
|
4
|
+
spec.authors = ["Jonathan Amiez"]
|
5
|
+
spec.email = ["jonathan.amiez@gmail.com"]
|
6
|
+
spec.description = "Redmine interaction through Lita"
|
7
|
+
spec.summary = "Fetch various information from your Redmine instance"
|
8
|
+
spec.homepage = "https://github.com/josqu4red/lita-redmine"
|
9
|
+
spec.license = "MIT"
|
10
|
+
spec.metadata = { "lita_plugin_type" => "handler" }
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split($/)
|
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", "~> 3.0"
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
spec.add_development_dependency "rspec", ">= 3.0.0.beta2"
|
22
|
+
spec.add_development_dependency "simplecov"
|
23
|
+
spec.add_development_dependency "coveralls"
|
24
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::Redmine, lita_handler: true do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Lita.configure do |config|
|
7
|
+
config.handlers.redmine.url = "https://redmine.example.com"
|
8
|
+
config.handlers.redmine.type = :chiliproject
|
9
|
+
config.handlers.redmine.apikey = "0000000000000000000000000000000000000000"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it { routes("get me redmine 12345, please").to(:issue) }
|
14
|
+
it { doesnt_route("redmine foo").to(:issue) }
|
15
|
+
|
16
|
+
describe "#issue" do
|
17
|
+
let(:response) do
|
18
|
+
response = double("Faraday::Response")
|
19
|
+
allow(response).to receive(:status).and_return(200)
|
20
|
+
response
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "params" do
|
24
|
+
it "replies with error if URL is not defined" do
|
25
|
+
Lita.configure do |config|
|
26
|
+
config.handlers.redmine.url = nil
|
27
|
+
end
|
28
|
+
|
29
|
+
send_command("redmine 42")
|
30
|
+
expect(replies.last).to eq("Error: Redmine URL must be defined ('config.handlers.redmine.url')")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "replies with error if API key is not defined" do
|
34
|
+
Lita.configure do |config|
|
35
|
+
config.handlers.redmine.apikey = nil
|
36
|
+
end
|
37
|
+
|
38
|
+
send_command("redmine 42")
|
39
|
+
expect(replies.last).to eq("Error: Redmine API key must be defined ('config.handlers.redmine.apikey')")
|
40
|
+
end
|
41
|
+
|
42
|
+
it "replies with error if Type is not defined" do
|
43
|
+
Lita.configure do |config|
|
44
|
+
config.handlers.redmine.type = nil
|
45
|
+
end
|
46
|
+
|
47
|
+
send_command("redmine 42")
|
48
|
+
expect(replies.last).to eq("Error: Redmine type must be :redmine (default) or :chiliproject ('config.handlers.redmine.type')")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
before do
|
53
|
+
allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(response)
|
54
|
+
end
|
55
|
+
|
56
|
+
it "replies with the title and URL for the issue" do
|
57
|
+
allow(response).to receive(:body).and_return(<<-JSON.chomp
|
58
|
+
{
|
59
|
+
"issue": {
|
60
|
+
"author": {
|
61
|
+
"name": "The Greybeards",
|
62
|
+
"id": 70
|
63
|
+
},
|
64
|
+
"subject": "Destroy Alduin",
|
65
|
+
"priority": {
|
66
|
+
"name": "High",
|
67
|
+
"id": 4
|
68
|
+
},
|
69
|
+
"updated_on": "2013-10-31T17:07:20+01:00",
|
70
|
+
"done_ratio": 0,
|
71
|
+
"start_date": "2012-11-22",
|
72
|
+
"status": {
|
73
|
+
"name": "Assigned",
|
74
|
+
"id": 2
|
75
|
+
},
|
76
|
+
"project": {
|
77
|
+
"name": "Skyrim",
|
78
|
+
"id": 1
|
79
|
+
},
|
80
|
+
"description": "",
|
81
|
+
"assigned_to": {
|
82
|
+
"name": "Dovahkin",
|
83
|
+
"id": 99
|
84
|
+
},
|
85
|
+
"tracker": {
|
86
|
+
"name": "Bug",
|
87
|
+
"id": 2
|
88
|
+
},
|
89
|
+
"created_on": "2012-11-22T14:52:33+01:00",
|
90
|
+
"id": 42
|
91
|
+
}
|
92
|
+
}
|
93
|
+
JSON
|
94
|
+
)
|
95
|
+
|
96
|
+
send_command("redmine 42")
|
97
|
+
|
98
|
+
expect(replies.last).to eq("https://redmine.example.com/issues/42 : Destroy Alduin")
|
99
|
+
end
|
100
|
+
|
101
|
+
it "replies that the issue doesn't exist" do
|
102
|
+
allow(response).to receive(:status).and_return(404)
|
103
|
+
|
104
|
+
send_command("redmine 42")
|
105
|
+
|
106
|
+
expect(replies.last).to eq("Issue #42 does not exist")
|
107
|
+
end
|
108
|
+
|
109
|
+
it "replies with an excception message" do
|
110
|
+
allow(response).to receive(:status).and_return(500)
|
111
|
+
|
112
|
+
send_command("redmine 42")
|
113
|
+
|
114
|
+
expect(replies.last).to match(/^Error: /)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,10 @@
|
|
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-redmine"
|
10
|
+
require "lita/rspec"
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-redmine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jonathan Amiez
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-18 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: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
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: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.0.beta2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.0.beta2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
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: coveralls
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Redmine interaction through Lita
|
98
|
+
email:
|
99
|
+
- jonathan.amiez@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
|
+
- Gemfile
|
107
|
+
- LICENSE
|
108
|
+
- README.md
|
109
|
+
- Rakefile
|
110
|
+
- lib/lita-redmine.rb
|
111
|
+
- lib/lita/handlers/redmine.rb
|
112
|
+
- lita-redmine.gemspec
|
113
|
+
- spec/lita/handlers/redmine_spec.rb
|
114
|
+
- spec/spec_helper.rb
|
115
|
+
homepage: https://github.com/josqu4red/lita-redmine
|
116
|
+
licenses:
|
117
|
+
- MIT
|
118
|
+
metadata:
|
119
|
+
lita_plugin_type: handler
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.2.0
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Fetch various information from your Redmine instance
|
140
|
+
test_files:
|
141
|
+
- spec/lita/handlers/redmine_spec.rb
|
142
|
+
- spec/spec_helper.rb
|