ghi 0.9.0.20130424 → 0.9.0.20130504
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ghi/client.rb +4 -1
- data/lib/ghi/commands/command.rb +2 -1
- data/lib/ghi/commands/list.rb +6 -0
- data/lib/ghi/commands/show.rb +5 -1
- data/lib/ghi/commands/version.rb +1 -1
- data/lib/ghi/formatting.rb +9 -4
- data/lib/ghi/formatting/colors.rb +5 -1
- data/lib/ghi/web.rb +2 -1
- metadata +3 -3
data/lib/ghi/client.rb
CHANGED
@@ -59,7 +59,8 @@ module GHI
|
|
59
59
|
:patch => Net::HTTP::Patch,
|
60
60
|
:delete => Net::HTTP::Delete
|
61
61
|
}
|
62
|
-
|
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 '&'}"
|
data/lib/ghi/commands/command.rb
CHANGED
@@ -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
|
-
|
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)?$}
|
data/lib/ghi/commands/list.rb
CHANGED
@@ -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|
|
data/lib/ghi/commands/show.rb
CHANGED
data/lib/ghi/commands/version.rb
CHANGED
data/lib/ghi/formatting.rb
CHANGED
@@ -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
|
-
|
125
|
-
", assigned to #{assignee}"
|
128
|
+
", assigned to #{format_username assignee}"
|
126
129
|
end
|
127
130
|
end
|
128
131
|
if mentioned = assigns[:mentioned]
|
129
|
-
|
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] ||
|
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
|
data/lib/ghi/web.rb
CHANGED
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 9
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.9.0.
|
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
|
18
|
+
date: 2013-05-04 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|