Skip to content
This repository has been archived by the owner on Jun 10, 2018. It is now read-only.

Commit

Permalink
Replace multi_json with json
Browse files Browse the repository at this point in the history
  • Loading branch information
sferik committed May 12, 2013
1 parent 21a4237 commit 8e7d744
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
13 changes: 3 additions & 10 deletions lib/sprockets/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'sprockets/processed_asset'
require 'sprockets/server'
require 'sprockets/static_asset'
require 'multi_json'
require 'json'
require 'pathname'

module Sprockets
Expand Down Expand Up @@ -433,15 +433,8 @@ def matches_filter(filters, logical_path, filename)
end
end

# Feature detect newer MultiJson API
if MultiJson.respond_to?(:dump)
def json_decode(obj)
MultiJson.load(obj)
end
else
def json_decode(obj)
MultiJson.decode(obj)
end
def json_decode(obj)
JSON.load(obj)
end
end
end
24 changes: 7 additions & 17 deletions lib/sprockets/manifest.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'multi_json'
require 'json'
require 'securerandom'
require 'time'

Expand Down Expand Up @@ -64,7 +64,7 @@ def initialize(*args)
if File.exist?(@path)
data = json_decode(File.read(@path))
end
rescue MultiJson::DecodeError => e
rescue JSON::ParserError => e
logger.error "#{@path} is invalid: #{e.class} #{e.message}"
end

Expand Down Expand Up @@ -223,23 +223,13 @@ def save
end

private
# Feature detect newer MultiJson API
if MultiJson.respond_to?(:dump)
def json_decode(obj)
MultiJson.load(obj)
end

def json_encode(obj)
MultiJson.dump(obj)
end
else
def json_decode(obj)
MultiJson.decode(obj)
end
def json_decode(obj)
JSON.load(obj)
end

def json_encode(obj)
MultiJson.encode(obj)
end
def json_encode(obj)
JSON.dump(obj)
end

def logger
Expand Down
1 change: 0 additions & 1 deletion sprockets.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Gem::Specification.new do |s|
s.executables = ["sprockets"]

s.add_dependency "hike", "~> 1.2"
s.add_dependency "multi_json", "~> 1.0"
s.add_dependency "rack", "~> 1.0"
s.add_dependency "tilt", ["~> 1.1", "!= 1.3.0"]

Expand Down

0 comments on commit 8e7d744

Please sign in to comment.