This commit is contained in:
Steve Bazyl 2016-02-25 09:39:46 -08:00
commit acf2b0ec61
11 changed files with 28 additions and 22 deletions

View File

@ -1,5 +1,6 @@
language: ruby language: ruby
rvm: rvm:
- 2.3.0
- 2.2 - 2.2
- 2.0.0 - 2.0.0
- 2.1 - 2.1

View File

@ -220,8 +220,8 @@ Samples for versions 0.9 and onward can be found in the `samples` directory.
Contributions for additional samples are welcome. See [CONTRIBUTING](CONTRIBUTING.md). Contributions for additional samples are welcome. See [CONTRIBUTING](CONTRIBUTING.md).
Samples for previous versions can be found in the Samples for previous versions can be found in the
[google-api-ruby-client-samples](https://github.com/google/google-api-ruby-client-samples) [samples](samples)
repository. folder.
## Generating APIs ## Generating APIs

View File

@ -6,7 +6,6 @@ require 'thor'
require 'open-uri' require 'open-uri'
require 'google/apis/discovery_v1' require 'google/apis/discovery_v1'
require 'google/apis/generator' require 'google/apis/generator'
require 'multi_json'
require 'logger' require 'logger'
module Google module Google

View File

@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib', 'generated', 'third_party'] spec.require_paths = ['lib', 'generated', 'third_party']
spec.add_runtime_dependency 'representable', '~> 2.3.0' spec.add_runtime_dependency 'representable', '~> 2.3.0'
spec.add_runtime_dependency 'multi_json', '~> 1.11'
spec.add_runtime_dependency 'retriable', '~> 2.0' spec.add_runtime_dependency 'retriable', '~> 2.0'
spec.add_runtime_dependency 'activesupport', '>= 3.2' spec.add_runtime_dependency 'activesupport', '>= 3.2'
spec.add_runtime_dependency 'addressable', '~> 2.3' spec.add_runtime_dependency 'addressable', '~> 2.3'

View File

@ -12,8 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
require 'json'
require 'compat/multi_json'
module Google module Google
@ -71,7 +70,7 @@ module Google
search_path = File.expand_path(File.join(search_path, '..')) search_path = File.expand_path(File.join(search_path, '..'))
end end
end end
data = File.open(filename, 'r') { |file| MultiJson.load(file.read) } data = File.open(filename, 'r') { |file| JSON.load(file.read) }
return self.new(data) return self.new(data)
end end
@ -119,7 +118,7 @@ module Google
# @return [String] # @return [String]
# JSON # JSON
def to_json def to_json
return MultiJson.dump(to_hash) return Json.dump(to_hash)
end end
def to_hash def to_hash

View File

@ -17,7 +17,7 @@ require 'addressable/uri'
require 'addressable/template' require 'addressable/template'
require 'google/apis/core/http_command' require 'google/apis/core/http_command'
require 'google/apis/errors' require 'google/apis/errors'
require 'multi_json' require 'json'
require 'retriable' require 'retriable'
module Google module Google
@ -113,7 +113,7 @@ module Google
# HTTP response body # HTTP response body
# @return [Hash] # @return [Hash]
def parse_error(body) def parse_error(body)
hash = MultiJson.load(body) hash = JSON.load(body)
hash['error']['errors'].first hash['error']['errors'].first
rescue rescue
nil nil

View File

@ -303,6 +303,7 @@ module Google
end end
req.header.update(header) req.header.update(header)
req.options.timeout = options.timeout_sec req.options.timeout = options.timeout_sec
req.options.open_timeout = options.open_timeout_sec
end end
private private

View File

@ -38,8 +38,8 @@ module Google
def getter_fn(name) def getter_fn(name)
ivar_name = "@#{name}".to_sym ivar_name = "@#{name}".to_sym
lambda do |_| lambda do |_|
if respond_to?(:[]) if respond_to?(:fetch)
self[name] || instance_variable_get(ivar_name) fetch(name, instance_variable_get(ivar_name))
else else
instance_variable_get(ivar_name) instance_variable_get(ivar_name)
end end

View File

@ -15,7 +15,7 @@
require 'logger' require 'logger'
require 'erb' require 'erb'
require 'yaml' require 'yaml'
require 'multi_json' require 'json'
require 'active_support/inflector' require 'active_support/inflector'
require 'google/apis/core/logging' require 'google/apis/core/logging'
require 'google/apis/generator/template' require 'google/apis/generator/template'

View File

@ -23,7 +23,7 @@ FIXTURES_PATH = File.expand_path('../../../fixtures', __FILE__)
RSpec.describe Google::APIClient::ClientSecrets do RSpec.describe Google::APIClient::ClientSecrets do
describe '::new' do describe '::new' do
let(:filename) { File.join(FIXTURES_PATH, 'files', 'client_secrets.json') } let(:filename) { File.join(FIXTURES_PATH, 'files', 'client_secrets.json') }
let(:data) { File.open(filename, 'r') { |file| MultiJson.load(file.read) } } let(:data) { File.open(filename, 'r') { |file| JSON.load(file.read) } }
context 'without options' do context 'without options' do
subject { Google::APIClient::ClientSecrets.new(data) } subject { Google::APIClient::ClientSecrets.new(data) }
@ -367,7 +367,7 @@ RSpec.describe Google::APIClient::ClientSecrets do
context 'with invalid JSON file' do context 'with invalid JSON file' do
it 'should raise exception' do it 'should raise exception' do
file = File.join(FIXTURES_PATH, 'files', 'invalid.json') file = File.join(FIXTURES_PATH, 'files', 'invalid.json')
expect { Google::APIClient::ClientSecrets.load(file) }.to raise_exception(MultiJson::ParseError) expect { Google::APIClient::ClientSecrets.load(file) }.to raise_exception(JSON::ParserError)
end end
end end

View File

@ -28,7 +28,8 @@ RSpec.describe Google::Apis::Core::JsonRepresentation do
attr_accessor :nil_value attr_accessor :nil_value
attr_accessor :numeric_value attr_accessor :numeric_value
attr_accessor :string_value attr_accessor :string_value
attr_accessor :boolean_value attr_accessor :boolean_value_true
attr_accessor :boolean_value_false
attr_accessor :date_value attr_accessor :date_value
attr_accessor :bytes_value attr_accessor :bytes_value
attr_accessor :items attr_accessor :items
@ -44,7 +45,8 @@ RSpec.describe Google::Apis::Core::JsonRepresentation do
property :nil_value, as: 'nilValue' property :nil_value, as: 'nilValue'
property :numeric_value, as: 'numericValue' property :numeric_value, as: 'numericValue'
property :string_value, as: 'stringValue' property :string_value, as: 'stringValue'
property :boolean_value, as: 'booleanValue' property :boolean_value_true, as: 'booleanValueTrue'
property :boolean_value_false, as: 'booleanValueFalse'
property :date_value, as: 'dateValue', type: DateTime property :date_value, as: 'dateValue', type: DateTime
property :bytes_value, as: 'bytesValue', base64: true property :bytes_value, as: 'bytesValue', base64: true
property :items property :items
@ -75,7 +77,8 @@ RSpec.describe Google::Apis::Core::JsonRepresentation do
end end
it 'serializes boolean values' do it 'serializes boolean values' do
expect(json).to be_json_eql(%(true)).at_path('booleanValue') expect(json).to be_json_eql(%(true)).at_path('booleanValueTrue')
expect(json).to be_json_eql(%(false)).at_path('booleanValueFalse')
end end
it 'serializes date values' do it 'serializes date values' do
@ -107,7 +110,8 @@ RSpec.describe Google::Apis::Core::JsonRepresentation do
model.numeric_value = 123 model.numeric_value = 123
model.string_value = 'test' model.string_value = 'test'
model.date_value = DateTime.new(2015, 5, 1, 12) model.date_value = DateTime.new(2015, 5, 1, 12)
model.boolean_value = true model.boolean_value_true = true
model.boolean_value_false = false
model.bytes_value = 'Hello world' model.bytes_value = 'Hello world'
model.items = [1, 2, 3] model.items = [1, 2, 3]
model.child = child_class.new model.child = child_class.new
@ -127,7 +131,8 @@ RSpec.describe Google::Apis::Core::JsonRepresentation do
string_value: 'test', string_value: 'test',
numeric_value: 123, numeric_value: 123,
date_value: DateTime.new(2015, 5, 1, 12), date_value: DateTime.new(2015, 5, 1, 12),
boolean_value: true, boolean_value_true: true,
boolean_value_false: false,
bytes_value: 'Hello world', bytes_value: 'Hello world',
items: [1, 2, 3], items: [1, 2, 3],
child: { child: {
@ -146,7 +151,8 @@ RSpec.describe Google::Apis::Core::JsonRepresentation do
json = <<EOF json = <<EOF
{ "stringValue": "test", { "stringValue": "test",
"nilValue": null, "nilValue": null,
"booleanValue": true, "booleanValueTrue": true,
"booleanValueFalse": false,
"numericValue": 123, "numericValue": 123,
"dateValue": "2015-05-01T12:00:00+00:00", "dateValue": "2015-05-01T12:00:00+00:00",
"bytesValue": "SGVsbG8gd29ybGQ=", "bytesValue": "SGVsbG8gd29ybGQ=",
@ -170,7 +176,8 @@ EOF
end end
it 'deserializes boolean values' do it 'deserializes boolean values' do
expect(model.boolean_value).to be_truthy expect(model.boolean_value_true).to be_truthy
expect(model.boolean_value_false).to be_falsey
end end
it 'deserializes date values' do it 'deserializes date values' do