Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
82 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
module Oj | ||
# Current version of the module. | ||
VERSION = '2.0.11' | ||
VERSION = '2.0.12' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env ruby | ||
# encoding: UTF-8 | ||
|
||
# Ubuntu does not accept arguments to ruby when called using env. To get warnings to show up the -w options is | ||
# required. That can be set in the RUBYOPT environment variable. | ||
# export RUBYOPT=-w | ||
|
||
$VERBOSE = true | ||
|
||
$: << File.join(File.dirname(__FILE__), "../lib") | ||
$: << File.join(File.dirname(__FILE__), "../ext") | ||
|
||
require 'test/unit' | ||
require 'stringio' | ||
require 'oj' | ||
require 'json' | ||
|
||
class MimicAfter < ::Test::Unit::TestCase | ||
|
||
def test0_mimic_json | ||
assert(!defined?(JSON).nil?) | ||
Oj.mimic_JSON | ||
end | ||
|
||
# dump | ||
def test_dump_string | ||
Oj.default_options= {:indent => 2} # JSON this will not change anything | ||
json = JSON.dump([1, true, nil]) | ||
assert_equal(%{[ | ||
1, | ||
true, | ||
null]}, json) | ||
end | ||
|
||
end # MimicAfter |
9061c07
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Peter, thanks for the sweet gem. Thought you should be aware of a possible problem that these changes could cause. This change seems to cause an exception to be raised by ExecJS if this version of the gem (
2.0.12
) is bundled into a rails application along withuglifier
andoj_mimic_json
andoj_mimic_json
is required prior touglifier
.Prior to this version of the gem,
oj_mimic_json
had to be required before the call toBundler.require
in a rails app, to ensure that it was recognized beforejson
ormulti_json
were required (otherwise a fatal error would get thrown). Because of this, here is what myconfig/boot.rb
looked like:Just updated the bundled version of Oj for this app from
2.0.11
to2.0.12
, went to runrails console
and here is the error that's getting spit out:Removing the
require 'oj_mimic_json'
line from myconfig/boot.rb
file seems to make these errors go away, but it makes me a little nervous as to whether this error could pop up when the application is deployed into production, since it appears that if theoj_mimic_json
gem is required prior tomulti_json
(which many gems seem to require), then this exception will get raised, and I don't think the order in which Bundler requires gems can be guaranteed, right?Should I just remove the
oj_mimic_json
gem from my bundle and then manually callOj.mimic_JSON()
in myconfig/application.rb
after theBundler.require
block? Seems like it would be a safer in ensuring this exception won't get raised.9061c07
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expected the existing oj_mimic_json gem to work as before. I kept that part the same. Calling mimic after requiring the json gem should overwrite the json gem's methods. Over-ridding the json gem has been a tough one to keep working. Calling mimic after loading the json may be the best approach. Any feedback on what works best for you would be appreciated.