lib/remote_table/properties.rb in remote_table-1.1.10 vs lib/remote_table/properties.rb in remote_table-1.2.0
- old
+ new
@@ -15,15 +15,38 @@
@uri.query = 'output=csv&' + @uri.query.sub(/\&?output=.*?(\&|\z)/, '\1')
end
@uri
end
+ # Whether to stream the rows without caching them. Saves memory, but you have to re-download the file every time you...
+ # * call []
+ # * call each
+ # Defaults to false.
+ def streaming
+ t.options['streaming'] || false
+ end
+
+ # Defaults to true.
+ def warn_on_multiple_downloads
+ t.options['warn_on_multiple_downloads'] != false
+ end
+
# The headers specified by the user
+ #
+ # Default: :first_row
def headers
- t.options['headers']
+ t.options['headers'].nil? ? :first_row : t.options['headers']
end
+ def use_first_row_as_header?
+ headers == :first_row
+ end
+
+ def output_class
+ headers == false ? ::Array : ::ActiveSupport::OrderedHash
+ end
+
# The sheet specified by the user as a number or a string
#
# Default: 0
def sheet
t.options['sheet'] || 0
@@ -50,11 +73,11 @@
# Likely external encoding
#
# Default: "UTF-8"
def encoding
- @encoding ||= ::Array.wrap(t.options['encoding'] || [ 'UTF-8', 'US-ASCII', 'ASCII-8BIT' ])
+ @encoding ||= ::Array.wrap(t.options['encoding'] || [ 'ISO-8859-1', 'US-ASCII', 'WINDOWS-1252', 'ASCII-8BIT', 'UTF-8' ])
end
# The delimiter
#
# Default: ","
@@ -69,11 +92,21 @@
# The XPath used to find columns
def column_xpath
t.options['column_xpath']
end
+
+ # The CSS selector used to find rows
+ def row_css
+ t.options['row_css']
+ end
+ # The CSS selector used to find columns
+ def column_css
+ t.options['column_css']
+ end
+
# The compression type.
#
# Default: guessed from URI.
#
# Can be specified as: "gz", "zip", "bz2", "exe" (treated as "zip")
@@ -203,9 +236,11 @@
Format::OpenOffice
when /fixed_?width/
Format::FixedWidth
when /htm/
Format::HTML
+ when /xml/
+ Format::XML
else
Format::Delimited
end
end
end