Skip to content

Commit

Permalink
JSON library loading tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
samlown committed Jul 2, 2010
1 parent e0f2e77 commit aa3942a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Expand Up @@ -25,7 +25,7 @@ begin
gemspec.files = %w( LICENSE README.md Rakefile THANKS.md history.txt couchrest.gemspec) + Dir["{examples,lib,spec,utils}/**/*"] - Dir["spec/tmp"]
gemspec.has_rdoc = true
gemspec.add_dependency("rest-client", ">= 1.5.1")
gemspec.add_dependency("json", "<= 1.4.2")
gemspec.add_dependency("json", "= 1.2.4") # json 1.4.3 has stack overflow issues!
# gemspec.add_dependency("couchrest_extended_document", ">= 1.0.0")
gemspec.version = CouchRest::VERSION
gemspec.date = "2010-07-01"
Expand Down Expand Up @@ -65,4 +65,4 @@ module Rake
end

Rake.remove_task("github:release")
Rake.remove_task("release")
Rake.remove_task("release")
13 changes: 9 additions & 4 deletions lib/couchrest.rb
Expand Up @@ -13,10 +13,15 @@
# limitations under the License.

require 'rubygems'
gem 'json', "<= 1.4.2"
require 'json'
gem 'rest-client', ">= 1.5.1"
require 'rest_client'
begin
unless Kernel.const_defined?("JSON")
gem 'json', '1.2.4'
require 'json'
end
rescue LoadError
raise "No compatible json library found, install json gem"
end

# Not sure why this is required, so removed until a reason is found!
$:.unshift File.dirname(__FILE__) unless
Expand Down Expand Up @@ -134,4 +139,4 @@ def self.inherited(subclass)
raise "ExtendedDocument is no longer included in CouchRest base driver, see couchrest_extended_document gem"
end

end
end

2 comments on commit aa3942a

@tapajos
Copy link
Member

@tapajos tapajos commented on aa3942a Jul 6, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sam,

Using this rescue we lost the message about recommended version of json. I think that the best usage is:

unless Kernel.const_defined?("JSON")
  gem 'json', '1.2.4'
  require 'json'
end

What's your opinion?

@samlown
Copy link
Member Author

@samlown samlown commented on aa3942a Jul 6, 2010

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think you're right, the 'gem' call should handle showing any useful messages for the version required. My mistale!

Please sign in to comment.