ghi 0.9.0.20130424 → 0.9.0.20130504

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.
@@ -59,7 +59,8 @@ module GHI
59
59
  :patch => Net::HTTP::Patch,
60
60
  :delete => Net::HTTP::Delete
61
61
  }
62
- HOST = 'api.github.com'
62
+ DEFAULT_HOST = 'api.github.com'
63
+ HOST = GHI.config('github.host') || DEFAULT_HOST
63
64
  PORT = 443
64
65
 
65
66
  attr_reader :username, :password
@@ -94,6 +95,8 @@ module GHI
94
95
  private
95
96
 
96
97
  def request method, path, options
98
+ path = "/api/v3#{path}" if HOST != DEFAULT_HOST
99
+
97
100
  if params = options[:params] and !params.empty?
98
101
  q = params.map { |k, v| "#{CGI.escape k.to_s}=#{CGI.escape v.to_s}" }
99
102
  path += "?#{q.join '&'}"
@@ -72,7 +72,8 @@ module GHI
72
72
  def remotes
73
73
  return @remotes if defined? @remotes
74
74
  @remotes = `git config --get-regexp remote\..+\.url`.split "\n"
75
- @remotes.reject! { |r| !r.include? 'github.com'}
75
+ github_host = GHI.config('github.host') || 'github.com'
76
+ @remotes.reject! { |r| !r.include? github_host}
76
77
  @remotes.map! { |r|
77
78
  remote, user, repo = r.scan(
78
79
  %r{remote\.([^\.]+)\.url .*?([^:/]+)/([^/\s]+?)(?:\.git)?$}
@@ -81,6 +81,12 @@ module GHI
81
81
  opts.on '--mine', 'assigned to you' do
82
82
  assigns[:assignee] = Authorization.username
83
83
  end
84
+ opts.on(
85
+ '--creator [<user>]', 'created by you or specified user'
86
+ ) do |creator|
87
+ creator = creator.sub /^@/, '' if creator
88
+ assigns[:creator] = creator || Authorization.username
89
+ end
84
90
  opts.on(
85
91
  '-U', '--mentioned [<user>]', 'mentioning you or specified user'
86
92
  ) do |mentioned|
@@ -22,8 +22,12 @@ module GHI
22
22
  else
23
23
  if patch_path
24
24
  i = throb { Web.new(repo).curl patch_path }
25
+ unless i.start_with? 'From'
26
+ warn 'Patch not found'
27
+ abort
28
+ end
25
29
  page do
26
- puts i
30
+ no_color { puts i }
27
31
  break
28
32
  end
29
33
  else
@@ -4,7 +4,7 @@ module GHI
4
4
  MAJOR = 0
5
5
  MINOR = 9
6
6
  PATCH = 0
7
- PRE = 20130424
7
+ PRE = 20130504
8
8
 
9
9
  VERSION = [MAJOR, MINOR, PATCH, PRE].compact.join '.'
10
10
 
@@ -104,6 +104,10 @@ module GHI
104
104
  # Specific formatters:
105
105
  #++
106
106
 
107
+ def format_username username
108
+ username == Authorization.username ? 'you' : username
109
+ end
110
+
107
111
  def format_issues_header
108
112
  state = assigns[:state] || 'open'
109
113
  header = "# #{repo || 'Global,'} #{state} issues"
@@ -121,13 +125,11 @@ module GHI
121
125
  when '*' then ', assigned'
122
126
  when 'none' then ', unassigned'
123
127
  else
124
- assignee = 'you' if Authorization.username == assignee
125
- ", assigned to #{assignee}"
128
+ ", assigned to #{format_username assignee}"
126
129
  end
127
130
  end
128
131
  if mentioned = assigns[:mentioned]
129
- mentioned = 'you' if Authorization.username == mentioned
130
- header << ", mentioning #{mentioned}"
132
+ header << ", mentioning #{format_username mentioned}"
131
133
  end
132
134
  else
133
135
  header << case assigns[:filter]
@@ -138,6 +140,9 @@ module GHI
138
140
  ' assigned to you'
139
141
  end
140
142
  end
143
+ if creator = assigns[:creator]
144
+ header << " #{format_username creator} created"
145
+ end
141
146
  if labels = assigns[:labels]
142
147
  header << ", labeled #{labels.gsub ',', ', '}"
143
148
  end
@@ -220,13 +220,17 @@ module GHI
220
220
  return yield unless color && colorize?
221
221
  previous_escape = Thread.current[:escape] || "\e[0m"
222
222
  escape = Thread.current[:escape] = "\e[%s%sm" % [
223
- layer, ANSI[color] || "8;5;#{to_256(*to_rgb(color))}"
223
+ layer, ANSI[color] || escape_256(color)
224
224
  ]
225
225
  [escape, yield, previous_escape].join
226
226
  ensure
227
227
  Thread.current[:escape] = previous_escape
228
228
  end
229
229
 
230
+ def escape_256 color
231
+ "8;5;#{to_256(*to_rgb(color))}" if ENV['TERM'] =~ /256/
232
+ end
233
+
230
234
  def to_256 r, g, b
231
235
  r, g, b = [r, g, b].map { |c| c / 10 }
232
236
  return 232 + g if r == g && g == b && g != 0 && g != 25
@@ -3,7 +3,8 @@ require 'uri'
3
3
 
4
4
  module GHI
5
5
  class Web
6
- BASE_URI = 'https://github.com/'
6
+ HOST = GHI.config('github.host') || 'github.com'
7
+ BASE_URI = "https://#{HOST}/"
7
8
 
8
9
  attr_reader :base
9
10
  def initialize base
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 9
8
8
  - 0
9
- - 20130424
10
- version: 0.9.0.20130424
9
+ - 20130504
10
+ version: 0.9.0.20130504
11
11
  platform: ruby
12
12
  authors:
13
13
  - Stephen Celis
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-04-24 00:00:00 -07:00
18
+ date: 2013-05-04 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency