Skip to content

Commit

Permalink
Use ActiveSupport::JSON instead of JSON if available
Browse files Browse the repository at this point in the history
  • Loading branch information
niels committed Apr 1, 2009
1 parent eab4151 commit 17a1cb2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
7 changes: 6 additions & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ Additionally, geoplanet has the following gem dependencies:
* rest-client >= 0.9
* json >= 1.1.3

Please note that if you have ActiveSupport::JSON defined (either by
manually having loaded it or when you use geoplanet within a Rails
application) the json dependency will be ignored and geoplanet uses
ActiveSupport::JSON instead.

== INSTALL:

* gem install carlosparamio-geoplanet --source http://gems.github.com
Expand Down Expand Up @@ -120,4 +125,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6 changes: 3 additions & 3 deletions geoplanet.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = "geoplanet"
s.version = "0.2.0"
s.date = "2009-03-23"
s.version = "0.2.2"
s.date = "2009-04-01"
s.summary = "A Ruby wrapper for the Yahoo! GeoPlanet API."
s.email = "carlosparamio@gmail.com"
s.homepage = "http://github.com/carlosparamio/geoplanet/"
Expand All @@ -24,4 +24,4 @@ Gem::Specification.new do |s|

s.has_rdoc = false
s.rdoc_options = ["--main", "README.rdoc"]
end
end
15 changes: 13 additions & 2 deletions lib/geoplanet.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
%w{rubygems rest_client json}.each { |x| require x }
%w{rubygems rest_client}.each { |x| require x }

if defined?(ActiveSupport::JSON)
JSON = ActiveSupport::JSON
module JSON
def self.parse(json)
decode(json)
end
end
else
require 'json'
end

require 'geoplanet/version'
require 'geoplanet/base'
Expand All @@ -15,4 +26,4 @@ class << self
class BadRequest < StandardError; end
class NotFound < StandardError; end
class NotAcceptable < StandardError; end
end
end

0 comments on commit 17a1cb2

Please sign in to comment.