stephencelis-ghi 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,4 +1,16 @@
1
- === 0.1.5 / 2009-05-15
1
+ === 0.1.6 / 2009-08-05
2
+
3
+ * 1 minor enhancement
4
+
5
+ * Support for non-"origin" remotes.
6
+
7
+
8
+ * 1 bugfix
9
+
10
+ * Graceful offline error.
11
+
12
+
13
+ === 0.1.5 / 2009-07-08
2
14
 
3
15
  * 2 bugfixes
4
16
 
data/bin/ghi CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $: << File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))
3
4
  require "ghi/cli"
4
5
  $stdout.sync = true
5
6
  GHI::CLI::Executable.new.parse!(ARGV)
data/lib/ghi/api.rb CHANGED
@@ -69,6 +69,8 @@ class GHI::API
69
69
  res
70
70
  rescue ArgumentError, URI::InvalidURIError
71
71
  raise ResponseError, "GitHub hiccuped on your request"
72
+ rescue SocketError
73
+ raise ResponseError, "couldn't find the internet"
72
74
  end
73
75
 
74
76
  def post(*args)
@@ -79,6 +81,8 @@ class GHI::API
79
81
  res
80
82
  rescue ArgumentError, URI::InvalidURIError
81
83
  raise ResponseError, "GitHub hiccuped on your request"
84
+ rescue SocketError
85
+ raise ResponseError, "couldn't find the internet"
82
86
  end
83
87
 
84
88
  def errors(response)
data/lib/ghi/cli.rb CHANGED
@@ -18,7 +18,7 @@ module GHI::CLI #:nodoc:
18
18
 
19
19
  def gets_from_editor(issue)
20
20
  if windows?
21
- warn "Please supply the message by using the -m option"
21
+ warn "Please supply the message with the -m option"
22
22
  exit 1
23
23
  end
24
24
 
@@ -195,7 +195,7 @@ module GHI::CLI #:nodoc:
195
195
  end
196
196
 
197
197
  def windows?
198
- RUBY_PLATFORM.include?("mswin")
198
+ RUBY_PLATFORM.include? "mswin"
199
199
  end
200
200
  end
201
201
 
@@ -208,8 +208,9 @@ module GHI::CLI #:nodoc:
208
208
  def parse!(*argv)
209
209
  @args, @argv = argv, argv.dup
210
210
 
211
+ remotes = `git config --get-regexp remote\..+\.url`.split /\n/
211
212
  repo_expression = %r{([^:/]+)/([^/\.\s]+)(?:\.git)?$}
212
- `git config --get remote.origin.url`.match repo_expression
213
+ remotes.find { |r| r.include? "github.com" }.match repo_expression
213
214
  @user, @repo = $1, $2
214
215
 
215
216
  option_parser.parse!(*args)
data/lib/ghi.rb CHANGED
@@ -2,52 +2,54 @@ require "net/http"
2
2
  require "yaml"
3
3
 
4
4
  module GHI
5
- VERSION = "0.1.5"
5
+ VERSION = "0.1.6"
6
6
 
7
- def self.login
8
- return @login if defined? @login
9
- @login = `git config --get github.user`.chomp
10
- if @login.empty?
11
- begin
12
- print "Please enter your GitHub username: "
13
- @login = gets.chomp
14
- valid = user? @login
15
- warn "invalid username" unless valid
16
- end until valid
17
- `git config --global github.user #@login`
7
+ class << self
8
+ def login
9
+ return @login if defined? @login
10
+ @login = `git config --get github.user`.chomp
11
+ if @login.empty?
12
+ begin
13
+ print "Please enter your GitHub username: "
14
+ @login = gets.chomp
15
+ valid = user? @login
16
+ warn "invalid username" unless valid
17
+ end until valid
18
+ `git config --global github.user #@login`
19
+ end
20
+ @login
18
21
  end
19
- @login
20
- end
21
22
 
22
- def self.token
23
- return @token if defined? @token
24
- @token = `git config --get github.token`.chomp
25
- if @token.empty?
26
- begin
27
- print "GitHub token (https://github.com/account): "
28
- @token = gets.chomp
29
- valid = token? @token
30
- warn "invalid token for #{GHI.login}" unless valid
31
- end until valid
32
- `git config --global github.token #@token`
23
+ def token
24
+ return @token if defined? @token
25
+ @token = `git config --get github.token`.chomp
26
+ if @token.empty?
27
+ begin
28
+ print "GitHub token (https://github.com/account): "
29
+ @token = gets.chomp
30
+ valid = token? @token
31
+ warn "invalid token for #{login}" unless valid
32
+ end until valid
33
+ `git config --global github.token #@token`
34
+ end
35
+ @token
33
36
  end
34
- @token
35
- end
36
37
 
37
- private
38
+ private
38
39
 
39
- def self.user?(username)
40
- url = "http://github.com/api/v2/yaml/user/show/#{username}"
41
- !YAML.load(Net::HTTP.get(URI.parse(url)))["user"].nil?
42
- rescue ArgumentError, URI::InvalidURIError
43
- false
44
- end
40
+ def user?(username)
41
+ url = "http://github.com/api/v2/yaml/user/show/#{username}"
42
+ !YAML.load(Net::HTTP.get(URI.parse(url)))["user"].nil?
43
+ rescue ArgumentError, URI::InvalidURIError
44
+ false
45
+ end
45
46
 
46
- def self.token?(token)
47
- url = "http://github.com/api/v2/yaml/user/show/#{GHI.login}"
48
- url += "?login=#{GHI.login}&token=#{token}"
49
- !YAML.load(Net::HTTP.get(URI.parse(url)))["user"]["plan"].nil?
50
- rescue ArgumentError, NoMethodError, URI::InvalidURIError
51
- false
47
+ def token?(token)
48
+ url = "http://github.com/api/v2/yaml/user/show/#{login}"
49
+ url += "?login=#{login}&token=#{token}"
50
+ !YAML.load(Net::HTTP.get(URI.parse(url)))["user"]["plan"].nil?
51
+ rescue ArgumentError, NoMethodError, URI::InvalidURIError
52
+ false
53
+ end
52
54
  end
53
55
  end
data/spec/ghi/cli_spec.rb CHANGED
@@ -19,7 +19,7 @@ describe GHI::CLI::Executable do
19
19
  end
20
20
 
21
21
  after :each do
22
- @cli.stub!(:`).and_return "stub:localuser/ghi.git"
22
+ @cli.stub!(:`).and_return "stub@github.com:localuser/ghi.git"
23
23
  @cli.should_receive(@action)
24
24
  @cli.parse! @args
25
25
  @cli.action.should == @action
data/spec/ghi_spec.rb CHANGED
@@ -2,7 +2,7 @@ require "ghi"
2
2
 
3
3
  LOGGED_OUT_YAML = <<-YAML
4
4
  ---
5
- user:
5
+ user:
6
6
  id: 23
7
7
  login: defunkt
8
8
  name: Kristopher Walken Wanstrath
@@ -18,7 +18,7 @@ YAML
18
18
 
19
19
  LOGGED_IN_YAML = <<-YAML
20
20
  ---
21
- user:
21
+ user:
22
22
  id: 23
23
23
  login: defunkt
24
24
  name: Kristopher Walken Wanstrath
@@ -35,7 +35,7 @@ user:
35
35
  disk_usage: 50384
36
36
  owned_private_repo_count: 1
37
37
  private_gist_count: 0
38
- plan:
38
+ plan:
39
39
  name: mega
40
40
  collaborators: 60
41
41
  space: 20971520
@@ -54,7 +54,7 @@ describe GHI do
54
54
  GHI.should_receive(:`).once.and_return "stephencelis\n"
55
55
  GHI.login.should == "stephencelis"
56
56
  end
57
-
57
+
58
58
  it "should return token" do
59
59
  GHI.should_receive(:`).once.and_return "da39a3ee5e6b4b0d3255bfef95601890\n"
60
60
  GHI.token.should == "da39a3ee5e6b4b0d3255bfef95601890"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stephencelis-ghi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Celis
@@ -39,6 +39,7 @@ files:
39
39
  - spec/ghi_spec.rb
40
40
  has_rdoc: true
41
41
  homepage: http://github.com/stephencelis/ghi
42
+ licenses:
42
43
  post_install_message:
43
44
  rdoc_options:
44
45
  - --main
@@ -60,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
61
  requirements: []
61
62
 
62
63
  rubyforge_project: ghi
63
- rubygems_version: 1.2.0
64
+ rubygems_version: 1.3.5
64
65
  signing_key:
65
66
  specification_version: 3
66
67
  summary: GitHub Issues on the command line