remote_table 0.2.9 → 0.2.10

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.9
1
+ 0.2.10
data/lib/remote_table.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  require 'digest/md5'
2
2
  require 'iconv'
3
+ require 'uri'
4
+ require 'tmpdir'
3
5
  require 'active_support'
4
6
  begin; require 'active_support/core_ext/object/blank'; rescue MissingSourceFile; end
5
7
  begin; require 'active_support/core_ext/string/inflections'; rescue MissingSourceFile; end
6
8
  begin; require 'active_support/core_ext/array/wrap'; rescue MissingSourceFile; end
7
9
  begin; require 'active_support/core_ext/hash/except'; rescue MissingSourceFile; end
8
- begin; require 'active_support/core_ext/string/starts_ends_with'; rescue MissingSourceFile; end
9
- require 'tempfile'
10
10
  require 'fastercsv'
11
11
  require 'slither'
12
12
  require 'roo'
@@ -3,10 +3,10 @@ class RemoteTable
3
3
  attr_accessor :parsed_url, :post_data, :username, :password
4
4
  attr_accessor :form_data
5
5
 
6
- # TODO: support post_data
7
6
  # TODO: support HTTP basic auth
8
7
  def initialize(bus)
9
- @parsed_url = URI.parse(bus[:url]) or raise "need url"
8
+ raise(ArgumentError, "RemoteTable needs :url option") unless bus[:url].present?
9
+ @parsed_url = URI.parse bus[:url]
10
10
  if @parsed_url.host == 'spreadsheets.google.com' and (bus[:format].blank? or bus[:format].to_s == 'csv')
11
11
  @parsed_url.query = 'output=csv&' + @parsed_url.query.sub(/\&*output=.*(\&|\z)/, '')
12
12
  end
@@ -36,8 +36,7 @@ class RemoteTable
36
36
 
37
37
  def staging_dir_path
38
38
  return @_staging_dir_path if @_staging_dir_path
39
- @_staging_dir_path = Tempfile.open(parsed_url.to_s.gsub(/[^a-z0-9]+/i, '_')[0,100]).path
40
- FileUtils.rm_f @_staging_dir_path
39
+ @_staging_dir_path = ::File.join Dir.tmpdir, rand.to_s
41
40
  FileUtils.mkdir @_staging_dir_path
42
41
  at_exit { FileUtils.rm_rf @_staging_dir_path }
43
42
  @_staging_dir_path
data/remote_table.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{remote_table}
8
- s.version = "0.2.9"
8
+ s.version = "0.2.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Seamus Abshere", "Andy Rossmeissl"]
12
- s.date = %q{2010-04-15}
12
+ s.date = %q{2010-04-16}
13
13
  s.description = %q{Remotely open and parse Excel XLS, ODS, CSV and fixed-width tables.}
14
14
  s.email = %q{seamus@abshere.net}
15
15
  s.extra_rdoc_files = [
@@ -14,7 +14,7 @@ class FuelOilParser
14
14
  row.keys.grep(/(.+) Residual Fuel Oil/) do |location_column_name|
15
15
  first_part = $1
16
16
  next if (cost = row[location_column_name]).blank? or (date = row['Date']).blank?
17
- if first_part.starts_with?('U.S.')
17
+ if first_part.start_with?('U.S.')
18
18
  locatable = "united_states (Country)"
19
19
  elsif first_part.include?('PADD')
20
20
  /\(PADD (.*)\)/.match(first_part)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 9
9
- version: 0.2.9
8
+ - 10
9
+ version: 0.2.10
10
10
  platform: ruby
11
11
  authors:
12
12
  - Seamus Abshere
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-04-15 00:00:00 -04:00
18
+ date: 2010-04-16 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency