razor-client 1.3.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/NEWS.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Razor Client Release Notes
2
2
 
3
+ ## 1.4.0 - 2017-03-07
4
+
5
+ * Added support for internationalization by setting the Accept-Language
6
+ header for API requests.
7
+
3
8
  ## 1.3.0 - 2016-05-19
4
9
 
5
10
  * NEW: Added elegant display of the `razor config` collection.
data/bin/razor CHANGED
@@ -10,12 +10,16 @@ unless Kernel.respond_to?(:require_relative)
10
10
  end
11
11
 
12
12
  require 'rubygems'
13
+ require 'gettext-setup'
13
14
  require_relative "../lib/razor/cli"
14
15
 
16
+ GettextSetup.initialize(File.absolute_path('locales', File.dirname(File.dirname(__FILE__))))
17
+ FastGettext.locale = GettextSetup.negotiate_locale(GettextSetup.candidate_locales)
18
+
15
19
  include Razor::CLI::Format
16
20
 
17
21
  def die(message = nil)
18
- puts "Error: #{message}" if message
22
+ puts _("Error: %{error}") % {error: message} if message
19
23
  exit 1
20
24
  end
21
25
 
@@ -24,7 +28,7 @@ begin
24
28
  rescue Razor::CLI::InvalidURIError => e
25
29
  die e.message
26
30
  rescue OptionParser::InvalidOption => e
27
- die e.message + "\nTry 'razor --help' for more information"
31
+ die _("%{error}\nTry 'razor --help' for more information") % {error: e.message}
28
32
  end
29
33
 
30
34
  if parse.show_version?
@@ -40,14 +44,13 @@ if parse.show_help? and not parse.show_command_help?
40
44
  end
41
45
 
42
46
  def unexpected_error(e)
43
- die <<-ERROR
47
+ die _(<<-ERROR) % {backtrace: e.backtrace.take(10).join("\n"), error: e}
44
48
  An unexpected error has occurred.
45
49
 
46
50
  Backtrace:
47
- #{e.backtrace.take(10).join('
48
- ')}
51
+ %{backtrace}
49
52
 
50
- Error: #{e}
53
+ Error: %{error}
51
54
 
52
55
  Please inspect server logs for the cause, then report issue to:
53
56
  https://tickets.puppetlabs.com/browse/RAZOR
@@ -58,22 +61,27 @@ end
58
61
  begin
59
62
  document = parse.navigate.get_document
60
63
  url = parse.navigate.last_url
61
- puts "From #{url}:\n\n#{format_document document, parse}\n\n"
64
+ result = format_document document, parse
65
+ # TRANSLATORS: This is a template for all results that the client outputs.
66
+ puts _("From %{url}:\n\n%{result}\n\n") % {url: url, result: result}
62
67
  rescue OptionParser::InvalidOption => e
63
- # Occurs when invalid flags are passed in the navigation.
64
- die e.message + "\nTry 'razor --help' for more information"
68
+ # TRANSLATORS: This occurs when invalid flags are passed in the navigation.
69
+ die _("%{error}\nTry 'razor --help' for more information") %
70
+ {error: e.message}
65
71
  rescue SocketError, Errno::ECONNREFUSED => e
66
- puts "Error: Could not connect to the server at #{parse.api_url}"
67
- puts " #{e}\n"
72
+ puts _("Error: Could not connect to the server at %{url}\n" +
73
+ " %{error}") % {url: parse.api_url, error: e}
68
74
  die
69
75
  rescue RestClient::SSLCertificateNotVerified
70
- puts "Error: SSL certificate could not be verified against known CA certificates."
71
- puts " To turn off verification, use the -k or --insecure option."
76
+ puts _("Error: SSL certificate could not be verified against known CA " +
77
+ "certificates.\n To turn off verification, use the -k or --insecure option.")
72
78
  die
73
79
  rescue RestClient::Exception => e
74
80
  r = e.response
75
81
  unexpected_error(e) if r.nil?
76
- puts "Error from doing #{r.args[:method].to_s.upcase} #{r.args[:url]}"
82
+ request_type = r.args[:method].to_s.upcase
83
+ url = r.args[:url]
84
+ puts _("Error from doing %{request_type} %{url}") % {request_type: request_type, url: url}
77
85
  puts e.message
78
86
  begin
79
87
  body = MultiJson::load(r.body)
@@ -88,5 +96,5 @@ rescue RestClient::Exception => e
88
96
  end
89
97
  die
90
98
  rescue StandardError => e
91
- die "#{e.message}\nTry 'razor --help' for more information\n\n"
99
+ die _("%{error}\nTry 'razor --help' for more information\n\n") % {error: e.message}
92
100
  end
@@ -6,9 +6,9 @@ module Razor
6
6
  def initialize(url, key, doc)
7
7
  @key = key; @doc = doc
8
8
  if key.is_a?(Array)
9
- super "Could not navigate to '#{key.join(" ")}' from #{url}"
9
+ super _("Could not navigate to '%{path}' from %{url}") % {path: key.join(" "), url: url}
10
10
  else
11
- super "Could not find entry '#{key}' in document at #{url}"
11
+ super _("Could not find entry '%{key}' in document at %{url}") % {key: key, url: url}
12
12
  end
13
13
  end
14
14
  end
@@ -17,24 +17,24 @@ module Razor
17
17
  def initialize(url, type)
18
18
  case type
19
19
  when :env
20
- super "URL '#{url}' in ENV variable RAZOR_API is not valid"
20
+ super _("URL '%{url}' in ENV variable RAZOR_API is not valid") % {url: url}
21
21
  when :opts
22
- super "URL '#{url}' provided by -u or --url is not valid"
22
+ super _("URL '%{url}' provided by -u or --url is not valid") % {url: url}
23
23
  else
24
- super "URL '#{url}' is not valid"
24
+ super _("URL '%{url}' is not valid") % {url: url}
25
25
  end
26
26
  end
27
27
  end
28
28
 
29
29
  class InvalidCAFileError < Error
30
30
  def initialize(path)
31
- super "CA file '#{path}' in ENV variable RAZOR_CA_FILE does not exist"
31
+ super _("CA file '%{path}' in ENV variable RAZOR_CA_FILE does not exist") % {path: path}
32
32
  end
33
33
  end
34
34
 
35
35
  class VersionCompatibilityError < Error
36
36
  def initialize(reason)
37
- super "Server version is not compatible with client version: #{reason}"
37
+ super _("Server version is not compatible with client version: %{reason}") % {reason: reason}
38
38
  end
39
39
  end
40
40
 
@@ -16,7 +16,7 @@ class Razor::CLI::Command
16
16
  else
17
17
  if body.empty?
18
18
  raise Razor::CLI::Error,
19
- "No arguments for command (did you forget --json ?)"
19
+ _("No arguments for command (did you forget --json ?)")
20
20
  end
21
21
  result = @navigate.json_post(@cmd_url, body)
22
22
  # Get actual object from the id.
@@ -41,11 +41,11 @@ class Razor::CLI::Command
41
41
  elsif argument =~ /\A-([a-z-]{2,})(=(.+))?\Z/ and
42
42
  @cmd_schema[self.class.resolve_alias($1, @cmd_schema)]
43
43
  # Short form, should be long; offer suggestion
44
- raise ArgumentError, "Unexpected argument #{argument} (did you mean --#{$1}?)"
44
+ raise ArgumentError, _("Unexpected argument %{argument} (did you mean %{suggestion}?)") % {argument: argument, suggestion: "--#{$1}"}
45
45
  elsif argument =~ /\A--([a-z])(=(.+))?\Z/ and
46
46
  @cmd_schema[self.class.resolve_alias($1, @cmd_schema)]
47
47
  # Long form, should be short; offer suggestion
48
- raise ArgumentError, "Unexpected argument #{argument} (did you mean -#{$1}?)"
48
+ raise ArgumentError, _("Unexpected argument %{argument} (did you mean %{suggestion}?)") % {argument: argument, suggestion: "-#{$1}"}
49
49
  else
50
50
  # This may be a positional argument.
51
51
  arg_name = positional_argument(@cmd_schema, pos_index)
@@ -53,7 +53,7 @@ class Razor::CLI::Command
53
53
  body[arg_name] = self.class.convert_arg(arg_name, argument, body[arg_name], @cmd_schema)
54
54
  pos_index += 1
55
55
  else
56
- raise ArgumentError, "Unexpected argument #{argument}"
56
+ raise ArgumentError, _("Unexpected argument %{argument}") % {argument: argument}
57
57
  end
58
58
  end
59
59
  end
@@ -61,12 +61,12 @@ class Razor::CLI::Command
61
61
  begin
62
62
  body = MultiJson::load(File::read(body["json"])) if body["json"]
63
63
  rescue MultiJson::LoadError
64
- raise Razor::CLI::Error, "File #{body["json"]} is not valid JSON"
64
+ raise Razor::CLI::Error, _("File %{path} is not valid JSON") % {path: body['json']}
65
65
  rescue Errno::ENOENT
66
- raise Razor::CLI::Error, "File #{body["json"]} not found"
66
+ raise Razor::CLI::Error, _("File %{path} not found") % {path: body['json']}
67
67
  rescue Errno::EACCES
68
68
  raise Razor::CLI::Error,
69
- "Permission to read file #{body["json"]} denied"
69
+ _("Permission to read file %{path} denied") % {path: body['json']}
70
70
  end
71
71
  body
72
72
  end
@@ -99,7 +99,8 @@ class Razor::CLI::Command
99
99
  argument_type = arg_type(arg_name, cmd_schema)
100
100
 
101
101
  # This might be helpful, since there's no other method for debug-level logging on the client.
102
- puts "Formatting argument #{arg_name} with value #{value} as #{argument_type}\n" if @dump_response
102
+ puts _("Formatting argument %{argument_name} with value %{value} as %{argument_type}\n") %
103
+ {argument_name: arg_name, value: value, argument_type: argument_type} if @dump_response
103
104
 
104
105
  case argument_type
105
106
  when "array"
@@ -117,12 +118,13 @@ class Razor::CLI::Command
117
118
  existing_value.merge($1 => $2)
118
119
  else
119
120
  MultiJson::load(value).tap do |value|
120
- value.is_a?(Hash) or raise ArgumentError, "Invalid object for argument '#{arg_name}'"
121
+ value.is_a?(Hash) or raise ArgumentError, _("Invalid object for argument '%{argument_name}'") % {argument_name: arg_name}
121
122
  existing_value.merge(value)
122
123
  end
123
124
  end
124
125
  rescue MultiJson::LoadError => error
125
- raise ArgumentError, "Invalid object for argument '#{arg_name}': #{error.message}"
126
+ raise ArgumentError, _("Invalid object for argument '%{argument_name}': %{error}") %
127
+ {argument_name: arg_name, error: error.message}
126
128
  end
127
129
  when "boolean"
128
130
  ["true", nil].include?(value)
@@ -130,15 +132,16 @@ class Razor::CLI::Command
130
132
  begin
131
133
  Integer(value)
132
134
  rescue ArgumentError
133
- raise ArgumentError, "Invalid integer for argument '#{arg_name}': #{value}"
135
+ raise ArgumentError, _("Invalid integer for argument '%{arg_name}': %{value}") % {argument_name: arg_name, value: value}
134
136
  end
135
137
  when "null"
136
- raise ArgumentError, "Expected nothing for argument '#{arg_name}', but was: '#{value}'" unless value.nil?
138
+ raise ArgumentError, _("Expected nothing for argument '%{arg_name}', but was: '%{value}'") %
139
+ {argument_name: arg_name, value: value} unless value.nil?
137
140
  nil
138
141
  when "string", nil # `nil` for 'might be an alias, send as-is'
139
142
  value
140
143
  else
141
- raise Razor::CLI::Error, "Unexpected datatype '#{argument_type}' for argument #{arg_name}"
144
+ raise Razor::CLI::Error, _("Unexpected datatype '%{argument_type}' for argument %{argument_name}") % {argument_type: argument_type, argument_name: arg_name}
142
145
  end
143
146
  end
144
147
 
@@ -23,7 +23,7 @@ module Razor::CLI
23
23
  arguments = parse && parse.stripped_args
24
24
  doc = Razor::CLI::Document.new(doc, format)
25
25
 
26
- return "There are no items for this query." if doc.items.empty?
26
+ return _("There are no items for this query.") if doc.items.empty?
27
27
  return format_command_help(doc, parse.show_api_help?) if parse && parse.show_command_help?
28
28
 
29
29
  case (doc.format_view['+layout'] or 'list')
@@ -36,7 +36,7 @@ module Razor::CLI
36
36
  else doc.to_s
37
37
  end
38
38
  else
39
- raise ArgumentError, "Unrecognized view format #{doc.format_view['+layout']}"
39
+ raise ArgumentError, _("Unrecognized view format %{format_name}") % {format_name: doc.format_view['+layout']}
40
40
  end
41
41
  end
42
42
 
@@ -64,7 +64,7 @@ module Razor::CLI
64
64
 
65
65
  def format_command_help(doc, show_api_help)
66
66
  item = doc.items.first
67
- raise Razor::CLI::Error, 'Could not find help for that entry' unless item.has_key?('help')
67
+ raise Razor::CLI::Error, _('Could not find help for that entry') unless item.has_key?('help')
68
68
  if item['help'].has_key?('examples')
69
69
  if show_api_help && item['help']['examples'].has_key?('api')
70
70
  format_composed_help(item, item['help']['examples']['api']).chomp
@@ -85,31 +85,31 @@ module Razor::CLI
85
85
  def format_composed_help(object, examples = object['help']['examples']['cli'])
86
86
  help_obj = object['help']
87
87
  ret = ''
88
- ret = ret + <<-USAGE
88
+ ret = ret + _(<<-USAGE) % {command: object['name'], arguments: positional_args_usage(object)}
89
89
  # USAGE
90
90
 
91
- razor #{object['name']} #{positional_args_usage(object)} <flags>
91
+ razor %{command} %{arguments} <flags>
92
92
 
93
93
  USAGE
94
- ret = ret + <<-SYNOPSIS if help_obj.has_key?('summary')
94
+ ret = ret + _(<<-SYNOPSIS) % {summary: help_obj['summary']} if help_obj.has_key?('summary')
95
95
  # SYNOPSIS
96
- #{help_obj['summary']}
96
+ %{summary}
97
97
 
98
98
  SYNOPSIS
99
- ret = ret + <<-DESCRIPTION if help_obj.has_key?('description')
99
+ ret = ret + _(<<-DESCRIPTION) % {description: help_obj['description'], schema: help_obj['schema']} if help_obj.has_key?('description')
100
100
  # DESCRIPTION
101
- #{help_obj['description']}
101
+ %{description}
102
102
 
103
- #{help_obj['schema']}
103
+ %{schema}
104
104
  DESCRIPTION
105
- ret = ret + <<-RETURNS if help_obj.has_key?('returns')
105
+ ret = ret + _(<<-RETURNS) % {returns: help_obj['returns'].gsub(/^/, ' ')} if help_obj.has_key?('returns')
106
106
  # RETURNS
107
- #{help_obj['returns'].gsub(/^/, ' ')}
107
+ %{returns}
108
108
  RETURNS
109
- ret = ret + <<-EXAMPLES if examples
109
+ ret = ret + _(<<-EXAMPLES) % {examples: examples.gsub(/^/, ' ')} if examples
110
110
  # EXAMPLES
111
111
 
112
- #{examples.gsub(/^/, ' ')}
112
+ %{examples}
113
113
  EXAMPLES
114
114
  ret
115
115
  end
@@ -160,7 +160,7 @@ module Razor::CLI
160
160
  ""
161
161
  elsif doc.is_list? and objects.all? { |it| it.is_a?(Hash) && it.has_key?('name')}
162
162
  # If every element has the 'name' key, it has nested elements.
163
- "\n\nQuery an entry by including its name, e.g. `razor #{arguments.join(' ')} #{objects.first['name']}`"
163
+ _("\n\nQuery an entry by including its name, e.g. `razor %{arguments} %{name}`") % {arguments: arguments.join(' '), name: objects.first['name']}
164
164
  elsif objects.any?
165
165
  object = objects.first
166
166
  fields = display_fields(object) - PriorityKeys
@@ -168,7 +168,7 @@ module Razor::CLI
168
168
  object[f].is_a?(Hash) or object[f].is_a?(Array)
169
169
  end.sort
170
170
  if list.any?
171
- "\n\nQuery additional details via: `razor #{arguments.join(' ')} [#{list.join(', ')}]`"
171
+ _("\n\nQuery additional details via: `razor %{arguments} [%{options}]`") % {arguments: arguments.join(' '), options: list.join(', ')}
172
172
  end
173
173
  end
174
174
  end
@@ -48,7 +48,8 @@ module Razor::CLI
48
48
  @segments = segments||[]
49
49
  @doc = entrypoint
50
50
  @username, @password = parse.api_url.userinfo.to_s.split(':')
51
- @doc_resource = create_resource parse.api_url, {:accept => :json}
51
+ @doc_resource = create_resource parse.api_url, {:accept => :json,
52
+ :accept_language => accept_language}
52
53
  end
53
54
 
54
55
  attr_accessor :doc_resource
@@ -70,7 +71,7 @@ module Razor::CLI
70
71
  end
71
72
 
72
73
  def server_version
73
- entrypoint.has_key?('version') and entrypoint['version']['server'] or 'Unknown'
74
+ entrypoint.has_key?('version') and entrypoint['version']['server'] or _('Unknown')
74
75
  end
75
76
 
76
77
  def query?
@@ -144,6 +145,10 @@ module Razor::CLI
144
145
  end
145
146
  end
146
147
 
148
+ def accept_language
149
+ @accept_language ||= GettextSetup.candidate_locales
150
+ end
151
+
147
152
  def get(url, headers={})
148
153
  resource = create_resource(url, headers)
149
154
  response = resource.get
@@ -156,22 +161,24 @@ module Razor::CLI
156
161
  url.query = URI.encode_www_form(params)
157
162
  url.query = nil if url.query.empty? # Remove dangling '?' from URL.
158
163
 
159
- response = get(url,headers.merge(:accept => :json))
164
+ response = get(url,headers.merge(:accept => :json,
165
+ :accept_language => accept_language))
160
166
  unless response.headers[:content_type] =~ /application\/json/
161
- raise "Received content type #{response.headers[:content_type]}"
167
+ raise _("Received content type %{content_type}") % {content_type: response.headers[:content_type]}
162
168
  end
163
169
  MultiJson.load(response.body)
164
170
  end
165
171
 
166
172
  def json_post(url, body)
167
- headers = { :accept=>:json, "Content-Type" => :json }
173
+ headers = { :accept=>:json, "Content-Type" => :json,
174
+ :accept_language => accept_language}
168
175
  begin
169
176
  resource = create_resource(url, headers)
170
177
  response = resource.post MultiJson::dump(body)
171
178
  ensure
172
179
  if @parse.dump_response?
173
180
  print "POST #{url.to_s}\n#{body}\n-->\n"
174
- puts (response ? response.body : "ERROR")
181
+ puts (response ? response.body : _("ERROR"))
175
182
  end
176
183
  end
177
184
  MultiJson::load(response.body)
@@ -22,32 +22,32 @@ module Razor::CLI
22
22
 
23
23
  def get_optparse
24
24
  @optparse ||= OptionParser.new do |opts|
25
- opts.banner = "Usage: razor [FLAGS] NAVIGATION\n"
25
+ opts.banner = _("Usage: razor [FLAGS] NAVIGATION\n")
26
26
 
27
- opts.on "-d", "--dump", "Dumps API output to the screen" do
27
+ opts.on "-d", "--dump", _("Dumps API output to the screen") do
28
28
  @dump = true
29
29
  end
30
30
 
31
- opts.on "-a", "--api", "Show API help for a command" do
31
+ opts.on "-a", "--api", _("Show API help for a command") do
32
32
  @api_help = true
33
33
  end
34
34
 
35
- opts.on "-k", "--insecure", "Allow SSL connections without verified certificates" do
35
+ opts.on "-k", "--insecure", _("Allow SSL connections without verified certificates") do
36
36
  @verify_ssl = false
37
37
  end
38
38
 
39
39
  opts.on "-u", "--url URL",
40
- "The full Razor API URL, can also be set\n" + " "*37 +
40
+ _("The full Razor API URL, can also be set\n" + " "*37 +
41
41
  "with the RAZOR_API environment variable\n" + " "*37 +
42
- "(default #{DEFAULT_RAZOR_API})" do |url|
42
+ "(default %{default_api})") % {default_api: DEFAULT_RAZOR_API} do |url|
43
43
  parse_and_set_api_url(url, :opts)
44
44
  end
45
45
 
46
- opts.on "-v", "--version", "Show the version of Razor" do
46
+ opts.on "-v", "--version", _("Show the version of Razor") do
47
47
  @show_version = true
48
48
  end
49
49
 
50
- opts.on "-h", "--help", "Show this screen" do
50
+ opts.on "-h", "--help", _("Show this screen") do
51
51
  # If searching for a command's help, leave the argument for navigation.
52
52
  @option_help = true
53
53
  end
@@ -68,11 +68,11 @@ module Razor::CLI
68
68
  begin
69
69
  server_version = navigate.server_version
70
70
  rescue RestClient::Unauthorized
71
- error = "Error: Credentials are required to connect to the server at #{@api_url}."
71
+ error = _("Error: Credentials are required to connect to the server at %{url}.") % {url: @api_url}
72
72
  rescue
73
- error = "Error: Could not connect to the server at #{@api_url}."
73
+ error = _("Error: Could not connect to the server at %{url}.") % {url: @api_url}
74
74
  ensure
75
- return [(<<-OUTPUT + "\n" + error).rstrip, error != '' ? 1 : 0]
75
+ return [(_(<<-OUTPUT) % {server_version: server_version, client_version: Razor::CLI::VERSION} + "\n" + error).rstrip, error != '' ? 1 : 0]
76
76
  Razor Server version: #{server_version}
77
77
  Razor Client version: #{Razor::CLI::VERSION}
78
78
  OUTPUT
@@ -83,13 +83,15 @@ module Razor::CLI
83
83
  output = get_optparse.to_s
84
84
  exit = 0
85
85
  begin
86
- output << <<-HELP
87
- #{list_things("Collections", navigate.collections)}
86
+ replacements = {collections: list_things(_("Collections"), navigate.collections),
87
+ commands: list_things(_("Commands"), navigate.commands)}
88
+ output << _(<<-HELP) % replacements
89
+ %{collections}
88
90
 
89
91
  Navigate to entries of a collection using COLLECTION NAME, for example,
90
92
  'nodes node15' for the details of a node or 'nodes node15 log' to see
91
93
  the log for node15
92
- #{list_things("Commands", navigate.commands)}
94
+ %{commands}
93
95
 
94
96
  Pass arguments to commands either directly by name ('--name=NAME')
95
97
  or save the JSON body for the command in a file and pass it with
@@ -98,26 +100,26 @@ module Razor::CLI
98
100
 
99
101
  HELP
100
102
  rescue RestClient::Unauthorized
101
- output << <<-UNAUTH
102
- Error: Credentials are required to connect to the server at #{@api_url}"
103
+ output << _(<<-UNAUTH) % {url: @api_url}
104
+ Error: Credentials are required to connect to the server at %{url}"
103
105
  UNAUTH
104
106
  exit = 1
105
107
  rescue SocketError, Errno::ECONNREFUSED => e
106
- puts "Error: Could not connect to the server at #{@api_url}"
108
+ puts _("Error: Could not connect to the server at %{url}") % {url: @api_url}
107
109
  puts " #{e}\n"
108
110
  die
109
111
  rescue RestClient::SSLCertificateNotVerified
110
- puts "Error: SSL certificate could not be verified against known CA certificates."
111
- puts " To turn off verification, use the -k or --insecure option."
112
+ puts _("Error: SSL certificate could not be verified against known CA certificates.\n" +
113
+ " To turn off verification, use the -k or --insecure option.")
112
114
  die
113
115
  rescue OpenSSL::SSL::SSLError => e
114
116
  # Occurs in case of e.g. certificate mismatch (FQDN vs. hostname)
115
- puts "Error: SSL certificate error from server at #{@api_url}"
117
+ puts _("Error: SSL certificate error from server at %{url}") % {url: @api_url}
116
118
  puts " #{e}"
117
119
  die
118
120
  rescue => e
119
- output << <<-ERR
120
- Error: Unknown error occurred while connecting to server at #{@api_url}:
121
+ output << _(<<-ERR) % {url: @api_url}
122
+ Error: Unknown error occurred while connecting to server at %{url}:
121
123
  #{e}
122
124
  ERR
123
125
  exit = 1
@@ -24,11 +24,11 @@ class Razor::CLI::Query
24
24
  doc[nav]['params'].is_a?(Hash) && doc[nav]['params']) || {}
25
25
  end
26
26
  @queryoptparse = OptionParser.new do |opts|
27
- opts.on "-f", "--full", "Show full details when viewing entities" do
27
+ opts.on "-f", "--full", _("Show full details when viewing entities") do
28
28
  @parse.format = 'full'
29
29
  end
30
30
 
31
- opts.on "-s", "--short", "Show shortened details when viewing entities" do
31
+ opts.on "-s", "--short", _("Show shortened details when viewing entities") do
32
32
  @parse.format = 'short'
33
33
  end
34
34
 
@@ -8,13 +8,13 @@ module Razor::CLI
8
8
  obj.nil? ? "---" : obj
9
9
  end
10
10
  def join_names(arr)
11
- (arr.nil? or arr.empty?) ? '(none)' : arr.map { |item| item['name'] }.join(", ")
11
+ (arr.nil? or arr.empty?) ? _('(none)') : arr.map { |item| item['name'] }.join(", ")
12
12
  end
13
13
  def nested(nested_obj)
14
- (nested_obj.nil? or nested_obj.empty?) ? '(none)' : nested_obj.to_s
14
+ (nested_obj.nil? or nested_obj.empty?) ? _('(none)') : nested_obj.to_s
15
15
  end
16
16
  def shallow_hash(hash)
17
- (hash.nil? or hash.empty?) ? '(none)' :
17
+ (hash.nil? or hash.empty?) ? _('(none)') :
18
18
  hash.map {|key, val| "#{key}: #{val}"}.join(', ')
19
19
  end
20
20
  def select_name(item)
@@ -59,14 +59,17 @@ module Razor::CLI
59
59
  end
60
60
  def event_entities(hash)
61
61
  hash ||= {}
62
- shallow_hash(Hash[hash].keep_if {|k,_| ['task', 'policy', 'broker', 'repo', 'node', 'command'].include?(k)})
62
+ fields = ['task', 'policy', 'broker', 'repo', 'node', 'command']
63
+ shallow_hash(Hash[hash].keep_if {|k,_| fields.include?(k)})
63
64
  end
64
65
  def event_misc(hash)
65
66
  hash ||= {}
66
- shallow_hash(Hash[hash].delete_if {|k,_|['task', 'policy', 'broker', 'repo', 'node', 'msg', 'command'].include?(k)})
67
+ fields = ['task', 'policy', 'broker', 'repo', 'node', 'msg', 'command']
68
+ shallow_hash(Hash[hash].delete_if {|k,_| fields.include?(k)})
67
69
  end
68
70
  def node_log_entry(hash)
69
- shallow_hash(Hash[hash].delete_if {|k,_|['event', 'timestamp', 'severity'].include?(k)})
71
+ fields = ['event', 'timestamp', 'severity']
72
+ shallow_hash(Hash[hash].delete_if {|k,_| fields.include?(k)})
70
73
  end
71
74
  end
72
75
  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.3.0'
21
+ version = '1.6.1'
22
22
 
23
23
  if version == "DEVELOPMENT"
24
24
  root = File.expand_path("../../..", File.dirname(__FILE__))
@@ -0,0 +1,24 @@
1
+ ---
2
+ # This is the project-specific configuration file for setting up
3
+ # fast_gettext for your project.
4
+ gettext:
5
+ # This is used for the name of the .pot and .po files; they will be
6
+ # called <project_name>.pot?
7
+ project_name: 'razor-client'
8
+ # This is used in comments in the .pot and .po files to indicate what
9
+ # project the files belong to and should be a little more descriptive than
10
+ # <project_name>
11
+ package_name: Razor Client
12
+ # The locale that the default messages in the .pot file are in
13
+ default_locale: en
14
+ # The email used for sending bug reports.
15
+ bugs_address: docs@puppet.com
16
+ # The holder of the copyright.
17
+ copyright_holder: Puppet Inc.
18
+ # This determines which comments in code should be eligible for translation.
19
+ comments_tag: TRANSLATORS
20
+ # Patterns for +Dir.glob+ used to find all files that might contain
21
+ # translatable content, relative to the project root directory
22
+ source_files:
23
+ - 'lib/**/*.rb'
24
+ - 'bin/razor'
@@ -0,0 +1,268 @@
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) 2017 Puppet, LLC.
3
+ # This file is distributed under the same license as the Razor Client package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, 2017.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: Razor Client 1.3.0-3-ga296fc7\n"
10
+ "\n"
11
+ "Report-Msgid-Bugs-To: docs@puppet.com\n"
12
+ "POT-Creation-Date: 2017-01-12 03:03-0600\n"
13
+ "PO-Revision-Date: 2017-01-12 03:03-0600\n"
14
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
15
+ "Language-Team: LANGUAGE <LL@li.org>\n"
16
+ "Language: \n"
17
+ "MIME-Version: 1.0\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
19
+ "Content-Transfer-Encoding: 8bit\n"
20
+ "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
21
+
22
+ msgid "Error: %{error}"
23
+ msgstr ""
24
+
25
+ #. TRANSLATORS: This occurs when invalid flags are passed in the navigation.
26
+ msgid ""
27
+ "%{error}\n"
28
+ "Try 'razor --help' for more information"
29
+ msgstr ""
30
+
31
+ msgid ""
32
+ "An unexpected error has occurred.\n"
33
+ "\n"
34
+ "Backtrace:\n"
35
+ " %{backtrace}\n"
36
+ "\n"
37
+ "Error: %{error}\n"
38
+ "\n"
39
+ "Please inspect server logs for the cause, then report issue to:\n"
40
+ "https://tickets.puppetlabs.com/browse/RAZOR\n"
41
+ "\n"
42
+ msgstr ""
43
+
44
+ #. TRANSLATORS: This is a template for all results that the client outputs.
45
+ msgid ""
46
+ "From %{url}:\n"
47
+ "\n"
48
+ "%{result}\n"
49
+ "\n"
50
+ msgstr ""
51
+
52
+ msgid ""
53
+ "Error: Could not connect to the server at %{url}\n"
54
+ " %{error}"
55
+ msgstr ""
56
+
57
+ msgid ""
58
+ "Error: SSL certificate could not be verified against known CA certificates.\n"
59
+ " To turn off verification, use the -k or --insecure option."
60
+ msgstr ""
61
+
62
+ msgid "Error from doing %{request_type} %{url}"
63
+ msgstr ""
64
+
65
+ msgid ""
66
+ "%{error}\n"
67
+ "Try 'razor --help' for more information\n"
68
+ "\n"
69
+ msgstr ""
70
+
71
+ msgid "Could not navigate to '%{path}' from %{url}"
72
+ msgstr ""
73
+
74
+ msgid "Could not find entry '%{key}' in document at %{url}"
75
+ msgstr ""
76
+
77
+ msgid "URL '%{url}' in ENV variable RAZOR_API is not valid"
78
+ msgstr ""
79
+
80
+ msgid "URL '%{url}' provided by -u or --url is not valid"
81
+ msgstr ""
82
+
83
+ msgid "URL '%{url}' is not valid"
84
+ msgstr ""
85
+
86
+ msgid "CA file '%{path}' in ENV variable RAZOR_CA_FILE does not exist"
87
+ msgstr ""
88
+
89
+ msgid "Server version is not compatible with client version: %{reason}"
90
+ msgstr ""
91
+
92
+ msgid "No arguments for command (did you forget --json ?)"
93
+ msgstr ""
94
+
95
+ msgid "Unexpected argument %{argument} (did you mean %{suggestion}?)"
96
+ msgstr ""
97
+
98
+ msgid "Unexpected argument %{argument}"
99
+ msgstr ""
100
+
101
+ msgid "File %{path} is not valid JSON"
102
+ msgstr ""
103
+
104
+ msgid "File %{path} not found"
105
+ msgstr ""
106
+
107
+ msgid "Permission to read file %{path} denied"
108
+ msgstr ""
109
+
110
+ msgid ""
111
+ "Formatting argument %{argument_name} with value %{value} as %{argument_type}\n"
112
+ msgstr ""
113
+
114
+ msgid "Invalid object for argument '%{argument_name}'"
115
+ msgstr ""
116
+
117
+ msgid "Invalid object for argument '%{argument_name}': %{error}"
118
+ msgstr ""
119
+
120
+ msgid "Invalid integer for argument '%{arg_name}': %{value}"
121
+ msgstr ""
122
+
123
+ msgid "Expected nothing for argument '%{arg_name}', but was: '%{value}'"
124
+ msgstr ""
125
+
126
+ msgid "Unexpected datatype '%{argument_type}' for argument %{argument_name}"
127
+ msgstr ""
128
+
129
+ msgid "There are no items for this query."
130
+ msgstr ""
131
+
132
+ msgid "Unrecognized view format %{format_name}"
133
+ msgstr ""
134
+
135
+ msgid "Could not find help for that entry"
136
+ msgstr ""
137
+
138
+ msgid ""
139
+ "# USAGE\n"
140
+ "\n"
141
+ " razor %{command} %{arguments} <flags>\n"
142
+ "\n"
143
+ msgstr ""
144
+
145
+ msgid ""
146
+ "# SYNOPSIS\n"
147
+ "%{summary}\n"
148
+ "\n"
149
+ msgstr ""
150
+
151
+ msgid ""
152
+ "# DESCRIPTION\n"
153
+ "%{description}\n"
154
+ "\n"
155
+ "%{schema}\n"
156
+ msgstr ""
157
+
158
+ msgid ""
159
+ "# RETURNS\n"
160
+ "%{returns}\n"
161
+ msgstr ""
162
+
163
+ msgid ""
164
+ "# EXAMPLES\n"
165
+ "\n"
166
+ "%{examples}\n"
167
+ msgstr ""
168
+
169
+ msgid ""
170
+ "\n"
171
+ "\n"
172
+ "Query an entry by including its name, e.g. `razor %{arguments} %{name}`"
173
+ msgstr ""
174
+
175
+ msgid ""
176
+ "\n"
177
+ "\n"
178
+ "Query additional details via: `razor %{arguments} [%{options}]`"
179
+ msgstr ""
180
+
181
+ msgid "Unknown"
182
+ msgstr ""
183
+
184
+ msgid "Received content type %{content_type}"
185
+ msgstr ""
186
+
187
+ msgid "ERROR"
188
+ msgstr ""
189
+
190
+ msgid ""
191
+ "Usage: razor [FLAGS] NAVIGATION\n"
192
+ msgstr ""
193
+
194
+ msgid "Dumps API output to the screen"
195
+ msgstr ""
196
+
197
+ msgid "Show API help for a command"
198
+ msgstr ""
199
+
200
+ msgid "Allow SSL connections without verified certificates"
201
+ msgstr ""
202
+
203
+ msgid ""
204
+ "The full Razor API URL, can also be set\n"
205
+ " "
206
+ msgstr ""
207
+
208
+ msgid "Show the version of Razor"
209
+ msgstr ""
210
+
211
+ msgid "Show this screen"
212
+ msgstr ""
213
+
214
+ msgid "Error: Credentials are required to connect to the server at %{url}."
215
+ msgstr ""
216
+
217
+ msgid "Error: Could not connect to the server at %{url}."
218
+ msgstr ""
219
+
220
+ msgid ""
221
+ " Razor Server version: #{server_version}\n"
222
+ " Razor Client version: #{Razor::CLI::VERSION}\n"
223
+ msgstr ""
224
+
225
+ msgid "Collections"
226
+ msgstr ""
227
+
228
+ msgid "Commands"
229
+ msgstr ""
230
+
231
+ msgid ""
232
+ "%{collections}\n"
233
+ "\n"
234
+ " Navigate to entries of a collection using COLLECTION NAME, for example,\n"
235
+ " 'nodes node15' for the details of a node or 'nodes node15 log' to see\n"
236
+ " the log for node15\n"
237
+ "%{commands}\n"
238
+ "\n"
239
+ " Pass arguments to commands either directly by name ('--name=NAME')\n"
240
+ " or save the JSON body for the command in a file and pass it with\n"
241
+ " '--json FILE'. Using --json is the only way to pass arguments in\n"
242
+ " nested structures such as the configuration for a broker.\n"
243
+ "\n"
244
+ msgstr ""
245
+
246
+ msgid ""
247
+ "Error: Credentials are required to connect to the server at %{url}\"\n"
248
+ msgstr ""
249
+
250
+ msgid "Error: Could not connect to the server at %{url}"
251
+ msgstr ""
252
+
253
+ msgid "Error: SSL certificate error from server at %{url}"
254
+ msgstr ""
255
+
256
+ msgid ""
257
+ "Error: Unknown error occurred while connecting to server at %{url}:\n"
258
+ " #{e}\n"
259
+ msgstr ""
260
+
261
+ msgid "Show full details when viewing entities"
262
+ msgstr ""
263
+
264
+ msgid "Show shortened details when viewing entities"
265
+ msgstr ""
266
+
267
+ msgid "(none)"
268
+ msgstr ""
@@ -227,4 +227,23 @@ describe Razor::CLI::Navigate do
227
227
  parse.stripped_args.should == ['nodes', name, 'log']
228
228
  end
229
229
  end
230
+
231
+ context "accept-language header", :vcr do
232
+ before :each do
233
+ GettextSetup.clear
234
+ end
235
+ it "should set the accept-language header" do
236
+ GettextSetup.candidate_locales.should_not be_nil
237
+ nav = Razor::CLI::Parse.new(['create-broker', '--name=some-broker', '--broker-type', 'puppet-pe', '-c', 'server=abc.com']).navigate
238
+ nav.accept_language.should == GettextSetup.candidate_locales
239
+ end
240
+ it "should allow other accept-language headers" do
241
+ ENV['LANG'] = 'de_DE'
242
+ locales = GettextSetup.candidate_locales
243
+ locales.should == 'de_DE,de,en'
244
+ nav = Razor::CLI::Parse.new(['create-broker', '--name=other-broker', '--broker-type', 'puppet-pe', '-c', 'server=abc.com']).navigate
245
+ nav.accept_language.should == locales
246
+ nav.doc_resource.options[:headers][:accept_language].should == locales
247
+ end
248
+ end
230
249
  end
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:8150/api
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Accept-Language:
15
+ - de_DE,de,en
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - Apache-Coyote/1.1
25
+ X-Content-Type-Options:
26
+ - nosniff
27
+ Content-Type:
28
+ - application/json
29
+ Content-Length:
30
+ - '7116'
31
+ Date:
32
+ - Wed, 18 Jan 2017 18:16:48 GMT
33
+ body:
34
+ encoding: US-ASCII
35
+ string: '{"commands":[{"name":"add-policy-tag","rel":"http://api.puppetlabs.com/razor/v1/commands/add-policy-tag","id":"http://localhost:8150/api/commands/add-policy-tag"},{"name":"create-broker","rel":"http://api.puppetlabs.com/razor/v1/commands/create-broker","id":"http://localhost:8150/api/commands/create-broker"},{"name":"create-hook","rel":"http://api.puppetlabs.com/razor/v1/commands/create-hook","id":"http://localhost:8150/api/commands/create-hook"},{"name":"create-policy","rel":"http://api.puppetlabs.com/razor/v1/commands/create-policy","id":"http://localhost:8150/api/commands/create-policy"},{"name":"create-repo","rel":"http://api.puppetlabs.com/razor/v1/commands/create-repo","id":"http://localhost:8150/api/commands/create-repo"},{"name":"create-tag","rel":"http://api.puppetlabs.com/razor/v1/commands/create-tag","id":"http://localhost:8150/api/commands/create-tag"},{"name":"create-task","rel":"http://api.puppetlabs.com/razor/v1/commands/create-task","id":"http://localhost:8150/api/commands/create-task"},{"name":"delete-broker","rel":"http://api.puppetlabs.com/razor/v1/commands/delete-broker","id":"http://localhost:8150/api/commands/delete-broker"},{"name":"delete-hook","rel":"http://api.puppetlabs.com/razor/v1/commands/delete-hook","id":"http://localhost:8150/api/commands/delete-hook"},{"name":"delete-node","rel":"http://api.puppetlabs.com/razor/v1/commands/delete-node","id":"http://localhost:8150/api/commands/delete-node"},{"name":"delete-policy","rel":"http://api.puppetlabs.com/razor/v1/commands/delete-policy","id":"http://localhost:8150/api/commands/delete-policy"},{"name":"delete-repo","rel":"http://api.puppetlabs.com/razor/v1/commands/delete-repo","id":"http://localhost:8150/api/commands/delete-repo"},{"name":"delete-tag","rel":"http://api.puppetlabs.com/razor/v1/commands/delete-tag","id":"http://localhost:8150/api/commands/delete-tag"},{"name":"disable-policy","rel":"http://api.puppetlabs.com/razor/v1/commands/disable-policy","id":"http://localhost:8150/api/commands/disable-policy"},{"name":"enable-policy","rel":"http://api.puppetlabs.com/razor/v1/commands/enable-policy","id":"http://localhost:8150/api/commands/enable-policy"},{"name":"modify-node-metadata","rel":"http://api.puppetlabs.com/razor/v1/commands/modify-node-metadata","id":"http://localhost:8150/api/commands/modify-node-metadata"},{"name":"modify-policy-max-count","rel":"http://api.puppetlabs.com/razor/v1/commands/modify-policy-max-count","id":"http://localhost:8150/api/commands/modify-policy-max-count"},{"name":"move-policy","rel":"http://api.puppetlabs.com/razor/v1/commands/move-policy","id":"http://localhost:8150/api/commands/move-policy"},{"name":"reboot-node","rel":"http://api.puppetlabs.com/razor/v1/commands/reboot-node","id":"http://localhost:8150/api/commands/reboot-node"},{"name":"register-node","rel":"http://api.puppetlabs.com/razor/v1/commands/register-node","id":"http://localhost:8150/api/commands/register-node"},{"name":"reinstall-node","rel":"http://api.puppetlabs.com/razor/v1/commands/reinstall-node","id":"http://localhost:8150/api/commands/reinstall-node"},{"name":"remove-node-metadata","rel":"http://api.puppetlabs.com/razor/v1/commands/remove-node-metadata","id":"http://localhost:8150/api/commands/remove-node-metadata"},{"name":"remove-policy-tag","rel":"http://api.puppetlabs.com/razor/v1/commands/remove-policy-tag","id":"http://localhost:8150/api/commands/remove-policy-tag"},{"name":"run-hook","rel":"http://api.puppetlabs.com/razor/v1/commands/run-hook","id":"http://localhost:8150/api/commands/run-hook"},{"name":"set-node-desired-power-state","rel":"http://api.puppetlabs.com/razor/v1/commands/set-node-desired-power-state","id":"http://localhost:8150/api/commands/set-node-desired-power-state"},{"name":"set-node-hw-info","rel":"http://api.puppetlabs.com/razor/v1/commands/set-node-hw-info","id":"http://localhost:8150/api/commands/set-node-hw-info"},{"name":"set-node-ipmi-credentials","rel":"http://api.puppetlabs.com/razor/v1/commands/set-node-ipmi-credentials","id":"http://localhost:8150/api/commands/set-node-ipmi-credentials"},{"name":"update-broker-configuration","rel":"http://api.puppetlabs.com/razor/v1/commands/update-broker-configuration","id":"http://localhost:8150/api/commands/update-broker-configuration"},{"name":"update-hook-configuration","rel":"http://api.puppetlabs.com/razor/v1/commands/update-hook-configuration","id":"http://localhost:8150/api/commands/update-hook-configuration"},{"name":"update-node-metadata","rel":"http://api.puppetlabs.com/razor/v1/commands/update-node-metadata","id":"http://localhost:8150/api/commands/update-node-metadata"},{"name":"update-policy-broker","rel":"http://api.puppetlabs.com/razor/v1/commands/update-policy-broker","id":"http://localhost:8150/api/commands/update-policy-broker"},{"name":"update-policy-node-metadata","rel":"http://api.puppetlabs.com/razor/v1/commands/update-policy-node-metadata","id":"http://localhost:8150/api/commands/update-policy-node-metadata"},{"name":"update-policy-repo","rel":"http://api.puppetlabs.com/razor/v1/commands/update-policy-repo","id":"http://localhost:8150/api/commands/update-policy-repo"},{"name":"update-policy-task","rel":"http://api.puppetlabs.com/razor/v1/commands/update-policy-task","id":"http://localhost:8150/api/commands/update-policy-task"},{"name":"update-repo-task","rel":"http://api.puppetlabs.com/razor/v1/commands/update-repo-task","id":"http://localhost:8150/api/commands/update-repo-task"},{"name":"update-tag-rule","rel":"http://api.puppetlabs.com/razor/v1/commands/update-tag-rule","id":"http://localhost:8150/api/commands/update-tag-rule"}],"collections":[{"name":"brokers","rel":"http://api.puppetlabs.com/razor/v1/collections/brokers","id":"http://localhost:8150/api/collections/brokers"},{"name":"repos","rel":"http://api.puppetlabs.com/razor/v1/collections/repos","id":"http://localhost:8150/api/collections/repos"},{"name":"tags","rel":"http://api.puppetlabs.com/razor/v1/collections/tags","id":"http://localhost:8150/api/collections/tags"},{"name":"policies","rel":"http://api.puppetlabs.com/razor/v1/collections/policies","id":"http://localhost:8150/api/collections/policies"},{"name":"nodes","rel":"http://api.puppetlabs.com/razor/v1/collections/nodes","id":"http://localhost:8150/api/collections/nodes","params":{"start":{"type":"number"},"limit":{"type":"number"}}},{"name":"tasks","rel":"http://api.puppetlabs.com/razor/v1/collections/tasks","id":"http://localhost:8150/api/collections/tasks"},{"name":"commands","rel":"http://api.puppetlabs.com/razor/v1/collections/commands","id":"http://localhost:8150/api/collections/commands"},{"name":"events","rel":"http://api.puppetlabs.com/razor/v1/collections/events","id":"http://localhost:8150/api/collections/events","params":{"start":{"type":"number"},"limit":{"type":"number"}}},{"name":"hooks","rel":"http://api.puppetlabs.com/razor/v1/collections/hooks","id":"http://localhost:8150/api/collections/hooks"},{"name":"config","rel":"http://api.puppetlabs.com/razor/v1/collections/config","id":"http://localhost:8150/api/collections/config"}],"version":{"server":"v1.5.0-11-g89cc831"}}'
36
+ http_version:
37
+ recorded_at: Wed, 18 Jan 2017 18:16:48 GMT
38
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://localhost:8150/api
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Accept-Language:
15
+ - en_US,en
16
+ User-Agent:
17
+ - Ruby
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - Apache-Coyote/1.1
25
+ X-Content-Type-Options:
26
+ - nosniff
27
+ Content-Type:
28
+ - application/json
29
+ Content-Length:
30
+ - '7116'
31
+ Date:
32
+ - Wed, 18 Jan 2017 18:16:43 GMT
33
+ body:
34
+ encoding: US-ASCII
35
+ string: '{"commands":[{"name":"add-policy-tag","rel":"http://api.puppetlabs.com/razor/v1/commands/add-policy-tag","id":"http://localhost:8150/api/commands/add-policy-tag"},{"name":"create-broker","rel":"http://api.puppetlabs.com/razor/v1/commands/create-broker","id":"http://localhost:8150/api/commands/create-broker"},{"name":"create-hook","rel":"http://api.puppetlabs.com/razor/v1/commands/create-hook","id":"http://localhost:8150/api/commands/create-hook"},{"name":"create-policy","rel":"http://api.puppetlabs.com/razor/v1/commands/create-policy","id":"http://localhost:8150/api/commands/create-policy"},{"name":"create-repo","rel":"http://api.puppetlabs.com/razor/v1/commands/create-repo","id":"http://localhost:8150/api/commands/create-repo"},{"name":"create-tag","rel":"http://api.puppetlabs.com/razor/v1/commands/create-tag","id":"http://localhost:8150/api/commands/create-tag"},{"name":"create-task","rel":"http://api.puppetlabs.com/razor/v1/commands/create-task","id":"http://localhost:8150/api/commands/create-task"},{"name":"delete-broker","rel":"http://api.puppetlabs.com/razor/v1/commands/delete-broker","id":"http://localhost:8150/api/commands/delete-broker"},{"name":"delete-hook","rel":"http://api.puppetlabs.com/razor/v1/commands/delete-hook","id":"http://localhost:8150/api/commands/delete-hook"},{"name":"delete-node","rel":"http://api.puppetlabs.com/razor/v1/commands/delete-node","id":"http://localhost:8150/api/commands/delete-node"},{"name":"delete-policy","rel":"http://api.puppetlabs.com/razor/v1/commands/delete-policy","id":"http://localhost:8150/api/commands/delete-policy"},{"name":"delete-repo","rel":"http://api.puppetlabs.com/razor/v1/commands/delete-repo","id":"http://localhost:8150/api/commands/delete-repo"},{"name":"delete-tag","rel":"http://api.puppetlabs.com/razor/v1/commands/delete-tag","id":"http://localhost:8150/api/commands/delete-tag"},{"name":"disable-policy","rel":"http://api.puppetlabs.com/razor/v1/commands/disable-policy","id":"http://localhost:8150/api/commands/disable-policy"},{"name":"enable-policy","rel":"http://api.puppetlabs.com/razor/v1/commands/enable-policy","id":"http://localhost:8150/api/commands/enable-policy"},{"name":"modify-node-metadata","rel":"http://api.puppetlabs.com/razor/v1/commands/modify-node-metadata","id":"http://localhost:8150/api/commands/modify-node-metadata"},{"name":"modify-policy-max-count","rel":"http://api.puppetlabs.com/razor/v1/commands/modify-policy-max-count","id":"http://localhost:8150/api/commands/modify-policy-max-count"},{"name":"move-policy","rel":"http://api.puppetlabs.com/razor/v1/commands/move-policy","id":"http://localhost:8150/api/commands/move-policy"},{"name":"reboot-node","rel":"http://api.puppetlabs.com/razor/v1/commands/reboot-node","id":"http://localhost:8150/api/commands/reboot-node"},{"name":"register-node","rel":"http://api.puppetlabs.com/razor/v1/commands/register-node","id":"http://localhost:8150/api/commands/register-node"},{"name":"reinstall-node","rel":"http://api.puppetlabs.com/razor/v1/commands/reinstall-node","id":"http://localhost:8150/api/commands/reinstall-node"},{"name":"remove-node-metadata","rel":"http://api.puppetlabs.com/razor/v1/commands/remove-node-metadata","id":"http://localhost:8150/api/commands/remove-node-metadata"},{"name":"remove-policy-tag","rel":"http://api.puppetlabs.com/razor/v1/commands/remove-policy-tag","id":"http://localhost:8150/api/commands/remove-policy-tag"},{"name":"run-hook","rel":"http://api.puppetlabs.com/razor/v1/commands/run-hook","id":"http://localhost:8150/api/commands/run-hook"},{"name":"set-node-desired-power-state","rel":"http://api.puppetlabs.com/razor/v1/commands/set-node-desired-power-state","id":"http://localhost:8150/api/commands/set-node-desired-power-state"},{"name":"set-node-hw-info","rel":"http://api.puppetlabs.com/razor/v1/commands/set-node-hw-info","id":"http://localhost:8150/api/commands/set-node-hw-info"},{"name":"set-node-ipmi-credentials","rel":"http://api.puppetlabs.com/razor/v1/commands/set-node-ipmi-credentials","id":"http://localhost:8150/api/commands/set-node-ipmi-credentials"},{"name":"update-broker-configuration","rel":"http://api.puppetlabs.com/razor/v1/commands/update-broker-configuration","id":"http://localhost:8150/api/commands/update-broker-configuration"},{"name":"update-hook-configuration","rel":"http://api.puppetlabs.com/razor/v1/commands/update-hook-configuration","id":"http://localhost:8150/api/commands/update-hook-configuration"},{"name":"update-node-metadata","rel":"http://api.puppetlabs.com/razor/v1/commands/update-node-metadata","id":"http://localhost:8150/api/commands/update-node-metadata"},{"name":"update-policy-broker","rel":"http://api.puppetlabs.com/razor/v1/commands/update-policy-broker","id":"http://localhost:8150/api/commands/update-policy-broker"},{"name":"update-policy-node-metadata","rel":"http://api.puppetlabs.com/razor/v1/commands/update-policy-node-metadata","id":"http://localhost:8150/api/commands/update-policy-node-metadata"},{"name":"update-policy-repo","rel":"http://api.puppetlabs.com/razor/v1/commands/update-policy-repo","id":"http://localhost:8150/api/commands/update-policy-repo"},{"name":"update-policy-task","rel":"http://api.puppetlabs.com/razor/v1/commands/update-policy-task","id":"http://localhost:8150/api/commands/update-policy-task"},{"name":"update-repo-task","rel":"http://api.puppetlabs.com/razor/v1/commands/update-repo-task","id":"http://localhost:8150/api/commands/update-repo-task"},{"name":"update-tag-rule","rel":"http://api.puppetlabs.com/razor/v1/commands/update-tag-rule","id":"http://localhost:8150/api/commands/update-tag-rule"}],"collections":[{"name":"brokers","rel":"http://api.puppetlabs.com/razor/v1/collections/brokers","id":"http://localhost:8150/api/collections/brokers"},{"name":"repos","rel":"http://api.puppetlabs.com/razor/v1/collections/repos","id":"http://localhost:8150/api/collections/repos"},{"name":"tags","rel":"http://api.puppetlabs.com/razor/v1/collections/tags","id":"http://localhost:8150/api/collections/tags"},{"name":"policies","rel":"http://api.puppetlabs.com/razor/v1/collections/policies","id":"http://localhost:8150/api/collections/policies"},{"name":"nodes","rel":"http://api.puppetlabs.com/razor/v1/collections/nodes","id":"http://localhost:8150/api/collections/nodes","params":{"start":{"type":"number"},"limit":{"type":"number"}}},{"name":"tasks","rel":"http://api.puppetlabs.com/razor/v1/collections/tasks","id":"http://localhost:8150/api/collections/tasks"},{"name":"commands","rel":"http://api.puppetlabs.com/razor/v1/collections/commands","id":"http://localhost:8150/api/collections/commands"},{"name":"events","rel":"http://api.puppetlabs.com/razor/v1/collections/events","id":"http://localhost:8150/api/collections/events","params":{"start":{"type":"number"},"limit":{"type":"number"}}},{"name":"hooks","rel":"http://api.puppetlabs.com/razor/v1/collections/hooks","id":"http://localhost:8150/api/collections/hooks"},{"name":"config","rel":"http://api.puppetlabs.com/razor/v1/collections/config","id":"http://localhost:8150/api/collections/config"}],"version":{"server":"v1.5.0-11-g89cc831"}}'
36
+ http_version:
37
+ recorded_at: Wed, 18 Jan 2017 18:16:43 GMT
38
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,24 @@
1
+ ---
2
+ # This is the project-specific configuration file for setting up
3
+ # fast_gettext for your project.
4
+ gettext:
5
+ # This is used for the name of the .pot and .po files; they will be
6
+ # called <project_name>.pot?
7
+ project_name: 'razor-client'
8
+ # This is used in comments in the .pot and .po files to indicate what
9
+ # project the files belong to and should be a little more descriptive than
10
+ # <project_name>
11
+ package_name: Razor Client
12
+ # The locale that the default messages in the .pot file are in
13
+ default_locale: en
14
+ # The email used for sending bug reports.
15
+ bugs_address: docs@puppet.com
16
+ # The holder of the copyright.
17
+ copyright_holder: Puppet Inc.
18
+ # This determines which comments in code should be eligible for translation.
19
+ comments_tag: TRANSLATORS
20
+ # Patterns for +Dir.glob+ used to find all files that might contain
21
+ # translatable content, relative to the project root directory
22
+ source_files:
23
+ - 'lib/**/*.rb'
24
+ - 'bin/razor'
@@ -6,6 +6,9 @@ end
6
6
  require 'multi_json'
7
7
  require 'vcr'
8
8
 
9
+ require 'gettext-setup'
10
+ GettextSetup.initialize(File.absolute_path('locales', File.dirname(__FILE__)))
11
+
9
12
  require_relative '../lib/razor'
10
13
  require_relative 'vcr_library'
11
14
 
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.3.0
4
+ version: 1.6.1
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: 2016-05-18 00:00:00.000000000 Z
12
+ date: 2017-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mime-types
@@ -75,6 +75,22 @@ dependencies:
75
75
  - - ! '>'
76
76
  - !ruby/object:Gem::Version
77
77
  version: '3.0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: gettext-setup
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
78
94
  description: ! 'Razor is an advanced provisioning application which can deploy both
79
95
  bare-metal
80
96
 
@@ -110,6 +126,8 @@ files:
110
126
  - lib/razor/cli/views.rb
111
127
  - lib/razor/cli/format.rb
112
128
  - lib/razor/cli.rb
129
+ - locales/config.yaml
130
+ - locales/razor-client.pot
113
131
  - NEWS.md
114
132
  - README.md
115
133
  - LICENSE
@@ -121,6 +139,8 @@ files:
121
139
  - spec/cli/format_spec.rb
122
140
  - spec/fixtures/vcr/Razor_CLI_Parse/_new/_help/should_print_a_list_of_known_endpoints.yml
123
141
  - spec/fixtures/vcr/Razor_CLI_Navigate/with_no_parameters/should_fail_with_bad_JSON.yml
142
+ - spec/fixtures/vcr/Razor_CLI_Navigate/accept-language_header/should_allow_other_accept-language_headers.yml
143
+ - spec/fixtures/vcr/Razor_CLI_Navigate/accept-language_header/should_set_the_accept-language_header.yml
124
144
  - spec/fixtures/vcr/Razor_CLI_Navigate/with_authentication/should_supply_that_to_the_API_service.yml
125
145
  - spec/fixtures/vcr/Razor_CLI_Navigate/with_authentication/should_preserve_that_across_navigation.yml
126
146
  - spec/fixtures/vcr/Razor_CLI_Navigate/with_multiple_arguments_with_same_name/combining_as_an_object/should_fail_with_mixed_types_array_then_hash_.yml
@@ -154,6 +174,7 @@ files:
154
174
  - spec/vcr_library.rb
155
175
  - spec/version_spec.rb
156
176
  - spec/spec_helper.rb
177
+ - spec/locales/config.yaml
157
178
  homepage: http://puppetlabs.com/puppet/puppet-enterprise
158
179
  licenses: []
159
180
  post_install_message:
@@ -165,7 +186,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
165
186
  requirements:
166
187
  - - ! '>='
167
188
  - !ruby/object:Gem::Version
168
- version: '0'
189
+ version: 1.9.3
169
190
  required_rubygems_version: !ruby/object:Gem::Requirement
170
191
  none: false
171
192
  requirements:
@@ -187,6 +208,8 @@ test_files:
187
208
  - spec/cli/format_spec.rb
188
209
  - spec/fixtures/vcr/Razor_CLI_Parse/_new/_help/should_print_a_list_of_known_endpoints.yml
189
210
  - spec/fixtures/vcr/Razor_CLI_Navigate/with_no_parameters/should_fail_with_bad_JSON.yml
211
+ - spec/fixtures/vcr/Razor_CLI_Navigate/accept-language_header/should_allow_other_accept-language_headers.yml
212
+ - spec/fixtures/vcr/Razor_CLI_Navigate/accept-language_header/should_set_the_accept-language_header.yml
190
213
  - spec/fixtures/vcr/Razor_CLI_Navigate/with_authentication/should_supply_that_to_the_API_service.yml
191
214
  - spec/fixtures/vcr/Razor_CLI_Navigate/with_authentication/should_preserve_that_across_navigation.yml
192
215
  - spec/fixtures/vcr/Razor_CLI_Navigate/with_multiple_arguments_with_same_name/combining_as_an_object/should_fail_with_mixed_types_array_then_hash_.yml
@@ -220,3 +243,4 @@ test_files:
220
243
  - spec/vcr_library.rb
221
244
  - spec/version_spec.rb
222
245
  - spec/spec_helper.rb
246
+ - spec/locales/config.yaml