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 +4 -4
- data/lib/confluence_helper.rb +7 -6
- data/lib/confluence_helper/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90b91cb325d0ffc8bc8bad7bc5c35892301d00c1
|
4
|
+
data.tar.gz: 649d03934d12fd34687b089fc72c83fec4e0dbfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a781cb7f72473b412c0c49d5fca2094db5b32e433abda2575af81ddfb423cb7e61122db63bdc5cb492eabd3f68507f91fecb8140df5ab96f06efb6dfe85b9550
|
7
|
+
data.tar.gz: 599ff3d54901aafcd7f92e3fa97cd94516d371c5df0ecbc4b1684bea32c99f4da1d49fc8aef7d74d77aafd6bc00ad071edcec3d879b5efea8e1a4c04e1bfe2c6
|
data/lib/confluence_helper.rb
CHANGED
@@ -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 ] ] =
|
217
|
+
row_hash[ headers[ index ] ] =
|
218
|
+
(mode == :text ? cell.content : cell.inner_html).gsub( /\u00A0/,"" )
|
218
219
|
}
|
219
220
|
end
|
220
221
|
|