Skip to content

Commit

Permalink
Added transparent compatibility with MultiJson legacy api for #132
Browse files Browse the repository at this point in the history
Original source for the updated API was #122.

Also see sferik/rails@5e62670
for the source implementation of this.
  • Loading branch information
colszowka committed May 10, 2012
1 parent eb6a231 commit c9120e6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions lib/simplecov/result_merger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ def resultset_path
# Loads the cached resultset from YAML and returns it as a Hash
def resultset
if stored_data
MultiJson.load(stored_data)
# Detect and use available MultiJson API - it changed in v1.3
if MultiJson.respond_to?(:adapter)
MultiJson.load(stored_data)
else
MultiJson.decode(stored_data)
end
else
{}
end
Expand Down Expand Up @@ -71,7 +76,12 @@ def store_result(result)
if defined? ::JSON
f.puts JSON.pretty_generate(new_set)
else
f.puts MultiJson.dump(new_set)
# Detect and use available MultiJson API - it changed in v1.3
if MultiJson.respond_to?(:adapter)
f.puts MultiJson.dump(new_set)
else
f.puts MultiJson.encode(new_set)
end
end
end
true
Expand Down
2 changes: 1 addition & 1 deletion simplecov.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
gem.description = %Q{Code coverage for Ruby 1.9 with a powerful configuration library and automatic merging of coverage across test suites}
gem.summary = gem.description

gem.add_dependency 'multi_json', '~> 1.3'
gem.add_dependency 'multi_json', '~> 1.0'
gem.add_dependency 'simplecov-html', '~> 0.5.3'
gem.add_development_dependency 'aruba'
gem.add_development_dependency 'capybara'
Expand Down

0 comments on commit c9120e6

Please sign in to comment.