lib/sxp.rb in sxp-0.0.4 vs lib/sxp.rb in sxp-0.0.5
- old
+ new
@@ -1,5 +1,22 @@
+require 'rational'
+require 'stringio'
+
+if RUBY_VERSION < '1.8.7'
+ # @see http://rubygems.org/gems/backports
+ begin
+ require 'backports/1.8.7'
+ rescue LoadError
+ begin
+ require 'rubygems'
+ require 'backports/1.8.7'
+ rescue LoadError
+ abort "SXP.rb requires Ruby 1.8.7 or the Backports gem (hint: `gem install backports')."
+ end
+ end
+end
+
require 'sxp/version'
require 'sxp/extensions'
require 'sxp/writer'
module SXP
@@ -14,11 +31,11 @@
#
# @param [String, #to_s] url
# @param [Hash{Symbol => Object}] options
# @return [Enumerable<Object>]
def self.read_url(url, options = {})
- require 'openuri'
+ require 'open-uri'
open(url.to_s, 'rb', nil, options) { |io| read_all(io, options) }
end
##
# Reads all S-expressions from the given input files.
@@ -46,20 +63,20 @@
#
# @param [IO, StringIO, String] input
# @param [Hash{Symbol => Object}] options
# @return [Enumerable<Object>]
def self.read_all(input, options = {})
- Reader.new(input, options).read_all
+ Reader::Scheme.new(input, options).read_all
end
##
# Reads one S-expression from the given input stream.
#
# @param [IO, StringIO, String] input
# @param [Hash{Symbol => Object}] options
# @return [Object]
def self.read(input, options = {})
- Reader.new(input, options).read
+ Reader::Scheme.new(input, options).read
end
class << self
alias_method :parse, :read
alias_method :parse_all, :read_all