remote_table 0.2.14 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.14
1
+ 0.2.15
@@ -7,8 +7,13 @@ class RemoteTable
7
7
  def initialize(bus)
8
8
  raise(ArgumentError, "RemoteTable needs :url option") unless bus[:url].present?
9
9
  @parsed_url = URI.parse bus[:url]
10
- if @parsed_url.host == 'spreadsheets.google.com' and (bus[:format].blank? or bus[:format].to_s == 'csv')
11
- @parsed_url.query = 'output=csv&' + @parsed_url.query.sub(/\&*output=.*(\&|\z)/, '')
10
+ if @parsed_url.host == 'spreadsheets.google.com'
11
+ if bus[:format].blank? or bus[:format].to_s == 'csv'
12
+ @parsed_url.query = 'output=csv&' + @parsed_url.query.sub(/\&?output=.*?(\&|\z)/, '\1')
13
+ end
14
+ if bus[:sheet].present?
15
+ @parsed_url.query = "gid=#{bus[:sheet]}&single=true&" + @parsed_url.query.gsub(/\&?(?:gid|single)=.*?(\&|\z)/, '\1')
16
+ end
12
17
  end
13
18
  @form_data = bus[:form_data]
14
19
  end
data/remote_table.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{remote_table}
8
- s.version = "0.2.14"
8
+ s.version = "0.2.15"
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"]
@@ -99,6 +99,14 @@ class RemoteTableTest < Test::Unit::TestCase
99
99
  assert_equal 'Rocky Mountain', t.rows.last['PAD district name']
100
100
  assert_equal 'WY', t.rows.last['State']
101
101
  end
102
+
103
+ should "open a Google Docs url (as a CSV, with sheet options)" do
104
+ t = RemoteTable.new(:url => 'http://spreadsheets.google.com/pub?single=false&key=t5HM1KbaRngmTUbntg8JwPA&gid=5', :sheet => 0)
105
+ assert_equal 'Gulf Coast', t.rows.first['PAD district name']
106
+ assert_equal 'AL', t.rows.first['State']
107
+ assert_equal 'Rocky Mountain', t.rows.last['PAD district name']
108
+ assert_equal 'WY', t.rows.last['State']
109
+ end
102
110
 
103
111
  should "open a Google Docs url as a CSV without headers" do
104
112
  t = RemoteTable.new(:url => 'http://spreadsheets.google.com/pub?key=t5HM1KbaRngmTUbntg8JwPA', :skip => 1, :headers => false)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 14
9
- version: 0.2.14
8
+ - 15
9
+ version: 0.2.15
10
10
  platform: ruby
11
11
  authors:
12
12
  - Seamus Abshere