ruby-dita 0.4.3 → 0.5.0

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ruby-dita/table.rb +23 -8
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d1513f432d5b1035ecd0a8e75a36b95f2ed4686
4
- data.tar.gz: bb2d391e1c78bfdd228d88a579e75546dc4f0584
3
+ metadata.gz: 83ece111fe0ac7b5650bb2a3ca496ee8ac8a27a6
4
+ data.tar.gz: 4b1b28b1bc0dc917a426bb80ef951a3c390e627b
5
5
  SHA512:
6
- metadata.gz: b9593df6c0a1ca54198c376413f7ab36d0562e808ea1ca8f50fcb60eeed43ad251c53d52ad32416502f8bcf18a3d98bf64b9adfb4666c84b88b1921d0c9eded0
7
- data.tar.gz: 9f54b6c8a3d6528831343661b419abc268fbc797998ececfde64cae862f3c8f0f5ead45736283f99181e73115ec6a926b97564e2765e5547106fb5e2bfdf9714
6
+ metadata.gz: ce8b7933ddbfd7e051d65ed2de3a94086252c87347770172566cf60def113d6334cd89e78bfe26c4229ca3e59b3e563333d84fa2eb864a246d2c19cd80033b6b
7
+ data.tar.gz: 4580b04dba50973ee5c13d01f7987427ec59f21dee9cfda345ea9c2b3cca4179013cce874b683c4f64cc2b1df230b4501436e38814f61a28802e05acab11d6fe
@@ -9,11 +9,11 @@ module Dita
9
9
  def row(ary)
10
10
  return ary if ary.all? do |a| a.respond_to?(:name) and a.name == 'row' end
11
11
  Element.new('row') <<
12
- ary.collect do |entry|
13
- if entry.is_a?(Element) and entry.name == 'entry'
14
- entry
12
+ ary.collect do |e|
13
+ if e.is_a?(Element) and e.name == 'entry'
14
+ e
15
15
  else
16
- Element.new('entry') << entry
16
+ entry e
17
17
  end
18
18
  end
19
19
  end
@@ -25,16 +25,21 @@ module Dita
25
25
  t = Element.new('table')
26
26
  headings = []
27
27
  tgroup = Element.new('tgroup')
28
+ num_cols = column_info.size.to_s
28
29
  case column_info
29
30
  when Array
30
31
  headings = column_info if column_info.first.is_a?(String)
31
- tgroup << column_info if column_info.first.is_a?(Element)
32
+ colspecs = column_info if column_info.first.is_a?(Element) and column_info.first.name == 'colspec'
32
33
  when Hash
33
34
  headings = column_info.keys
34
- tgroup << column_info.values
35
+ colspecs = column_info.values
35
36
  else
36
37
  # TODO raise error?
37
38
  end
39
+ if colspecs
40
+ colspecs.each_with_index do |c, index| c[:colname] = index.to_s end
41
+ tgroup << colspecs
42
+ end
38
43
  if headings.any?
39
44
  tgroup << Element.new('thead', [Element.new('row')])
40
45
  headings.each do |h|
@@ -42,9 +47,19 @@ module Dita
42
47
  end
43
48
  end
44
49
 
45
- tgroup[:cols] = column_info.size.to_s
50
+ tgroup[:cols] = num_cols
46
51
  tgroup << Element.new('tbody')
47
52
  tgroup.tbody << rows.collect do |r| row r end
48
53
  t << tgroup
49
54
  end
50
- end # end of module Table
55
+
56
+ def colspec(attrs)
57
+ Element.new('colspec', attrs)
58
+ end
59
+
60
+ # @param content [String, Element] content of
61
+ def entry(content, attrs={})
62
+ Element.new('entry', attrs, [content])
63
+ end
64
+ end # end of module Table
65
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-dita
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Kong