table_parser 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.txt CHANGED
@@ -35,7 +35,7 @@ Note the first column contains duplicated item, because the first row contains "
35
35
  html = "<html><body><table><tr><td>A</td><td>B</td></tr>\
36
36
  <tr><td rowspan=\"2\">1</td><td>2</td></tr> \
37
37
  <tr><td>3</td></tr></table></body></html>"
38
- table = TableParser::Table.new(html, "/html/body/table", false)
38
+ table = TableParser::Table.new(html, "/html/body/table", {:dup_rows => false})
39
39
  </pre>
40
40
 
41
41
  Which result in following parsed table:
@@ -47,7 +47,7 @@ Table&lt;TableColumn&lt;name=A, children=[1],[1]&gt;,TableColumn&lt;name=B, chil
47
47
 
48
48
  == DEVELOPERS:
49
49
 
50
- * Francis Chong francis at ignition dot hk
50
+ * Francis Chong, francis at ignition dot hk
51
51
 
52
52
  == LICENSE:
53
53
 
data/lib/table_parser.rb CHANGED
@@ -4,5 +4,5 @@ require 'table_parser/table'
4
4
  require 'table_parser/parser'
5
5
 
6
6
  module TableParser
7
- VERSION = '0.5.0'
7
+ VERSION = '0.5.1'
8
8
  end
@@ -1,10 +1,17 @@
1
1
  module TableParser
2
2
  class Table
3
3
  attr_reader :nodes, :columns
4
- def initialize(input, xpath_to_table="//table[0]", duplicate_colspan=true)
4
+ def initialize(input, xpath_to_table="//table[0]", options={})
5
+
6
+ if options.has_key? :dup_rows
7
+ dup_rows = options[:dup_rows]
8
+ else
9
+ dup_rows = true
10
+ end
11
+
5
12
  table = Parser.extract_table(input, xpath_to_table)
6
13
  @columns = Parser.extract_column_headers(table)
7
- @nodes = Parser.extract_nodes(table, @columns, duplicate_colspan)
14
+ @nodes = Parser.extract_nodes(table, @columns, dup_rows)
8
15
  end
9
16
 
10
17
  def to_s
@@ -18,7 +18,7 @@ class TestTableParser < Test::Unit::TestCase
18
18
  table = TableParser::Table.new "<html><body><table><tr><td>A</td><td>B</td></tr>\
19
19
  <tr><td rowspan=\"2\">1</td><td>2</td></tr> \
20
20
  <tr><td>3</td></tr></table></body></html>",
21
- "/html/body/table", false
21
+ "/html/body/table", {:dup_rows => false}
22
22
 
23
23
  puts table
24
24
  assert_equal(2, table.columns.size, 'header_count should = 2 ')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francis Chong