tabular 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -3,9 +3,17 @@ module Tabular
3
3
  class Table
4
4
  attr_reader :rows
5
5
 
6
+ # +file+ : file path as String or File
6
7
  # Assumes .txt = tab-delimited, .csv = CSV, .xls = Excel. Assumes first row is the header.
7
8
  # Normalizes column names to lower-case with underscores.
8
- def self.read(file_path, *options)
9
+ def self.read(file, *options)
10
+ file_path = case file
11
+ when File
12
+ file.path
13
+ else
14
+ file
15
+ end
16
+
9
17
  raise "Could not find '#{file_path}'" unless File.exists?(file_path)
10
18
  options = extract_options(options)
11
19
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tabular}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Scott Willson"]
12
- s.date = %q{2010-06-08}
12
+ s.date = %q{2010-06-09}
13
13
  s.description = %q{Tabular is a Ruby library for reading, writing, and manipulating CSV, tab-delimited and Excel data.}
14
14
  s.email = %q{scott.willson@gmail.cpm}
15
15
  s.extra_rdoc_files = [
@@ -33,6 +33,11 @@ module Tabular
33
33
  assert_equal Date.new(2006, 1, 20), table[0][:date], "0.0"
34
34
  end
35
35
 
36
+ def test_read_from_excel_file
37
+ table = Table.read(File.new(File.expand_path(File.dirname(__FILE__) + "/fixtures/excel.xls")))
38
+ assert_equal Date.new(2006, 1, 20), table[0][:date], "0.0"
39
+ end
40
+
36
41
  def test_read_as
37
42
  table = Table.read(File.expand_path(File.dirname(__FILE__) + "/fixtures/sample.lif"), :as => :csv)
38
43
  assert_equal 4, table.rows.size, "rows"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Scott Willson
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-08 00:00:00 -07:00
17
+ date: 2010-06-09 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies: []
20
20