creeker 2.1.3 → 2.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/lib/creeker/shared_strings.rb +11 -10
- data/lib/creeker/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: f0d255dd9727f3364bfadcdf12a21dfc3ae72595
|
4
|
+
data.tar.gz: de0f8ef51a9b7f67ae336935981ec9c20c885c1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53ef6ad9fb7b60abd8dcebe5e1e561f941d2788a866b5c713abfc0dccf262c64d04b30a8492fe548cd134e1c2c65b6d604f8dcdf5d1ec300aeadacccc18e47ef
|
7
|
+
data.tar.gz: ec29a6a56281298b7dcb0c7cfc1b3385108b9093b34a578dc9d9e40e4e6a00bbfd2e8ce02f6224231fdeedd54ffba65b5ef130db50e6dbe17c0ed9e53138b6cb
|
data/.DS_Store
CHANGED
Binary file
|
@@ -9,24 +9,23 @@ module Creeker
|
|
9
9
|
|
10
10
|
def initialize book, multi_thread = false
|
11
11
|
@book = book
|
12
|
-
|
13
|
-
parse_shared_shared_strings
|
12
|
+
parse_shared_shared_strings(multi_thread)
|
14
13
|
end
|
15
14
|
|
16
|
-
def parse_shared_shared_strings
|
15
|
+
def parse_shared_shared_strings multi_thread
|
17
16
|
path = "xl/sharedStrings.xml"
|
18
17
|
if @book.files.file.exist?(path)
|
19
18
|
doc = @book.files.file.open path
|
20
19
|
xml = Nokogiri::XML::Document.parse doc
|
21
|
-
parse_shared_string_from_document(xml)
|
20
|
+
parse_shared_string_from_document(xml, multi_thread)
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
25
|
-
def parse_shared_string_from_document(xml)
|
26
|
-
@dictionary = self.class.parse_shared_string_from_document(xml)
|
24
|
+
def parse_shared_string_from_document(xml, multi_thread)
|
25
|
+
@dictionary = self.class.parse_shared_string_from_document(xml, multi_thread)
|
27
26
|
end
|
28
27
|
|
29
|
-
def self.parse_shared_string_from_document(xml)
|
28
|
+
def self.parse_shared_string_from_document(xml, multi_thread)
|
30
29
|
dictionary = Hash.new
|
31
30
|
# (1..10).each do |i|
|
32
31
|
# thread = Thread.new do
|
@@ -45,8 +44,8 @@ module Creeker
|
|
45
44
|
# end
|
46
45
|
|
47
46
|
# Creeker::Book.new(Upload.last.document.path)
|
48
|
-
if
|
49
|
-
xml.css('si').to_a.in_groups_of(10000).
|
47
|
+
if multi_thread
|
48
|
+
xml.css('si').to_a.in_groups_of(10000).each_with_index do |group, index|
|
50
49
|
thread = Thread.new do
|
51
50
|
group.each_with_index do |si, idx|
|
52
51
|
text_nodes = si.css('t')
|
@@ -58,7 +57,7 @@ module Creeker
|
|
58
57
|
end
|
59
58
|
end
|
60
59
|
|
61
|
-
|
60
|
+
sleep index
|
62
61
|
GC.start
|
63
62
|
end
|
64
63
|
else
|
@@ -70,6 +69,8 @@ module Creeker
|
|
70
69
|
dictionary[idx] = text_nodes.map(&:content).join('')
|
71
70
|
end
|
72
71
|
end
|
72
|
+
sleep 1
|
73
|
+
GC.start
|
73
74
|
end
|
74
75
|
dictionary
|
75
76
|
end
|
data/lib/creeker/version.rb
CHANGED