razor-client 1.6.1 → 1.7.0

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.
data/NEWS.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Razor Client Release Notes
2
2
 
3
+ ## 1.7.0 - 2018-01-17
4
+
5
+ * NEW: Removed support for Ruby < 2.0
6
+ * BUGFIX: Removed security vulnerabilities in gems
7
+
3
8
  ## 1.4.0 - 2017-03-07
4
9
 
5
10
  * Added support for internationalization by setting the Accept-Language
data/bin/razor CHANGED
@@ -1,14 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # Needed to make the client work on Ruby 1.8.7
4
- unless Kernel.respond_to?(:require_relative)
5
- module Kernel
6
- def require_relative(path)
7
- require File.join(File.dirname(caller[0]), path.to_str)
8
- end
9
- end
10
- end
11
-
12
3
  require 'rubygems'
13
4
  require 'gettext-setup'
14
5
  require_relative "../lib/razor/cli"
@@ -60,10 +51,15 @@ end
60
51
 
61
52
  begin
62
53
  document = parse.navigate.get_document
54
+ p document
63
55
  url = parse.navigate.last_url
64
56
  result = format_document document, parse
65
57
  # TRANSLATORS: This is a template for all results that the client outputs.
66
58
  puts _("From %{url}:\n\n%{result}\n\n") % {url: url, result: result}
59
+ rescue RestClient::Unauthorized
60
+ puts _(<<-UNAUTH) % {url: url}
61
+ Error: Credentials are required to connect to the server at %{url}"
62
+ UNAUTH
67
63
  rescue OptionParser::InvalidOption => e
68
64
  # TRANSLATORS: This occurs when invalid flags are passed in the navigation.
69
65
  die _("%{error}\nTry 'razor --help' for more information") %
@@ -79,6 +75,7 @@ rescue RestClient::SSLCertificateNotVerified
79
75
  rescue RestClient::Exception => e
80
76
  r = e.response
81
77
  unexpected_error(e) if r.nil?
78
+ p r.methods
82
79
  request_type = r.args[:method].to_s.upcase
83
80
  url = r.args[:url]
84
81
  puts _("Error from doing %{request_type} %{url}") % {request_type: request_type, url: url}
@@ -3,42 +3,6 @@ require 'multi_json'
3
3
  require 'yaml'
4
4
  require 'forwardable'
5
5
 
6
- # Needed to make the client work on Ruby 1.8.7
7
- unless URI.respond_to?(:encode_www_form)
8
- module URI
9
- def self.encode_www_form_component(str)
10
- str = str.to_s
11
- if HTML5ASCIIINCOMPAT.include?(str.encoding)
12
- str = str.encode(Encoding::UTF_8)
13
- else
14
- str = str.dup
15
- end
16
- str.force_encoding(Encoding::ASCII_8BIT)
17
- str.gsub!(/[^*\-.0-9A-Z_a-z]/, TBLENCWWWCOMP_)
18
- str.force_encoding(Encoding::US_ASCII)
19
- end
20
- def self.encode_www_form(enum)
21
- enum.map do |k,v|
22
- if v.nil?
23
- encode_www_form_component(k)
24
- elsif v.respond_to?(:to_ary)
25
- v.to_ary.map do |w|
26
- str = encode_www_form_component(k)
27
- unless w.nil?
28
- str << '='
29
- str << encode_www_form_component(w)
30
- end
31
- end.join('&')
32
- else
33
- str = encode_www_form_component(k)
34
- str << '='
35
- str << encode_www_form_component(v)
36
- end
37
- end.join('&')
38
- end
39
- end
40
- end
41
-
42
6
  module Razor::CLI
43
7
  class Navigate
44
8
  extend Forwardable
@@ -47,7 +11,6 @@ module Razor::CLI
47
11
  @parse = parse
48
12
  @segments = segments||[]
49
13
  @doc = entrypoint
50
- @username, @password = parse.api_url.userinfo.to_s.split(':')
51
14
  @doc_resource = create_resource parse.api_url, {:accept => :json,
52
15
  :accept_language => accept_language}
53
16
  end
@@ -160,6 +123,8 @@ module Razor::CLI
160
123
  # Add extra parameters to URL.
161
124
  url.query = URI.encode_www_form(params)
162
125
  url.query = nil if url.query.empty? # Remove dangling '?' from URL.
126
+ @username ||= url.user
127
+ @password ||= url.password
163
128
 
164
129
  response = get(url,headers.merge(:accept => :json,
165
130
  :accept_language => accept_language))
@@ -170,6 +135,9 @@ module Razor::CLI
170
135
  end
171
136
 
172
137
  def json_post(url, body)
138
+ @username ||= url.user
139
+ @password ||= url.password
140
+
173
141
  headers = { :accept=>:json, "Content-Type" => :json,
174
142
  :accept_language => accept_language}
175
143
  begin
@@ -187,11 +155,13 @@ module Razor::CLI
187
155
  private
188
156
 
189
157
  def create_resource(url, headers)
190
- @doc_resource = RestClient::Resource.new(url.to_s, :headers => headers,
191
- :verify_ssl => @parse.verify_ssl?,
192
- :ssl_ca_file => @parse.ssl_ca_file,
193
- :user => @username,
194
- :password => @password)
158
+ @doc_resource = RestClient::Resource.new(url.to_s,
159
+ :headers => headers,
160
+ :verify_ssl => @parse.verify_ssl?,
161
+ :ssl_ca_file => @parse.ssl_ca_file,
162
+ # Add these in case the URL above doesn't include authentication.
163
+ :user => @username || url.user,
164
+ :password => @password || url.password)
195
165
  end
196
166
  end
197
167
  end
@@ -18,7 +18,7 @@ module Razor
18
18
  #
19
19
  # The next line is the one that our packaging tools modify, so please make
20
20
  # sure that any change to it is discussed and agreed first.
21
- version = '1.6.1'
21
+ version = '1.7.0'
22
22
 
23
23
  if version == "DEVELOPMENT"
24
24
  root = File.expand_path("../../..", File.dirname(__FILE__))
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: http://fred:dead@localhost:8150/api
5
+ uri: http://localhost:8150/api
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -35,7 +35,7 @@ http_interactions:
35
35
  recorded_at: Mon, 09 Mar 2015 19:54:50 GMT
36
36
  - request:
37
37
  method: get
38
- uri: http://fred:dead@localhost:8150/api/collections/tags
38
+ uri: http://localhost:8150/api/collections/tags
39
39
  body:
40
40
  encoding: US-ASCII
41
41
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: http://fred:dead@localhost:8150/api
5
+ uri: http://localhost:8150/api
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: http://fred:dead@localhost:8150/api
5
+ uri: http://localhost:8150/api
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -35,7 +35,7 @@ http_interactions:
35
35
  recorded_at: Mon, 09 Mar 2015 19:54:56 GMT
36
36
  - request:
37
37
  method: get
38
- uri: http://fred:dead@localhost:8150/api/collections/events?limit=1
38
+ uri: http://localhost:8150/api/collections/events?limit=1
39
39
  body:
40
40
  encoding: US-ASCII
41
41
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: http://fred:dead@localhost:8150/api
5
+ uri: http://localhost:8150/api
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -35,7 +35,7 @@ http_interactions:
35
35
  recorded_at: Mon, 09 Mar 2015 19:55:01 GMT
36
36
  - request:
37
37
  method: get
38
- uri: http://fred:dead@localhost:8150/api/collections/events?start=1
38
+ uri: http://localhost:8150/api/collections/events?start=1
39
39
  body:
40
40
  encoding: US-ASCII
41
41
  string: ''
@@ -213,7 +213,7 @@ http_interactions:
213
213
  recorded_at: Mon, 09 Mar 2015 19:55:12 GMT
214
214
  - request:
215
215
  method: get
216
- uri: http://fred:dead@localhost:8150/api
216
+ uri: http://localhost:8150/api
217
217
  body:
218
218
  encoding: US-ASCII
219
219
  string: ''
@@ -246,7 +246,7 @@ http_interactions:
246
246
  recorded_at: Mon, 09 Mar 2015 19:55:12 GMT
247
247
  - request:
248
248
  method: get
249
- uri: http://fred:dead@localhost:8150/api/collections/nodes
249
+ uri: http://localhost:8150/api/collections/nodes
250
250
  body:
251
251
  encoding: US-ASCII
252
252
  string: ''
@@ -279,7 +279,7 @@ http_interactions:
279
279
  recorded_at: Mon, 09 Mar 2015 19:55:12 GMT
280
280
  - request:
281
281
  method: get
282
- uri: http://fred:dead@localhost:8150/api/collections/nodes/node1
282
+ uri: http://localhost:8150/api/collections/nodes/node1
283
283
  body:
284
284
  encoding: US-ASCII
285
285
  string: ''
@@ -424,7 +424,7 @@ http_interactions:
424
424
  recorded_at: Mon, 09 Mar 2015 19:55:24 GMT
425
425
  - request:
426
426
  method: get
427
- uri: http://fred:dead@localhost:8150/api
427
+ uri: http://localhost:8150/api
428
428
  body:
429
429
  encoding: US-ASCII
430
430
  string: ''
@@ -457,7 +457,7 @@ http_interactions:
457
457
  recorded_at: Mon, 09 Mar 2015 19:55:24 GMT
458
458
  - request:
459
459
  method: get
460
- uri: http://fred:dead@localhost:8150/api/collections/nodes
460
+ uri: http://localhost:8150/api/collections/nodes
461
461
  body:
462
462
  encoding: US-ASCII
463
463
  string: ''
@@ -490,7 +490,7 @@ http_interactions:
490
490
  recorded_at: Mon, 09 Mar 2015 19:55:24 GMT
491
491
  - request:
492
492
  method: get
493
- uri: http://fred:dead@localhost:8150/api/collections/nodes/node1
493
+ uri: http://localhost:8150/api/collections/nodes/node1
494
494
  body:
495
495
  encoding: US-ASCII
496
496
  string: ''
@@ -523,7 +523,7 @@ http_interactions:
523
523
  recorded_at: Mon, 09 Mar 2015 19:55:24 GMT
524
524
  - request:
525
525
  method: get
526
- uri: http://fred:dead@localhost:8150/api/collections/nodes/node1/log?limit=1
526
+ uri: http://localhost:8150/api/collections/nodes/node1/log?limit=1
527
527
  body:
528
528
  encoding: US-ASCII
529
529
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: http://fred:dead@localhost:8150/api
5
+ uri: http://localhost:8150/api
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -213,7 +213,7 @@ http_interactions:
213
213
  recorded_at: Mon, 09 Mar 2015 19:55:18 GMT
214
214
  - request:
215
215
  method: get
216
- uri: http://fred:dead@localhost:8150/api
216
+ uri: http://localhost:8150/api
217
217
  body:
218
218
  encoding: US-ASCII
219
219
  string: ''
@@ -246,7 +246,7 @@ http_interactions:
246
246
  recorded_at: Mon, 09 Mar 2015 19:55:18 GMT
247
247
  - request:
248
248
  method: get
249
- uri: http://fred:dead@localhost:8150/api/collections/nodes
249
+ uri: http://localhost:8150/api/collections/nodes
250
250
  body:
251
251
  encoding: US-ASCII
252
252
  string: ''
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: razor-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.7.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-03-07 00:00:00.000000000 Z
12
+ date: 2018-01-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mime-types