Skip to content

Commit

Permalink
Merge pull request chef#9 from RiotGames/remove_json_deps
Browse files Browse the repository at this point in the history
Remove JSON and MultiJson as dependencies
  • Loading branch information
reset committed Jun 8, 2013
2 parents 0467832 + 7c63091 commit 96b9b52
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
2 changes: 0 additions & 2 deletions berkshelf-api.gemspec
Expand Up @@ -23,8 +23,6 @@ Gem::Specification.new do |spec|
spec.add_dependency 'celluloid', '~> 0.14.0'
spec.add_dependency 'reel', '= 0.4.0.pre'
spec.add_dependency 'grape', '>= 0.3.2'
spec.add_dependency 'multi_json', '>= 1.0.4'
spec.add_dependency 'json', '~> 1.7.7'
spec.add_dependency 'hashie', '>= 2.0.4'
spec.add_dependency 'faraday'
spec.add_dependency 'faraday_middleware'
Expand Down
2 changes: 1 addition & 1 deletion lib/berkshelf/api.rb
@@ -1,9 +1,9 @@
require 'grape'
require 'celluloid'
require 'multi_json'
require 'hashie'
require 'faraday'
require 'faraday_middleware'
require 'json'
require 'zlib'
require 'rubygems/package'
require 'ridley'
Expand Down
6 changes: 3 additions & 3 deletions lib/berkshelf/api/dependency_cache.rb
Expand Up @@ -23,11 +23,11 @@ class << self
#
# @return [DependencyCache]
def from_file(filepath)
contents = MultiJson.decode(File.read(filepath.to_s))
contents = JSON.parse(File.read(filepath.to_s))
new(contents)
rescue Errno::ENOENT => ex
raise Berkshelf::SaveNotFoundError.new(ex)
rescue MultiJson::LoadError => ex
rescue JSON::ParserError => ex
raise Berkshelf::InvalidSaveError.new(ex)
end
end
Expand All @@ -52,7 +52,7 @@ def to_hash

# @return [String]
def to_json(options = {})
MultiJson.encode(to_hash, options)
JSON.generate(to_hash, options)
end

# @return [Array<RemoteCookbook>]
Expand Down
2 changes: 1 addition & 1 deletion lib/berkshelf/api/endpoint/v1.rb
Expand Up @@ -6,7 +6,7 @@ class V1 < Endpoint::Base
format :json

rescue_from Grape::Exceptions::Validation do |e|
body = MultiJson.encode(status: e.status, message: e.message, param: e.param)
body = JSON.generate({status: e.status, message: e.message, param: e.param})
rack_response(body, e.status, "Content-type" => "application/json")
end

Expand Down
6 changes: 3 additions & 3 deletions spec/unit/berkshelf/api/dependency_cache_spec.rb
Expand Up @@ -11,7 +11,7 @@

context "when the file contains valid json" do
before do
@tempfile.write(MultiJson.encode(brooke: "winsor"))
@tempfile.write(JSON.generate({brooke: "winsor"}))
@tempfile.flush
end

Expand Down Expand Up @@ -43,14 +43,14 @@
end

let(:chicken) do
{ "1.0" =>
{ "1.0" =>
{ :dependencies => { "tuna" => "= 3.0.0" },
:platforms => { "centos" => ">= 0.0.0" }
}
}
end
let(:tuna) do
{ "3.0.0" =>
{ "3.0.0" =>
{ :dependencies => { },
:platforms => { "centos" => ">= 0.0.0" }
}
Expand Down

0 comments on commit 96b9b52

Please sign in to comment.