Skip to content

Commit

Permalink
Support MultiJson 1.2 for Rails 3.0 and 3.1
Browse files Browse the repository at this point in the history
Should fix #247
  • Loading branch information
presidentbeef committed Jan 31, 2013
1 parent 39be549 commit 1434d9a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion brakeman.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ Gem::Specification.new do |s|
s.add_dependency "erubis", "~>2.6"
s.add_dependency "haml", "~>3.0"
s.add_dependency "sass", "~>3.0"
s.add_dependency "multi_json", "~>1.3"
s.add_dependency "multi_json", "~>1.2"
end
26 changes: 23 additions & 3 deletions lib/brakeman/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,26 @@
# CSV is now FasterCSV in ruby 1.9
end

#MultiJson interface changed in 1.3.0, but need
#to support older MultiJson for Rails 3.1.
if MultiJson.respond_to? :default_adapter
mj_engine = MultiJson.default_adapter
else
mj_engine = MultiJson.default_engine

module MultiJson
def self.dump *args
encode *args
end

def self.load *args
decode *args
end
end
end

#This is so OkJson will work with symbol values
if MultiJson.default_adapter == :ok_json
if mj_engine == :ok_json
class Symbol
def to_json
self.to_s.inspect
Expand Down Expand Up @@ -694,11 +712,13 @@ def to_json
:brakeman_version => Brakeman::Version
}

MultiJson.dump({
report_info = {
:scan_info => scan_info,
:warnings => warnings,
:errors => errors
}, :pretty => true)
}

MultiJson.dump(report_info, :pretty => true)
end

def all_warnings
Expand Down

0 comments on commit 1434d9a

Please sign in to comment.