watson-ruby 1.5.0 → 1.5.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da9382974aee60af64d71f1cc6a63f594330cc12
4
- data.tar.gz: 7cb4dbb672ffa04412ae1198ac79c97f0bab6643
3
+ metadata.gz: 2cb1804dead00fc6ed4ccfc616c4551473fa2376
4
+ data.tar.gz: 0a56d91f93d36ae4ed03cfec5a3cd0e27779400f
5
5
  SHA512:
6
- metadata.gz: f5646b1f3b0db3fd820369e7dcb6727d235cec7bdc5be8bcb3fb2d4656265b5611f8be47dc48603f89e8a5206a3156e972b914e6b600b5fcc0b256d8baf16a6b
7
- data.tar.gz: 3f17083485b7efee7672483ca889ba23af2fa2811573d2834d31ba2bb5c47f28dee279c5e338627004cdfb7605efa4dc12382ec1cf4c6e132d7884c962fe6248
6
+ metadata.gz: 1ccdce1f3dd140fc82a608c69a0a0ab12b2d7e9750efb6f7582230f8f6567f52e9720965224131e328342b6975a1e3f36846525d5c9c45f8f8ba2ac487e595cd
7
+ data.tar.gz: 5291bd22fa3a29657864492e90e24404fa0a968e783866092ec5406dd073cceef991a5b956b83c226b23d55ad7cc526683076062f7b1b9bafe085f41186e6c76
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- watson-ruby (1.5.0)
4
+ watson-ruby (1.5.1)
5
5
  json
6
6
 
7
7
  GEM
@@ -321,7 +321,7 @@ module Watson
321
321
  when "context_depth"
322
322
  # No need for regex on context value, command should read this in only as a #
323
323
  # Chomp to get rid of any nonsense
324
- @context_depth = _line.chomp!
324
+ @context_depth = _line.chomp!.to_i
325
325
 
326
326
 
327
327
  when "parse_depth"
@@ -128,6 +128,14 @@ module Watson
128
128
  if _resp.code == "201"
129
129
  formatter.print_status "o", GREEN
130
130
  print BOLD + "Obtained OAuth Token\n\n" + RESET
131
+
132
+ elsif _resp.code == "401"
133
+ begin
134
+ # [todo] - Refactor all
135
+ _json, _resp = two_factor_authentication(opts, formatter)
136
+ rescue => e
137
+ return false
138
+ end
131
139
  else
132
140
  formatter.print_status "x", RED
133
141
  print BOLD + "Unable to obtain OAuth Token\n" + RESET
@@ -381,6 +389,39 @@ module Watson
381
389
  return true
382
390
  end
383
391
 
392
+ private
393
+
394
+ def two_factor_authentication(opts, formatter)
395
+ print "\n"
396
+ print "Two Factor Authentication has been enabled for this account.\n"
397
+ print BOLD + "Code: " + RESET
398
+ system "stty -echo"
399
+ _authcode = $stdin.gets.chomp
400
+ system "stty echo"
401
+ print "\n\n"
402
+ if _authcode.empty?
403
+ formatter.print_status "x", RED
404
+ print BOLD + "Input is blank. Please enter your Two Factor Authentication Code!\n\n" + RESET
405
+ return false
406
+ end
407
+ opts[:headers] = [ { :field => "X-GitHub-OTP", :value => _authcode } ]
408
+ _json, _resp = Remote.http_call(opts)
409
+ if _resp.code == "201"
410
+ formatter.print_status "o", GREEN
411
+ print BOLD + "Obtained OAuth Token\n\n" + RESET
412
+ return [_json, _resp]
413
+ elsif _resp.code == "401"
414
+ formatter.print_status "x", RED
415
+ print BOLD + "Unable to obtain OAuth Token\n" + RESET
416
+ print " Authentication Code Incorrect!\n\n"
417
+ false
418
+ else
419
+ formatter.print_status "x", RED
420
+ print BOLD + "Unable to obtain OAuth Token\n" + RESET
421
+ print " Status: #{ _resp.code } - #{ _resp.message }\n\n"
422
+ false
423
+ end
424
+ end
384
425
  end
385
426
  end
386
427
  end
@@ -84,8 +84,8 @@ module Watson
84
84
  debug_print "Parsing through all files/directories in #{ dir }\n"
85
85
 
86
86
  # [review] - Shifted away from single Dir.glob loop to separate for dir/file
87
- # This duplicates code but is much better for readability
88
- # Not sure which is preferred?
87
+ # This duplicates code but is much better for readability
88
+ # Not sure which is preferred?
89
89
 
90
90
 
91
91
  # Remove leading . or ./
@@ -147,12 +147,12 @@ module Watson
147
147
  if @config.parse_depth == 0
148
148
  debug_print "No max depth, parsing directory\n"
149
149
  _completed_dirs.push(parse_dir("#{ _entry }/", _cur_depth))
150
-
150
+
151
151
  # If current depth is less than limit (set in config), parse directory and pass depth
152
152
  elsif _cur_depth < @config.parse_depth.to_i + 1
153
153
  debug_print "Depth less than max dept (from config), parsing directory\n"
154
154
  _completed_dirs.push(parse_dir("#{ _entry }/", _cur_depth))
155
-
155
+
156
156
  # Else, depth is greater than limit, ignore the directory
157
157
  else
158
158
  debug_print "Depth greater than max depth, ignoring\n"
@@ -334,7 +334,7 @@ module Watson
334
334
 
335
335
  # If GitHub is valid, pass _issue to GitHub poster function
336
336
  # [review] - Keep Remote as a static method and pass config every time?
337
- # Or convert to a regular class and make an instance with @config
337
+ # Or convert to a regular class and make an instance with @config
338
338
 
339
339
 
340
340
  # [review] - Use _tag string as symbol reference in hash or keep as string?
@@ -380,6 +380,7 @@ module Watson
380
380
  '.class' => ['//', '/*', '/**'],
381
381
  '.cs' => ['//', '/*'], # C#
382
382
  '.scss' => ['//', '/*'], # SASS SCSS
383
+ '.sass' => ['//', '/*'], # SASS SCSS
383
384
  '.js' => ['//', '/*'], # JavaScript
384
385
  '.php' => ['//', '/*', '#'], # PHP
385
386
  '.m' => ['//', '/*'], # ObjectiveC
@@ -403,6 +404,8 @@ module Watson
403
404
  '.clj' => [';;'], # Clojure
404
405
  '.sql' => ['---', '//', '#' ], # SQL and PL types
405
406
  '.lua' => ['--', '--[['], # Lua
407
+ '.vim' => ['"'], # VimL
408
+ '.md' => ['<!--'], # Markdown
406
409
  '.html' => ['<!--'] # HTML
407
410
  }
408
411
 
@@ -1,3 +1,3 @@
1
1
  module Watson
2
- VERSION = "1.5.0"
2
+ VERSION = "1.5.1"
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.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - nhmood
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-10 00:00:00.000000000 Z
11
+ date: 2013-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json