razor-client 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,5 +1,8 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ # mime-types is a dependency of rest-client. We need to explicitly depend
4
+ # on it and pin its version to make sure this works with Ruby 1.8.7
5
+ gem 'mime-types', '< 2.0'
3
6
  gem 'rest-client'
4
7
  gem 'terminal-table'
5
8
 
@@ -38,6 +38,7 @@ PLATFORMS
38
38
 
39
39
  DEPENDENCIES
40
40
  kramdown
41
+ mime-types (< 2.0)
41
42
  rack-test
42
43
  rake
43
44
  rest-client
data/Rakefile CHANGED
@@ -1,5 +1,15 @@
1
1
  require 'rake'
2
2
  require "bundler/gem_tasks"
3
+
4
+ # Needed to make the client work on Ruby 1.8.7
5
+ unless Kernel.respond_to?(:require_relative)
6
+ module Kernel
7
+ def require_relative(path)
8
+ require File.join(File.dirname(caller[0]), path.to_str)
9
+ end
10
+ end
11
+ end
12
+
3
13
  require_relative 'spec/vcr_library'
4
14
 
5
15
  namespace :bundler do
data/bin/razor CHANGED
@@ -1,5 +1,15 @@
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
+ require 'rubygems'
3
13
  require_relative "../lib/razor/cli"
4
14
 
5
15
  include Razor::CLI::Format
@@ -35,7 +45,7 @@ rescue RestClient::Exception => e
35
45
  puts "Error from doing #{r.args[:method].to_s.upcase} #{r.args[:url]}"
36
46
  puts e.message
37
47
  begin
38
- body = JSON::parse(r.body)
48
+ body = MultiJson::load(r.body)
39
49
  puts body.delete("details") if body["details"]
40
50
  unless body.empty?
41
51
  puts format_document(body)
@@ -1,5 +1,5 @@
1
1
  require 'rest-client'
2
- require 'json'
2
+ require 'multi_json'
3
3
  require 'yaml'
4
4
 
5
5
  module Razor::CLI
@@ -68,7 +68,7 @@ module Razor::CLI
68
68
  end
69
69
  end
70
70
 
71
- body = JSON::parse(File::read(body["json"])) if body["json"]
71
+ body = MultiJson::load(File::read(body["json"])) if body["json"]
72
72
  [cmd, body]
73
73
  end
74
74
 
@@ -107,14 +107,14 @@ module Razor::CLI
107
107
  unless response.headers[:content_type] =~ /application\/json/
108
108
  raise "Received content type #{response.headers[:content_type]}"
109
109
  end
110
- JSON.parse(response.body)
110
+ MultiJson.load(response.body)
111
111
  end
112
112
 
113
113
  def json_post(url, body)
114
114
  headers = { :accept=>:json, "Content-Type" => :json }
115
- response = RestClient.post url, body.to_json, headers
115
+ response = RestClient.post url, MultiJson::dump(body), headers
116
116
  puts "POST #{url.to_s}\n#{body}\n-->\n#{response.body}" if @parse.dump_response?
117
- JSON::parse(response.body)
117
+ MultiJson::load(response.body)
118
118
  end
119
119
 
120
120
  private
@@ -130,7 +130,7 @@ module Razor::CLI
130
130
 
131
131
  def convert_arg(cmd_name, arg_name, value)
132
132
  value = nil if value == "null"
133
- self.class.arg_type(cmd_name, arg_name) == "json" ? JSON::parse(value) : value
133
+ self.class.arg_type(cmd_name, arg_name) == "json" ? MultiJson::load(value) : value
134
134
  end
135
135
  end
136
136
  end
@@ -15,7 +15,7 @@ module Razor::CLI
15
15
  @dump = true
16
16
  end
17
17
 
18
- opts.on "-U", "--url URL",
18
+ opts.on "-u", "--url URL",
19
19
  "The full Razor API URL, can also be set\n" + " "*37 +
20
20
  "with the RAZOR_API environment variable\n" + " "*37 +
21
21
  "(default #{DEFAULT_RAZOR_API})" do |url|
@@ -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.12.0"
7
+ spec.version = "0.13.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,8 +18,12 @@ 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'
21
+ spec.required_ruby_version
22
22
 
23
+ # mime-types is a dependency of rest-client. We need to explicitly depend
24
+ # on it and pin its version to make sure the gem works with Ruby 1.8.7
25
+ spec.add_dependency "mime-types", '< 2.0'
26
+ spec.add_dependency "multi_json"
23
27
  spec.add_dependency "rest-client"
24
28
  spec.add_dependency "terminal-table"
25
29
 
@@ -1,3 +1,12 @@
1
+ # Needed to make the client work on Ruby 1.8.7
2
+ unless Kernel.respond_to?(:require_relative)
3
+ module Kernel
4
+ def require_relative(path)
5
+ require File.join(File.dirname(caller[0]), path.to_str)
6
+ end
7
+ end
8
+ end
9
+
1
10
  require_relative '../spec_helper'
2
11
 
3
12
  describe Razor::CLI::Navigate do
@@ -1,3 +1,12 @@
1
+ # Needed to make the client work on Ruby 1.8.7
2
+ unless Kernel.respond_to?(:require_relative)
3
+ module Kernel
4
+ def require_relative(path)
5
+ require File.join(File.dirname(caller[0]), path.to_str)
6
+ end
7
+ end
8
+ end
9
+
1
10
  require "rspec/expectations"
2
11
  require_relative '../spec_helper'
3
12
 
@@ -3,7 +3,7 @@ SimpleCov.start do
3
3
  add_filter "/spec/"
4
4
  end
5
5
 
6
- require 'json'
6
+ require 'multi_json'
7
7
  require 'vcr'
8
8
 
9
9
  require_relative '../lib/razor'
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.12.0
4
+ version: 0.13.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,40 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-04 00:00:00.000000000 Z
12
+ date: 2014-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mime-types
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - <
20
+ - !ruby/object:Gem::Version
21
+ version: '2.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - <
28
+ - !ruby/object:Gem::Version
29
+ version: '2.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: multi_json
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
14
46
  - !ruby/object:Gem::Dependency
15
47
  name: rest-client
16
48
  requirement: !ruby/object:Gem::Requirement
@@ -119,7 +151,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
151
  requirements:
120
152
  - - ! '>='
121
153
  - !ruby/object:Gem::Version
122
- version: 1.9.3
154
+ version: '0'
123
155
  required_rubygems_version: !ruby/object:Gem::Requirement
124
156
  none: false
125
157
  requirements: