ghi 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +8 -0
- data/lib/ghi.rb +1 -1
- data/lib/ghi/cli.rb +14 -7
- data/spec/ghi/api_spec.rb +17 -15
- metadata +2 -2
data/History.rdoc
CHANGED
data/lib/ghi.rb
CHANGED
data/lib/ghi/cli.rb
CHANGED
@@ -45,7 +45,8 @@ module GHI::CLI #:nodoc:
|
|
45
45
|
private
|
46
46
|
|
47
47
|
def editor
|
48
|
-
ENV["GHI_EDITOR"] || ENV["
|
48
|
+
ENV["GHI_EDITOR"] || ENV["GIT_EDITOR"] ||
|
49
|
+
`git config --get-all core.editor`.split.first || ENV["EDITOR"] || "vi"
|
49
50
|
end
|
50
51
|
|
51
52
|
def gitdir
|
@@ -190,8 +191,11 @@ module GHI::CLI #:nodoc:
|
|
190
191
|
|
191
192
|
def pager
|
192
193
|
return @pager if defined? @pager
|
193
|
-
|
194
|
-
|
194
|
+
pager = ENV["GHI_PAGER"] || ENV["GIT_PAGER"] ||
|
195
|
+
`git config --get-all core.pager`.split.first || ENV["PAGER"] ||
|
196
|
+
"less -EMRX"
|
197
|
+
|
198
|
+
@pager = IO.popen(pager, "w")
|
195
199
|
end
|
196
200
|
|
197
201
|
def windows?
|
@@ -292,7 +296,7 @@ module GHI::CLI #:nodoc:
|
|
292
296
|
@number = v.to_i
|
293
297
|
when /^c(?:losed)?$/
|
294
298
|
@state = :closed
|
295
|
-
when /^
|
299
|
+
when /^[uw]$/
|
296
300
|
@action = :url
|
297
301
|
when /^v$/
|
298
302
|
@verbosity = true
|
@@ -319,7 +323,7 @@ module GHI::CLI #:nodoc:
|
|
319
323
|
@action = :list
|
320
324
|
when /^m$/
|
321
325
|
@title = args * " "
|
322
|
-
when /^
|
326
|
+
when /^[uw]$/
|
323
327
|
@action = :url
|
324
328
|
else
|
325
329
|
@title = v
|
@@ -334,7 +338,7 @@ module GHI::CLI #:nodoc:
|
|
334
338
|
when /^l$/
|
335
339
|
@action = :list
|
336
340
|
@state = :closed
|
337
|
-
when /^
|
341
|
+
when /^[uw]$/
|
338
342
|
@action = :url
|
339
343
|
@state = :closed
|
340
344
|
when nil
|
@@ -405,7 +409,7 @@ module GHI::CLI #:nodoc:
|
|
405
409
|
end
|
406
410
|
end
|
407
411
|
|
408
|
-
opts.on("-u", "--url [state|number]") do |v|
|
412
|
+
opts.on("-u", "-w", "--url", "--web [state|number]") do |v|
|
409
413
|
@action = :url
|
410
414
|
case v
|
411
415
|
when /^\d+$/
|
@@ -593,6 +597,9 @@ module GHI::CLI #:nodoc:
|
|
593
597
|
when %r{^([^/]+)/([^/]+)$}
|
594
598
|
@action = :list
|
595
599
|
@user, @repo = $1, $2
|
600
|
+
when "url", "web"
|
601
|
+
@action = :url
|
602
|
+
@number ||= arguments.shift[/\d+/].to_i
|
596
603
|
end
|
597
604
|
if @action
|
598
605
|
@args = @argv.dup
|
data/spec/ghi/api_spec.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
$: << File.expand_path(File.dirname(__FILE__) + "/../lib")
|
1
2
|
require "ghi"
|
2
3
|
require "ghi/api"
|
3
4
|
require "ghi/issue"
|
5
|
+
include GHI
|
4
6
|
|
5
7
|
ISSUES_YAML = <<-YAML
|
6
8
|
---
|
@@ -52,15 +54,15 @@ YAML
|
|
52
54
|
|
53
55
|
describe GHI::API do
|
54
56
|
it "should require user and repo" do
|
55
|
-
proc {
|
56
|
-
proc {
|
57
|
-
proc {
|
58
|
-
proc {
|
57
|
+
proc { API.new(nil, nil) }.should raise_error(API::InvalidConnection)
|
58
|
+
proc { API.new("u", nil) }.should raise_error(API::InvalidConnection)
|
59
|
+
proc { API.new(nil, "r") }.should raise_error(API::InvalidConnection)
|
60
|
+
proc { API.new("u", "r") }.should_not raise_error(API::InvalidConnection)
|
59
61
|
end
|
60
62
|
|
61
63
|
describe "requests" do
|
62
|
-
before :
|
63
|
-
@api =
|
64
|
+
before :each do
|
65
|
+
@api = API.new "stephencelis", "ghi"
|
64
66
|
GHI.stub!(:login).and_return "stephencelis"
|
65
67
|
GHI.stub!(:token).and_return "token"
|
66
68
|
end
|
@@ -78,7 +80,7 @@ describe GHI::API do
|
|
78
80
|
|
79
81
|
it "should process gets" do
|
80
82
|
url = "http://github.com/api/v2/yaml/issues/open/stephencelis/ghi"
|
81
|
-
query = "?login=stephencelis&token=
|
83
|
+
query = "?login=stephencelis&token=token"
|
82
84
|
@api.stub!(:url).and_return url
|
83
85
|
URI.should_receive(:parse).once.with(url + query).and_return("mock")
|
84
86
|
Net::HTTP.should_receive(:get).once.with("mock").and_return ISSUES_YAML
|
@@ -88,7 +90,7 @@ describe GHI::API do
|
|
88
90
|
it "should process posts" do
|
89
91
|
url = "http://github.com/api/v2/yaml/issues/open/stephencelis/ghi"
|
90
92
|
query = { "login" => "stephencelis",
|
91
|
-
"token" => "
|
93
|
+
"token" => "token",
|
92
94
|
"title" => "Title",
|
93
95
|
"body" => "Body" }
|
94
96
|
@api.stub!(:url).and_return url
|
@@ -104,7 +106,7 @@ describe GHI::API do
|
|
104
106
|
Net::HTTP.stub!(:get).and_return ISSUES_YAML
|
105
107
|
issues = @api.search "me"
|
106
108
|
issues.should be_an_instance_of(Array)
|
107
|
-
issues.each { |issue| issue.should be_an_instance_of(
|
109
|
+
issues.each { |issue| issue.should be_an_instance_of(Issue) }
|
108
110
|
end
|
109
111
|
|
110
112
|
it "should search closed" do
|
@@ -118,7 +120,7 @@ describe GHI::API do
|
|
118
120
|
Net::HTTP.stub!(:get).and_return ISSUES_YAML
|
119
121
|
issues = @api.list
|
120
122
|
issues.should be_an_instance_of(Array)
|
121
|
-
issues.each { |issue| issue.should be_an_instance_of(
|
123
|
+
issues.each { |issue| issue.should be_an_instance_of(Issue) }
|
122
124
|
end
|
123
125
|
|
124
126
|
it "should list closed" do
|
@@ -130,7 +132,7 @@ describe GHI::API do
|
|
130
132
|
it "should show" do
|
131
133
|
@api.should_receive(:url).with(:show, 1).and_return "u"
|
132
134
|
Net::HTTP.stub!(:get).and_return ISSUE_YAML
|
133
|
-
@api.show(1).should be_an_instance_of(
|
135
|
+
@api.show(1).should be_an_instance_of(Issue)
|
134
136
|
end
|
135
137
|
|
136
138
|
it "should open" do
|
@@ -138,7 +140,7 @@ describe GHI::API do
|
|
138
140
|
response = mock(Net::HTTPRequest)
|
139
141
|
response.stub!(:body).and_return ISSUE_YAML
|
140
142
|
Net::HTTP.stub!(:post_form).and_return response
|
141
|
-
@api.open("Title", "Body").should be_an_instance_of(
|
143
|
+
@api.open("Title", "Body").should be_an_instance_of(Issue)
|
142
144
|
end
|
143
145
|
|
144
146
|
it "should edit" do
|
@@ -146,7 +148,7 @@ describe GHI::API do
|
|
146
148
|
response = mock(Net::HTTPRequest)
|
147
149
|
response.stub!(:body).and_return ISSUE_YAML
|
148
150
|
Net::HTTP.stub!(:post_form).and_return response
|
149
|
-
@api.edit(1, "Title", "Body").should be_an_instance_of(
|
151
|
+
@api.edit(1, "Title", "Body").should be_an_instance_of(Issue)
|
150
152
|
end
|
151
153
|
|
152
154
|
it "should close" do
|
@@ -154,7 +156,7 @@ describe GHI::API do
|
|
154
156
|
response = mock(Net::HTTPRequest)
|
155
157
|
response.stub!(:body).and_return ISSUE_YAML
|
156
158
|
Net::HTTP.stub!(:post_form).and_return response
|
157
|
-
@api.close(1).should be_an_instance_of(
|
159
|
+
@api.close(1).should be_an_instance_of(Issue)
|
158
160
|
end
|
159
161
|
|
160
162
|
it "should reopen" do
|
@@ -162,7 +164,7 @@ describe GHI::API do
|
|
162
164
|
response = mock(Net::HTTPRequest)
|
163
165
|
response.stub!(:body).and_return ISSUE_YAML
|
164
166
|
Net::HTTP.stub!(:post_form).and_return response
|
165
|
-
@api.reopen(1).should be_an_instance_of(
|
167
|
+
@api.reopen(1).should be_an_instance_of(Issue)
|
166
168
|
end
|
167
169
|
|
168
170
|
it "should add labels" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ghi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Celis
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-12-07 00:00:00 -06:00
|
13
13
|
default_executable: ghi
|
14
14
|
dependencies: []
|
15
15
|
|