ghi 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,11 @@
1
+ === 0.2.3 / 2009-12-17
2
+
3
+ * Minor enhancements
4
+
5
+ * Better follow git's editor and pager behavior.
6
+ * Accept -w and --web as alternatives to -u and --url (like git help).
7
+
8
+
1
9
  === 0.2.2 / 2009-11-30
2
10
 
3
11
  * 1 bugfix
data/lib/ghi.rb CHANGED
@@ -2,7 +2,7 @@ require "net/http"
2
2
  require "yaml"
3
3
 
4
4
  module GHI
5
- VERSION = "0.2"
5
+ VERSION = "0.2.3"
6
6
 
7
7
  class << self
8
8
  def login
@@ -45,7 +45,8 @@ module GHI::CLI #:nodoc:
45
45
  private
46
46
 
47
47
  def editor
48
- ENV["GHI_EDITOR"] || ENV["VISUAL"] || ENV["EDITOR"] || "vi"
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
- pagers = [ENV["GHI_PAGER"], "less -EMRX", "pager", "more"].compact.uniq
194
- pagers.each { |pager| return @pager = IO.popen(pager, "w") rescue nil }
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 /^u$/
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 /^u$/
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 /^u$/
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
@@ -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 { GHI::API.new(nil, nil) }.should raise_error(GHI::API::InvalidConnection)
56
- proc { GHI::API.new("u", nil) }.should raise_error(GHI::API::InvalidConnection)
57
- proc { GHI::API.new(nil, "r") }.should raise_error(GHI::API::InvalidConnection)
58
- proc { GHI::API.new("u", "r") }.should_not raise_error(GHI::API::InvalidConnection)
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 :all do
63
- @api = GHI::API.new "stephencelis", "ghi"
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=d1cd249db48d51c9847cbf2b291f5ae9"
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" => "d1cd249db48d51c9847cbf2b291f5ae9",
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(GHI::Issue) }
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(GHI::Issue) }
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(GHI::Issue)
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(GHI::Issue)
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(GHI::Issue)
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(GHI::Issue)
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(GHI::Issue)
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.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-11-30 00:00:00 -06:00
12
+ date: 2009-12-07 00:00:00 -06:00
13
13
  default_executable: ghi
14
14
  dependencies: []
15
15