watson-ruby 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aed185a7a70ff98378f975ffb12794bda13dc75b
4
- data.tar.gz: ad4b6c8f0c1a60d3b2c937650709890289b99a39
3
+ metadata.gz: 6526764e5a9d056f1e208763be9871e9097c7848
4
+ data.tar.gz: 13b5605c8e07c6e05ce2b035180c5327a115cbb6
5
5
  SHA512:
6
- metadata.gz: 2e2a9cb224f671452bd2184151099644d7061ffb8a76fa2808a8234b0f38527ec1cdd8957d385a0f3de3c6290672b928c21b8c2ce831e9f8903f2ad16c1bc870
7
- data.tar.gz: 8f078dd73fc44966cb4c2ffe2df577b3c6ea3fe36923f1ef1783244dfacd5726ec5d446e77943871cd5e8956d40b8031f6cb652ade5b1109ae0f1d79d40e4ae5
6
+ metadata.gz: 385b0d1fc3a4398fa63671ef1e96ac497c2e81924e2d6b8877b1df36bbea08b6e8bfca3edd2c3860a894d970deddd9cf18d51bfa2faf3b237ff569e192c2e70b
7
+ data.tar.gz: ba4a0830d8b1600da0b0506da9cedef1effb4c0cde820cc67d9b3e2261dc42a30c557201aed2a6b0df1e934c321c727da7d23f4c8d86de49661eee40f4870ddf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- watson-ruby (1.1.3)
4
+ watson-ruby (1.2.0)
5
5
  json
6
6
 
7
7
  GEM
data/bin/watson CHANGED
@@ -1,18 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- # [review] - Using own funky path loading because traditional way seems wrong?
5
- # Commented out version is traditional, seen in many apps. If you use that and
6
- # look at load_path you get path/../lib (I'd expect those to be separate?)
7
- # My funky version adds path/., path/bin, path/assets separately
8
- # Maybe I don't get how the load path is supposed to look though...
9
-
10
- #$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
11
- $:.unshift *%w[. assets lib].map { |m| __dir__.gsub(/\/bin(.?)+/, '') + '/' + m }
12
- #p($:)
13
-
14
-
15
- require 'watson'
16
2
 
3
+ lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+ begin
5
+ require 'watson'
6
+ rescue LoadError
7
+ $LOAD_PATH << lib
8
+ require 'watson'
9
+ end
17
10
 
18
11
  Watson::Command.execute(*ARGV)
data/lib/watson/config.rb CHANGED
@@ -48,6 +48,8 @@ module Watson
48
48
  attr_accessor :github_valid
49
49
  # GitHub API key generated from Remote::GitHub setup
50
50
  attr_accessor :github_api
51
+ # GitHub Endpoint (for GitHub Enterprise)
52
+ attr_accessor :github_endpoint
51
53
  # GitHub repo associated with current directory + watson config
52
54
  attr_accessor :github_repo
53
55
  # Hash to hold list of all GitHub issues associated with repo
@@ -104,21 +106,22 @@ module Watson
104
106
  # Remote options
105
107
  @remote_valid = false
106
108
 
107
- @github_valid = false
108
- @github_api = ""
109
- @github_repo = ""
110
- @github_issues = {:open => Hash.new(),
111
- :closed => Hash.new()
112
- }
109
+ @github_valid = false
110
+ @github_api = ""
111
+ @github_endpoint = ""
112
+ @github_repo = ""
113
+ @github_issues = {:open => Hash.new(),
114
+ :closed => Hash.new()
115
+ }
113
116
 
114
117
  # Keep API param (and put username there) for OAuth update later
115
118
  @bitbucket_valid = false
116
119
  @bitbucket_api = ""
117
120
  @bitbucket_pw = ""
118
121
  @bitbucket_repo = ""
119
- @bitbucket_issues = {:open => Hash.new(),
120
- :closed => Hash.new()
121
- }
122
+ @bitbucket_issues = {:open => Hash.new(),
123
+ :closed => Hash.new()
124
+ }
122
125
  end
123
126
 
124
127
 
@@ -362,6 +365,12 @@ module Watson
362
365
  debug_print "GitHub API: #{ @github_api }\n"
363
366
 
364
367
 
368
+ when "github_endpoint"
369
+ # Same as above
370
+ @github_endpoint = _line.chomp!
371
+ debug_print "GitHub Endpoint #{ @github_endpoint }\n"
372
+
373
+
365
374
  when "github_repo"
366
375
  # Same as above
367
376
  @github_repo = _line.chomp!
data/lib/watson/github.rb CHANGED
@@ -31,7 +31,7 @@ module Watson
31
31
  print BOLD + "Obtaining OAuth Token for GitHub...\n" + RESET
32
32
 
33
33
  # Check config to make sure no previous API exists
34
- unless config.github_api.empty? && config.github_repo.empty?
34
+ unless config.github_api.empty? && config.github_repo.empty? && config.github_endpoint.empty?
35
35
  Printer.print_status "!", RED
36
36
  print BOLD + "Previous GitHub API + Repo is in RC, are you sure you want to overwrite?\n" + RESET
37
37
  print " (Y)es/(N)o: "
@@ -39,18 +39,39 @@ module Watson
39
39
  # Get user input
40
40
  _overwrite = $stdin.gets.chomp
41
41
  if ["no", "n"].include?(_overwrite.downcase)
42
- print "\n"
42
+ print "\n\n"
43
43
  Printer.print_status "x", RED
44
44
  print BOLD + "Not overwriting current GitHub API + repo info\n" + RESET
45
45
  return false
46
46
  end
47
47
  end
48
48
 
49
+ print "\n\n"
49
50
 
50
51
  Printer.print_status "!", YELLOW
51
52
  print BOLD + "Access to your GitHub account required to make/update issues\n" + RESET
52
53
  print " See help or README for more details on GitHub/Bitbucket access\n\n"
53
54
 
55
+ Printer.print_status "!", GREEN
56
+ print BOLD + "Is this a GitHub Enterprise account?\n" + RESET
57
+ print " (Y)es/(N)o: "
58
+
59
+ # Get user input
60
+ _enterprise = $stdin.gets.chomp
61
+ if ["yes", "y"].include?(_enterprise.downcase)
62
+ print "\n\n"
63
+ print BOLD + "GitHub API Endpoint: " + RESET
64
+ _endpoint = $stdin.gets.chomp.chomp('/')
65
+ if _endpoint.empty?
66
+ Printer.print_status "x", RED
67
+ print BOLD + "Input blank. Please enter your API endpoint!\n\n" + RESET
68
+ return false
69
+ end
70
+ else
71
+ _endpoint = ''
72
+ end
73
+
74
+ print "\n"
54
75
 
55
76
  # [todo] - Don't just check for blank password but invalid as well
56
77
  # Poor mans username/password grabbing
@@ -75,6 +96,8 @@ module Watson
75
96
  return false
76
97
  end
77
98
 
99
+ _endpoint = "https://api.github.com" if _endpoint.empty?
100
+
78
101
  # HTTP Request to get OAuth Token
79
102
  # GitHub API v3 - http://developer.github.com/v3/
80
103
 
@@ -82,15 +105,15 @@ module Watson
82
105
  # Auth URL for GitHub + SSL
83
106
  # Repo scope + notes for watson
84
107
  # Basic auth with user input
85
- opts = {:url => "https://api.github.com/authorizations",
86
- :ssl => true,
87
- :method => "POST",
88
- :basic_auth => [_username, _password],
89
- :data => {"scopes" => ["repo"],
90
- "note" => "watson",
91
- "note_url" => "http://watson.goosecode.com/" },
92
- :verbose => false
93
- }
108
+ opts = {:url => "#{ _endpoint }/authorizations",
109
+ :ssl => true,
110
+ :method => "POST",
111
+ :basic_auth => [_username, _password],
112
+ :data => {"scopes" => ["repo"],
113
+ "note" => "watson",
114
+ "note_url" => "http://watson.goosecode.com/" },
115
+ :verbose => false
116
+ }
94
117
 
95
118
  _json, _resp = Watson::Remote.http_call(opts)
96
119
 
@@ -105,9 +128,11 @@ module Watson
105
128
  return false
106
129
  end
107
130
 
108
- # Store API key obtained from POST to @config.github_api
131
+ # Store endpoint and API key obtained from POST to @config.github_api
132
+ config.github_endpoint = _endpoint
109
133
  config.github_api = _json["token"]
110
- debug_print "Config GitHub API Key updated to: #{ config.github_api }\n"
134
+ debug_print "Config GitHub API Endpoint updated to: #{ config.github_endpoint }\n"
135
+ debug_print "Config GitHub API Key updated to: #{ config.github_api }\n"
111
136
 
112
137
 
113
138
  # Get repo information, if blank give error
@@ -144,14 +169,14 @@ module Watson
144
169
  # Label URL for GitHub + SSL
145
170
  #
146
171
  # Auth token
147
- opts = {:url => "https://api.github.com/repos/#{ _owner }/#{ _repo }/labels",
148
- :ssl => true,
149
- :method => "POST",
150
- :auth => config.github_api,
151
- :data => {"name" => "watson",
152
- "color" => "00AEEF" },
153
- :verbose => false
154
- }
172
+ opts = {:url => "#{ _endpoint }/repos/#{ _owner }/#{ _repo }/labels",
173
+ :ssl => true,
174
+ :method => "POST",
175
+ :auth => config.github_api,
176
+ :data => {"name" => "watson",
177
+ "color" => "00AEEF" },
178
+ :verbose => false
179
+ }
155
180
 
156
181
  _json, _resp = Watson::Remote.http_call(opts)
157
182
 
@@ -195,14 +220,14 @@ module Watson
195
220
  # All setup has been completed, need to update RC
196
221
  # Call config updater/writer from @config to write config
197
222
  debug_print "Updating config with new GitHub info\n"
198
- config.update_conf("github_api", "github_repo")
223
+ config.update_conf("github_api", "github_repo", "github_endpoint")
199
224
 
200
225
  # Give user some info
201
226
  print "\n"
202
227
  Printer.print_status "o", GREEN
203
228
  print BOLD + "GitHub successfully setup\n" + RESET
204
229
  print " Issues will now automatically be retrieved from GitHub by default\n"
205
- print " Use -p, --push to post issues to GitHub\n"
230
+ print " Use -u, --update to post issues to GitHub\n"
206
231
  print " See help or README for more details on GitHub/Bitbucket access\n\n"
207
232
 
208
233
  return true
@@ -228,12 +253,12 @@ module Watson
228
253
  # Get all open tickets
229
254
  # Create options hash to pass to Remote::http_call
230
255
  # Issues URL for GitHub + SSL
231
- opts = {:url => "https://api.github.com/repos/#{ config.github_repo }/issues?labels=watson&state=open",
232
- :ssl => true,
233
- :method => "GET",
234
- :auth => config.github_api,
235
- :verbose => false
236
- }
256
+ opts = {:url => "#{ config.github_endpoint }/repos/#{ config.github_repo }/issues?labels=watson&state=open",
257
+ :ssl => true,
258
+ :method => "GET",
259
+ :auth => config.github_api,
260
+ :verbose => false
261
+ }
237
262
 
238
263
  _json, _resp = Watson::Remote.http_call(opts)
239
264
 
@@ -256,11 +281,11 @@ module Watson
256
281
  # Get all closed tickets
257
282
  # Create option hash to pass to Remote::http_call
258
283
  # Issues URL for GitHub + SSL
259
- opts = {:url => "https://api.github.com/repos/#{ config.github_repo }/issues?labels=watson&state=closed",
260
- :ssl => true,
261
- :method => "GET",
262
- :auth => config.github_api,
263
- :verbose => false
284
+ opts = {:url => "#{ config.github_endpoint }/repos/#{ config.github_repo }/issues?labels=watson&state=closed",
285
+ :ssl => true,
286
+ :method => "GET",
287
+ :auth => config.github_api,
288
+ :verbose => false
264
289
  }
265
290
 
266
291
  _json, _resp = Watson::Remote.http_call(opts)
@@ -330,22 +355,22 @@ module Watson
330
355
  # Create the body text for the issue here, too long to fit nicely into opts hash
331
356
  # [review] - Only give relative path for privacy when posted
332
357
  _body = "__filename__ : #{ issue[:path] }\n" +
333
- "__line #__ : #{ issue[:line_number] }\n" +
334
- "__tag__ : #{ issue[:tag] }\n" +
335
- "__md5__ : #{ issue[:md5] }\n\n" +
336
- "#{ issue[:context].join }\n"
358
+ "__line #__ : #{ issue[:line_number] }\n" +
359
+ "__tag__ : #{ issue[:tag] }\n" +
360
+ "__md5__ : #{ issue[:md5] }\n\n" +
361
+ "#{ issue[:context].join }\n"
337
362
 
338
363
  # Create option hash to pass to Remote::http_call
339
364
  # Issues URL for GitHub + SSL
340
- opts = {:url => "https://api.github.com/repos/#{ config.github_repo }/issues",
341
- :ssl => true,
342
- :method => "POST",
343
- :auth => config.github_api,
344
- :data => { "title" => issue[:title] + " [#{ issue[:path] }]",
345
- "labels" => [issue[:tag], "watson"],
346
- "body" => _body },
347
- :verbose => false
348
- }
365
+ opts = {:url => "#{ config.github_endpoint }/repos/#{ config.github_repo }/issues",
366
+ :ssl => true,
367
+ :method => "POST",
368
+ :auth => config.github_api,
369
+ :data => { "title" => issue[:title] + " [#{ issue[:path] }]",
370
+ "labels" => [issue[:tag], "watson"],
371
+ "body" => _body },
372
+ :verbose => false
373
+ }
349
374
 
350
375
  _json, _resp = Watson::Remote.http_call(opts)
351
376
 
@@ -1,3 +1,3 @@
1
1
  module Watson
2
- VERSION = "1.1.3"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watson-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nhmood
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-27 00:00:00.000000000 Z
11
+ date: 2013-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json