razor-client 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -5,12 +5,15 @@ backwards incompatible changes, especially to the database schema which
5
5
  would force you to rebuild all the machines that Razor is managing. Razor
6
6
  will become stable RSN.
7
7
 
8
- This is the command line client for the
9
- [Razor server](https://github.com/puppetlabs/razor-server) Please have a
10
- look at the Wiki over there for details.
8
+ This is the command line client for the [Razor
9
+ server](https://github.com/puppetlabs/razor-server) Please have a look at
10
+ the Wiki over there for details, in particular, the [Getting
11
+ Started](https://github.com/puppetlabs/razor-server/wiki/Getting-started)
12
+ page contains instructions about installation and setup of the client.
11
13
 
12
14
  ## Getting in touch
13
15
 
16
+ * bug/issue tracker: [RAZOR project in JIRA](https://tickets.puppetlabs.com/browse/RAZOR)
14
17
  * on IRC: `#puppet-razor` on [freenode](http://freenode.net/)
15
18
  * mailing list: [puppet-razor@googlegroups.com](http://groups.google.com/group/puppet-razor)
16
19
 
data/bin/razor CHANGED
@@ -4,20 +4,32 @@ require_relative "../lib/razor/cli"
4
4
 
5
5
  include Razor::CLI::Format
6
6
 
7
- parse = Razor::CLI::Parse.new(ARGV)
7
+ def die(message = nil)
8
+ puts "Error: #{message}" if message
9
+ exit 1
10
+ end
11
+
12
+ begin
13
+ parse = Razor::CLI::Parse.new(ARGV)
14
+ rescue Razor::CLI::InvalidURIError => e
15
+ die e.message
16
+ end
17
+
8
18
  if parse.show_help?
9
19
  puts parse.help
10
20
  exit 0
11
21
  end
22
+
12
23
  begin
13
24
  document = parse.navigate.get_document
14
25
  url = parse.navigate.last_url
15
26
  puts "From #{url}:\n\n#{format_document document}\n\n"
16
27
  rescue Razor::CLI::NavigationError => e
17
- puts "Error: #{e}\n#{parse.help}\n\n"
28
+ die "#{e}\n#{parse.help}\n\n"
18
29
  rescue SocketError, Errno::ECONNREFUSED => e
19
30
  puts "Error: Could not connect to the server at #{parse.api_url}"
20
31
  puts " #{e}\n"
32
+ die
21
33
  rescue RestClient::Exception => e
22
34
  r = e.response
23
35
  puts "Error from doing #{r.args[:method].to_s.upcase} #{r.args[:url]}"
@@ -33,4 +45,5 @@ rescue RestClient::Exception => e
33
45
  # what happened has failed. Just dump the response
34
46
  puts r.body
35
47
  end
48
+ die
36
49
  end
@@ -53,7 +53,11 @@ module Razor::CLI
53
53
  output = "#{f.rjust key_indent + 2}: "
54
54
  output << case value
55
55
  when Hash
56
- "\n" + format_object(value, key_indent + 4).rstrip
56
+ if value.empty?
57
+ "{}"
58
+ else
59
+ "\n" + format_object(value, key_indent + 4).rstrip
60
+ end
57
61
  when Array
58
62
  if value.all? { |v| v.is_a?(String) }
59
63
  "[" + value.map(&:inspect).join(",") + "]"
@@ -67,10 +67,7 @@ module Razor::CLI
67
67
  body[$1] = convert_arg(cmd["name"], $1, ($3 || @segments.shift))
68
68
  end
69
69
  end
70
- # Parse JSON-valued arguments
71
- if cmd["name"] == "create-tag" && body["rule"]
72
- body["rule"] = JSON::parse(body["rule"])
73
- end
70
+
74
71
  body = JSON::parse(File::read(body["json"])) if body["json"]
75
72
  [cmd, body]
76
73
  end
@@ -87,6 +84,10 @@ module Razor::CLI
87
84
 
88
85
  if obj.is_a?(Hash) && obj["id"]
89
86
  @doc = json_get(obj["id"])
87
+ # strip the wrapper around collections
88
+ if @doc.is_a? Hash and @doc["items"].is_a? Array
89
+ @doc = @doc["items"]
90
+ end
90
91
  @doc_url = obj["id"]
91
92
  elsif obj.is_a? Hash
92
93
  @doc = obj
@@ -128,6 +129,7 @@ module Razor::CLI
128
129
  end
129
130
 
130
131
  def convert_arg(cmd_name, arg_name, value)
132
+ value = nil if value == "null"
131
133
  self.class.arg_type(cmd_name, arg_name) == "json" ? JSON::parse(value) : value
132
134
  end
133
135
  end
data/razor-client.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "razor-client"
7
- spec.version = "0.11.0"
7
+ spec.version = "0.12.0"
8
8
  spec.authors = ["Puppet Labs"]
9
9
  spec.email = ["info@puppetlabs.com"]
10
10
  spec.description = "The client for the Razor server"
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^spec/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.required_ruby_version = '>= 1.9.3'
22
+
21
23
  spec.add_dependency "rest-client"
22
24
  spec.add_dependency "terminal-table"
23
25
 
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: 0.11.0
4
+ version: 0.12.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: 2013-11-26 00:00:00.000000000 Z
12
+ date: 2014-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -119,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - ! '>='
121
121
  - !ruby/object:Gem::Version
122
- version: '0'
122
+ version: 1.9.3
123
123
  required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  none: false
125
125
  requirements: