Skip to content

Commit

Permalink
replace multi_json dependency with regular stdlib JSON
Browse files Browse the repository at this point in the history
JSON has been part of the ruby stdlib since 1.9.0 (see
ruby/ruby@af1c4167), and the latest version of
google-api-client requires ruby 2.0 or better so we can assume it's available
  • Loading branch information
yob committed Feb 25, 2016
1 parent b191e60 commit 4b9a63c
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 11 deletions.
1 change: 0 additions & 1 deletion bin/generate-api
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require 'thor'
require 'open-uri'
require 'google/apis/discovery_v1'
require 'google/apis/generator'
require 'multi_json'
require 'logger'

module Google
Expand Down
1 change: 0 additions & 1 deletion google-api-client.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib', 'generated', 'third_party']

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 'activesupport', '>= 3.2'
spec.add_runtime_dependency 'addressable', '~> 2.3'
Expand Down
7 changes: 3 additions & 4 deletions lib/google/api_client/client_secrets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.


require 'compat/multi_json'
require 'json'


module Google
Expand Down Expand Up @@ -71,7 +70,7 @@ def self.load(filename=nil)
search_path = File.expand_path(File.join(search_path, '..'))
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)
end

Expand Down Expand Up @@ -119,7 +118,7 @@ def initialize(options={})
# @return [String]
# JSON
def to_json
return MultiJson.dump(to_hash)
return Json.dump(to_hash)
end

def to_hash
Expand Down
4 changes: 2 additions & 2 deletions lib/google/apis/core/api_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
require 'addressable/template'
require 'google/apis/core/http_command'
require 'google/apis/errors'
require 'multi_json'
require 'json'
require 'retriable'

module Google
Expand Down Expand Up @@ -113,7 +113,7 @@ def check_status(status, header = nil, body = nil, message = nil)
# HTTP response body
# @return [Hash]
def parse_error(body)
hash = MultiJson.load(body)
hash = JSON.load(body)
hash['error']['errors'].first
rescue
nil
Expand Down
2 changes: 1 addition & 1 deletion lib/google/apis/generator/annotator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
require 'logger'
require 'erb'
require 'yaml'
require 'multi_json'
require 'json'
require 'active_support/inflector'
require 'google/apis/core/logging'
require 'google/apis/generator/template'
Expand Down
4 changes: 2 additions & 2 deletions spec/google/api_client/client_secrets_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
RSpec.describe Google::APIClient::ClientSecrets do
describe '::new' do
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
subject { Google::APIClient::ClientSecrets.new(data) }
Expand Down Expand Up @@ -367,7 +367,7 @@
context 'with invalid JSON file' do
it 'should raise exception' do
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

Expand Down

0 comments on commit 4b9a63c

Please sign in to comment.