confluence_helper 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d6007884edf8b589101607a422b3bfaf37fbef6a
4
- data.tar.gz: d386b468a27aec5cb2af0cd8d457016251abaf9b
3
+ metadata.gz: 90b91cb325d0ffc8bc8bad7bc5c35892301d00c1
4
+ data.tar.gz: 649d03934d12fd34687b089fc72c83fec4e0dbfc
5
5
  SHA512:
6
- metadata.gz: a6ddad351654a25546651934bd3c8f96ed1c20fb3a44b418186d02dd26d890f480952f7af708be907d11a1b32eb532e3caba18db013c551315560a298a52f0c5
7
- data.tar.gz: 5dba7c8e269a5df94da6cd3dbf919066e9bccef821d3f177cb6ea35aef6d1048dcb7c8b2a0811d61d32c81bde82ee1b77f1441d8c252b0e94eed17a601a2fa5e
6
+ metadata.gz: a781cb7f72473b412c0c49d5fca2094db5b32e433abda2575af81ddfb423cb7e61122db63bdc5cb492eabd3f68507f91fecb8140df5ab96f06efb6dfe85b9550
7
+ data.tar.gz: 599ff3d54901aafcd7f92e3fa97cd94516d371c5df0ecbc4b1684bea32c99f4da1d49fc8aef7d74d77aafd6bc00ad071edcec3d879b5efea8e1a4c04e1bfe2c6
@@ -169,8 +169,8 @@ class WikiPage < Confluence
169
169
  @spacekey, @title = spacekey, title
170
170
  end
171
171
 
172
- def to_nodes
173
- parse_wiki_table(doc)
172
+ def to_nodes(mode=:text)
173
+ parse_wiki_table(doc, mode)
174
174
  end
175
175
 
176
176
  def attachment(title)
@@ -196,11 +196,11 @@ class WikiPage < Confluence
196
196
  return Nokogiri::HTML( page.body["body"]["export_view"]["value"] )
197
197
  end
198
198
 
199
- def parse_wiki_table(doc)
199
+ def parse_wiki_table(doc, mode=:text)
200
200
  rows = doc.xpath("//table/tbody/tr")
201
201
  headers = rows.xpath("th").map{|n| n.content}
202
202
  rows = rows - rows.xpath("th/..")
203
- documents = rows.map{ | row | row_to_hash(row, headers) } #convert to hashes
203
+ documents = rows.map{ | row | row_to_hash(row, headers, mode) } #convert to hashes
204
204
  if headers.include?("ID")
205
205
  documents.each_with_object({}){|doc, o| o[doc["ID"].to_i] = doc } # index by id
206
206
  else
@@ -208,13 +208,14 @@ class WikiPage < Confluence
208
208
  end
209
209
  end
210
210
 
211
- def row_to_hash(row, headers)
211
+ def row_to_hash(row, headers, mode = :text)
212
212
  row.xpath( "td" ).
213
213
  to_a.
214
214
  each.
215
215
  with_index.
216
216
  with_object( {} ) { | (cell , index) , row_hash |
217
- row_hash[ headers[ index ] ] = cell.content.gsub( /\u00A0/,"" )
217
+ row_hash[ headers[ index ] ] =
218
+ (mode == :text ? cell.content : cell.inner_html).gsub( /\u00A0/,"" )
218
219
  }
219
220
  end
220
221
 
@@ -1,3 +1,3 @@
1
1
  module ConfluenceHelper
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: confluence_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Thorne