cinch-github 0.0.3 → 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.
- data/Gemfile.lock +7 -9
- data/README.md +17 -7
- data/lib/cinch/plugins/github/issue.rb +91 -3
- data/lib/cinch/plugins/github/version.rb +1 -1
- data/test/issue_test.rb +58 -0
- metadata +4 -26
data/Gemfile.lock
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
cinch-github (0.0.
|
5
|
-
cinch
|
4
|
+
cinch-github (0.0.3)
|
5
|
+
cinch (~> 1.1.1)
|
6
6
|
octopi
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: http://rubygems.org/
|
10
10
|
specs:
|
11
|
-
api_cache (0.2.
|
12
|
-
cinch (1.1.
|
11
|
+
api_cache (0.2.3)
|
12
|
+
cinch (1.1.3)
|
13
13
|
crack (0.1.8)
|
14
|
-
httparty (0.7.
|
14
|
+
httparty (0.7.8)
|
15
15
|
crack (= 0.1.8)
|
16
16
|
mechanize (1.0.0)
|
17
17
|
nokogiri (>= 1.2.1)
|
18
18
|
mocha (0.9.10)
|
19
19
|
rake
|
20
|
-
nokogiri (1.4.
|
21
|
-
octopi (0.4.
|
20
|
+
nokogiri (1.4.6)
|
21
|
+
octopi (0.4.4)
|
22
22
|
api_cache
|
23
23
|
httparty (>= 0.4.5)
|
24
24
|
mechanize (>= 0.9.3)
|
@@ -34,8 +34,6 @@ PLATFORMS
|
|
34
34
|
ruby
|
35
35
|
|
36
36
|
DEPENDENCIES
|
37
|
-
cinch
|
38
37
|
cinch-github!
|
39
38
|
mocha
|
40
|
-
octopi
|
41
39
|
riot (~> 0.12.0)
|
data/README.md
CHANGED
@@ -34,17 +34,19 @@ To setup the Issue plugin to work with your cinch bot, we'll need to provide som
|
|
34
34
|
|
35
35
|
#### Commands ####
|
36
36
|
|
37
|
-
* !issue state [open|closed] [query]
|
38
|
-
* !issue find [query]
|
39
|
-
* !issue link [number]
|
40
|
-
* !
|
41
|
-
|
42
|
-
|
37
|
+
* !issue state [open|closed] [query] - returns issues that have state open or closed matching the query
|
38
|
+
* !issue find [query] - returns issues matching the query. defaults to state open
|
39
|
+
* !issue link [number] - returns issue link for issue number(must be digits)
|
40
|
+
* !issue comment [number] [comment] - comment on an issue
|
41
|
+
* !issue new [title] - Create a new issue
|
42
|
+
* !issue close [number] [optional comment] - Close an issue with an optional comment
|
43
|
+
* !issue reopen [number] [optional comment] - Reopen an issue with an optional comment
|
44
|
+
* !help github issue - returns commands for Github Issue
|
43
45
|
|
44
46
|
## Integration with Cinch ##
|
45
47
|
|
46
48
|
It's simple. follow the guide on cinch or do something like:
|
47
|
-
|
49
|
+
|
48
50
|
# mybot.rb
|
49
51
|
require 'cinch'
|
50
52
|
require 'cinch/plugins/github'
|
@@ -75,6 +77,14 @@ Finally, run your bot.
|
|
75
77
|
And there you go!
|
76
78
|
|
77
79
|
|
80
|
+
CONTRIBUTORS
|
81
|
+
------------
|
82
|
+
|
83
|
+
Michael D. Ivey ([ivey](https://github.com/ivey))
|
84
|
+
|
85
|
+
* For having issue return a title and link when called.
|
86
|
+
* For adding new, close, reopen, and commenting operations with issues
|
87
|
+
|
78
88
|
TODO
|
79
89
|
-----
|
80
90
|
|
@@ -21,13 +21,23 @@ module Cinch
|
|
21
21
|
match %r{issue state (open|closed) (.+)}, :method => :get_ticket # !issue state closed bugs
|
22
22
|
match %r{issue find (.+)}, :method => :get_ticket # !issue find sinatra
|
23
23
|
match %r{issue link (.+)}, :method => :reply_link # !issue link 35
|
24
|
+
match %r{issue comment (\d+) (.+)}, :method => :comment_issue # !issue comment 35 some comment to add
|
25
|
+
match %r{issue close (\d+) ?(.*)}, :method => :close_issue # !issue close 35 [optional comment]
|
26
|
+
match %r{issue reopen (\d+) ?(.*)}, :method => :reopen_issue # !issue reopen 35 [optional comment]
|
27
|
+
match %r{issue new (.+)}, :method => :new_issue # !issue new title
|
28
|
+
match %r{issue show (\d+)}, :method => :show_issue # !issue show 35
|
24
29
|
|
25
30
|
# Display Github Issue Help
|
26
31
|
def display_help(m)
|
27
32
|
User(m.user.nick).send (<<-EOF).gsub(/^ {10}/,'')
|
28
|
-
!issue state [open|closed] [query]
|
29
|
-
!issue find [query]
|
30
|
-
!issue
|
33
|
+
!issue state [open|closed] [query] - query for a ticket with state closed
|
34
|
+
!issue find [query] - query for a ticket with state open
|
35
|
+
!issue show [number] - shows detail for issue
|
36
|
+
!issue link [number] - returns link for issue number.
|
37
|
+
!issue close [number] [optional comment] - close an issue
|
38
|
+
!issue reopen [number] [optional comment] - reopen an issue
|
39
|
+
!issue comment [number] [comment] - comment on an issue
|
40
|
+
!issue new [title] - create a new issue
|
31
41
|
EOF
|
32
42
|
end
|
33
43
|
|
@@ -38,6 +48,17 @@ module Cinch
|
|
38
48
|
output m, results.first.last
|
39
49
|
end
|
40
50
|
|
51
|
+
# show ticket title
|
52
|
+
def show_issue(m, arg)
|
53
|
+
result = find_issue(arg)
|
54
|
+
p result
|
55
|
+
if result
|
56
|
+
m.reply "##{arg} #{result.title} : #{issue_link(arg)}"
|
57
|
+
else
|
58
|
+
m.reply "Not found"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
41
62
|
# Return the link of the issue
|
42
63
|
def reply_link(m, arg)
|
43
64
|
arg =~ /\D+/ ? m.reply("You need to give me a number...") : m.reply(issue_link(arg))
|
@@ -55,6 +76,73 @@ module Cinch
|
|
55
76
|
"https://www.github.com/#{self.class.author}/#{self.class.repo}/issues/#{number}"
|
56
77
|
end
|
57
78
|
|
79
|
+
def find_issue(number)
|
80
|
+
authenticated_with :login => self.class.user, :token => self.class.token do
|
81
|
+
Octopi::Issue.find :user => self.class.author, :repo => self.class.repo, :number => number
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Creates an issue
|
86
|
+
def new_issue(m, title)
|
87
|
+
authenticated_with :login => self.class.user, :token => self.class.token do
|
88
|
+
params = { :title => title, :body => "Opened via #{m.user.nick} on IRC" }
|
89
|
+
i = Octopi::Issue.open :user => self.class.author, :repo => self.class.repo, :params => params
|
90
|
+
if i
|
91
|
+
m.reply "Issue created: #{issue_link(i.number)}"
|
92
|
+
else
|
93
|
+
m.reply "Issue creation failed. Sorry."
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Comments on the issue
|
99
|
+
def comment_issue(m, number, comment)
|
100
|
+
i = find_issue(number)
|
101
|
+
authenticated_with :login => self.class.user, :token => self.class.token do
|
102
|
+
if i.comment "Via #{m.user.nick} on IRC: #{comment}"
|
103
|
+
m.reply "Comment added. #{issue_link(number)}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# Closes issue
|
109
|
+
def close_issue(m, number, comment="")
|
110
|
+
i = find_issue(number)
|
111
|
+
authenticated_with :login => self.class.user, :token => self.class.token do
|
112
|
+
|
113
|
+
if i.close!
|
114
|
+
|
115
|
+
msg = "Closed via IRC by #{m.user.nick}"
|
116
|
+
if comment != ""
|
117
|
+
msg += "\n#{comment}"
|
118
|
+
end
|
119
|
+
i.comment msg
|
120
|
+
m.reply("Marked as closed: #{issue_link(number)}")
|
121
|
+
else
|
122
|
+
m.reply("Sorry, close failed #{issue_link(number)}")
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
# Closes the issue
|
128
|
+
def reopen_issue(m, number, comment="")
|
129
|
+
i = find_issue(number)
|
130
|
+
authenticated_with :login => self.class.user, :token => self.class.token do
|
131
|
+
|
132
|
+
if i.reopen!
|
133
|
+
|
134
|
+
msg = "Reopened via IRC by #{m.user.nick}"
|
135
|
+
if comment != ""
|
136
|
+
msg += "\n#{comment}"
|
137
|
+
end
|
138
|
+
i.comment msg
|
139
|
+
m.reply("Marked as reopened: #{issue_link(number)}")
|
140
|
+
else
|
141
|
+
m.reply("Sorry, reopen failed #{issue_link(number)}")
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
58
146
|
private
|
59
147
|
|
60
148
|
# Outputs the reply back to screen
|
data/test/issue_test.rb
CHANGED
@@ -30,6 +30,10 @@ context "Issue Plugin" do
|
|
30
30
|
mock_match @issue, %r{issue state (open|closed) (.*)}, :get_ticket
|
31
31
|
mock_match @issue, %r{issue find (.*)}, :get_ticket
|
32
32
|
mock_match @issue, %r{issue link (.*)}, :reply_link
|
33
|
+
mock_match @issue, %r{issue close (\d+) ?(.*)}, :close_issue
|
34
|
+
mock_match @issue, %r{issue reopen (\d+) ?(.*)}, :reopen_issue
|
35
|
+
mock_match @issue, %r{issue comment (\d+) ?(.*)}, :comment_issue
|
36
|
+
mock_match @issue, %r{issue new (.*)}, :new_issue
|
33
37
|
end
|
34
38
|
asserts("that it has matches") { @issue.new(Cinch::Bot.new) }
|
35
39
|
end
|
@@ -114,4 +118,58 @@ context "Issue Plugin" do
|
|
114
118
|
|
115
119
|
end
|
116
120
|
|
121
|
+
context "#comment_issue" do
|
122
|
+
setup do
|
123
|
+
@m = mock()
|
124
|
+
@m.expects(:reply).returns(true)
|
125
|
+
@issue = issue.new(Cinch::Bot.new)
|
126
|
+
@issue.expects(:authenticated_with).at_least_once.with(:login => 'achiu', :token => 'my_token').returns(true)
|
127
|
+
@mock_issue = mock()
|
128
|
+
@mock_issue.expects(:comment).returns(true)
|
129
|
+
params = { :user => 'achiu', :repo => 'cinch-github', :number => 3 }
|
130
|
+
Octopi::Issue.expects(:find).with(params).returns(@mock_issue)
|
131
|
+
end
|
132
|
+
asserts("that it finds the ticket and adds a comment") { @issue.comment_issue(@m, 3, "foo bar") }
|
133
|
+
end
|
134
|
+
|
135
|
+
context "#close_issue" do
|
136
|
+
setup do
|
137
|
+
@m = mock()
|
138
|
+
@m.expects(:reply).returns(true)
|
139
|
+
@issue = issue.new(Cinch::Bot.new)
|
140
|
+
@issue.expects(:authenticated_with).at_least_once.with(:login => 'achiu', :token => 'my_token').returns(true)
|
141
|
+
@mock_issue = mock()
|
142
|
+
@mock_issue.expects(:close!).returns(true)
|
143
|
+
params = { :user => 'achiu', :repo => 'cinch-github', :number => 3 }
|
144
|
+
Octopi::Issue.expects(:find).with(params).returns(@mock_issue)
|
145
|
+
end
|
146
|
+
asserts("that it finds the ticket and marks it closed") { @issue.close_issue(@m, 3) }
|
147
|
+
end
|
148
|
+
|
149
|
+
context "#reopen_issue" do
|
150
|
+
setup do
|
151
|
+
@m = mock()
|
152
|
+
@m.expects(:reply).returns(true)
|
153
|
+
@issue = issue.new(Cinch::Bot.new)
|
154
|
+
@issue.expects(:authenticated_with).at_least_once.with(:login => 'achiu', :token => 'my_token').returns(true)
|
155
|
+
@mock_issue = mock()
|
156
|
+
@mock_issue.expects(:reopen!).returns(true)
|
157
|
+
params = { :user => 'achiu', :repo => 'cinch-github', :number => 3 }
|
158
|
+
Octopi::Issue.expects(:find).with(params).returns(@mock_issue)
|
159
|
+
end
|
160
|
+
asserts("that it finds the ticket and marks it re-opened") { @issue.reopen_issue(@m, 3) }
|
161
|
+
end
|
162
|
+
|
163
|
+
context "#new_issue" do
|
164
|
+
setup do
|
165
|
+
@m = mock()
|
166
|
+
@m.expects(:reply).returns(true)
|
167
|
+
@issue = issue.new(Cinch::Bot.new)
|
168
|
+
@issue.expects(:authenticated_with).at_least_once.with(:login => 'achiu', :token => 'my_token').returns(true)
|
169
|
+
params = { :user => 'achiu', :repo => 'cinch-github', :number => 3 }
|
170
|
+
Octopi::Issue.expects(:open).with(params).returns(@mock_issue)
|
171
|
+
end
|
172
|
+
asserts("that it opens a new issue") { @issue.new_issue(@m, 'test issue') }
|
173
|
+
end
|
174
|
+
|
117
175
|
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-github
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
version: 0.0.3
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Arthur Chiu
|
@@ -14,8 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
18
|
-
default_executable:
|
13
|
+
date: 2011-06-20 00:00:00 Z
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
16
|
name: cinch
|
@@ -25,10 +20,6 @@ dependencies:
|
|
25
20
|
requirements:
|
26
21
|
- - ~>
|
27
22
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 1
|
31
|
-
- 1
|
32
23
|
version: 1.1.1
|
33
24
|
type: :runtime
|
34
25
|
version_requirements: *id001
|
@@ -40,8 +31,6 @@ dependencies:
|
|
40
31
|
requirements:
|
41
32
|
- - ">="
|
42
33
|
- !ruby/object:Gem::Version
|
43
|
-
segments:
|
44
|
-
- 0
|
45
34
|
version: "0"
|
46
35
|
type: :runtime
|
47
36
|
version_requirements: *id002
|
@@ -53,10 +42,6 @@ dependencies:
|
|
53
42
|
requirements:
|
54
43
|
- - ~>
|
55
44
|
- !ruby/object:Gem::Version
|
56
|
-
segments:
|
57
|
-
- 0
|
58
|
-
- 12
|
59
|
-
- 0
|
60
45
|
version: 0.12.0
|
61
46
|
type: :development
|
62
47
|
version_requirements: *id003
|
@@ -68,8 +53,6 @@ dependencies:
|
|
68
53
|
requirements:
|
69
54
|
- - ">="
|
70
55
|
- !ruby/object:Gem::Version
|
71
|
-
segments:
|
72
|
-
- 0
|
73
56
|
version: "0"
|
74
57
|
type: :development
|
75
58
|
version_requirements: *id004
|
@@ -96,7 +79,6 @@ files:
|
|
96
79
|
- test.watchr
|
97
80
|
- test/issue_test.rb
|
98
81
|
- test/teststrap.rb
|
99
|
-
has_rdoc: true
|
100
82
|
homepage: http://rubygems.org/gems/cinch-github
|
101
83
|
licenses: []
|
102
84
|
|
@@ -110,21 +92,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
92
|
requirements:
|
111
93
|
- - ">="
|
112
94
|
- !ruby/object:Gem::Version
|
113
|
-
segments:
|
114
|
-
- 0
|
115
95
|
version: "0"
|
116
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
97
|
none: false
|
118
98
|
requirements:
|
119
99
|
- - ">="
|
120
100
|
- !ruby/object:Gem::Version
|
121
|
-
segments:
|
122
|
-
- 0
|
123
101
|
version: "0"
|
124
102
|
requirements: []
|
125
103
|
|
126
104
|
rubyforge_project: cinch-github
|
127
|
-
rubygems_version: 1.
|
105
|
+
rubygems_version: 1.8.4
|
128
106
|
signing_key:
|
129
107
|
specification_version: 3
|
130
108
|
summary: Github Plugin for Cinch
|