ghi 0.9.0.20130504 → 0.9.0.20130912

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e0c68ea7d989b5a9f84393182ce31fc1aa3225d0
4
+ data.tar.gz: 4703a58daeadacc4fe7eeb14634707e1689af384
5
+ SHA512:
6
+ metadata.gz: 9285c3ef1ba18302d364ba8690c42bf9f4bd0861ae3c16c57a86dd372e6e958058c6a9b3b4182df3cbde206778a6c1307c3516d7cb5e808ebefc3a18b1219d9f
7
+ data.tar.gz: 0a48d81eaae90de2a27a5bf6ff60ac58de04f709638ae3111196e978fd33db416f30b2255b7e33e0cd3ec04551ed770c69ce10832f8a7f40732d9a586977e45b
@@ -16,13 +16,18 @@ module GHI
16
16
 
17
17
  def authorize! user = username, pass = password, local = true
18
18
  return false unless user && pass
19
-
20
- res = throb(54, "✔\r") {
21
- Client.new(user, pass).post(
22
- '/authorizations',
19
+ code ||= nil # 2fa
20
+ args = code ? [] : [54, "✔\r"]
21
+ res = throb(*args) {
22
+ headers = {}
23
+ headers['X-GitHub-OTP'] = code if code
24
+ body = {
23
25
  :scopes => %w(public_repo repo),
24
26
  :note => 'ghi',
25
27
  :note_url => 'https://github.com/stephencelis/ghi'
28
+ }
29
+ Client.new(user, pass).post(
30
+ '/authorizations', body, :headers => headers
26
31
  )
27
32
  }
28
33
  @token = res.body['token']
@@ -50,6 +55,15 @@ EOF
50
55
  end
51
56
  end
52
57
  rescue Client::Error => e
58
+ if e.response['X-GitHub-OTP'] =~ /required/
59
+ puts "Bad code." if code
60
+ print "Two-factor authentication code: "
61
+ trap('INT') { abort }
62
+ code = gets
63
+ code = '' and puts "\n" unless code
64
+ retry
65
+ end
66
+
53
67
  abort "#{e.message}#{CURSOR[:column][0]}"
54
68
  end
55
69
 
data/lib/ghi/client.rb CHANGED
@@ -102,7 +102,8 @@ module GHI
102
102
  path += "?#{q.join '&'}"
103
103
  end
104
104
 
105
- headers = { 'Accept' => CONTENT_TYPE, 'User-Agent' => USER_AGENT }
105
+ headers = options.fetch :headers, {}
106
+ headers.update 'Accept' => CONTENT_TYPE, 'User-Agent' => USER_AGENT
106
107
  req = METHODS[method].new path, headers
107
108
  if GHI::Authorization.token
108
109
  req['Authorization'] = "token #{GHI::Authorization.token}"
@@ -37,7 +37,7 @@ module GHI
37
37
 
38
38
  def repo
39
39
  return @repo if defined? @repo
40
- @repo = GHI.config('ghi.repo') || detect_repo
40
+ @repo = detect_repo || GHI.config('ghi.repo')
41
41
  if @repo && !@repo.include?('/')
42
42
  @repo = [Authorization.username, @repo].join '/'
43
43
  end
@@ -103,6 +103,7 @@ module GHI
103
103
 
104
104
  begin
105
105
  options.parse! args
106
+ @repo ||= ARGV[0] if ARGV.one?
106
107
  rescue OptionParser::InvalidOption => e
107
108
  fallback.parse! e.args
108
109
  retry
@@ -4,7 +4,7 @@ module GHI
4
4
  MAJOR = 0
5
5
  MINOR = 9
6
6
  PATCH = 0
7
- PRE = 20130504
7
+ PRE = 20130912
8
8
 
9
9
  VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join '.'
10
10
 
@@ -228,7 +228,7 @@ module GHI
228
228
  end
229
229
 
230
230
  def escape_256 color
231
- "8;5;#{to_256(*to_rgb(color))}" if ENV['TERM'] =~ /256/
231
+ "8;5;#{to_256(*to_rgb(color))}" if `tput colors` =~ /256/
232
232
  end
233
233
 
234
234
  def to_256 r, g, b
data/lib/ghi/web.rb CHANGED
@@ -12,7 +12,9 @@ module GHI
12
12
  end
13
13
 
14
14
  def open path = '', params = {}
15
- system "open '#{uri_for path, params}'"
15
+ launcher = 'open'
16
+ launcher = 'xdg-open' if /linux/ =~ RUBY_PLATFORM
17
+ system "#{launcher} '#{uri_for path, params}'"
16
18
  end
17
19
 
18
20
  def curl path = '', params = {}
metadata CHANGED
@@ -1,58 +1,51 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: ghi
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 9
8
- - 0
9
- - 20130504
10
- version: 0.9.0.20130504
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0.20130912
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Stephen Celis
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-05-04 00:00:00 -07:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
11
+ date: 2013-09-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
22
14
  name: rake
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
31
20
  type: :development
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: ronn
35
21
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- segments:
41
- - 0
42
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ronn
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
43
34
  type: :development
44
- version_requirements: *id002
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
45
41
  description: |
46
42
  GitHub Issues on the command line. Use your `$EDITOR`, not your browser.
47
-
48
43
  email: stephen@stephencelis.com
49
- executables:
44
+ executables:
50
45
  - ghi
51
46
  extensions: []
52
-
53
47
  extra_rdoc_files: []
54
-
55
- files:
48
+ files:
56
49
  - lib/ghi/authorization.rb
57
50
  - lib/ghi/client.rb
58
51
  - lib/ghi/commands/assign.rb
@@ -75,35 +68,28 @@ files:
75
68
  - lib/ghi/json.rb
76
69
  - lib/ghi/web.rb
77
70
  - lib/ghi.rb
78
- has_rdoc: true
71
+ - bin/ghi
79
72
  homepage: https://github.com/stephencelis/ghi
80
73
  licenses: []
81
-
74
+ metadata: {}
82
75
  post_install_message:
83
76
  rdoc_options: []
84
-
85
- require_paths:
77
+ require_paths:
86
78
  - lib
87
- required_ruby_version: !ruby/object:Gem::Requirement
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- segments:
92
- - 0
93
- version: "0"
94
- required_rubygems_version: !ruby/object:Gem::Requirement
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- segments:
99
- - 0
100
- version: "0"
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
101
89
  requirements: []
102
-
103
90
  rubyforge_project:
104
- rubygems_version: 1.3.6
91
+ rubygems_version: 2.0.3
105
92
  signing_key:
106
- specification_version: 3
93
+ specification_version: 4
107
94
  summary: GitHub Issues command line interface
108
95
  test_files: []
109
-