lib/terraformer.rb in terraformer-0.0.8 vs lib/terraformer.rb in terraformer-0.0.9
- old
+ new
@@ -43,11 +43,11 @@
# parses geojson into a terraformer object. parameter must be a +Hash+,
# +String+ or +File+ containing a valid geojson object. return class type
# is determined by +type+ property.
#
def self.parse geojson
- if String === geojson
+ if geojson.is_a?(String) or geojson.respond_to?(:read)
geojson = File.read geojson if File.readable? geojson
geojson = JSON.parse geojson
end
raise ArgumentError.new "invalid arg: #{geojson}" unless Hash === geojson
@@ -60,9 +60,10 @@
# open OS's default browser to geojson.io with param data
#
def self.geojson_io data
require 'launchy'
+ require 'uri'
Launchy.open "http://geojson.io/#data=data:application/json,#{URI.encode_www_form_component data.to_json}"
end
# abstract base class for terraformer objects. implements +bbox+ and
# +envelope+.