creek 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 362e390640c6143db12fdf1cf83d45a2d70b1cf3
4
- data.tar.gz: c11e75bfc31e009513f32f14711b3396732ffd1e
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTlmZDZhOWE4MjA3ZTI5MDExOGRjNjhlODRhZjE4OGM3NTc5M2M2Yg==
5
+ data.tar.gz: !binary |-
6
+ NDU3NDgwNmEyZGY5OTExYzE4MTQxMTU4YjdjOTMzNzhkNWYyZWJmYQ==
5
7
  SHA512:
6
- metadata.gz: 5339ab0325a1f9034f245c73767a6d615958521286170853d489e2c53d242fba5794c25212acac61001d5759260d6be6156d39cb02cd0952fcdbeb7a8b7c9d74
7
- data.tar.gz: 27126fdd4c896abce8480174b80316025deb427f28d89275775da807f8049f5ac12a862134fc52b6fc63e4fcd54014d7cb5ab55d32d17fb2a826ffcb15117742
8
+ metadata.gz: !binary |-
9
+ MmY0YWJlYmM2YmIwNmNmMzgxNGM2NjhlZTliMTEyZDY4NDZhZTIzNjZlYmU2
10
+ YmJmMDU3NDQwM2VjZjI2ZmU2OGRmZTlmOTczM2RjZGFlOWE1ZWY5ODhhYjMy
11
+ NjI3NjkyYjUxM2VkYWE1NGQ4MGM1MmM3YTQyZmU1MjQxYmFkMTE=
12
+ data.tar.gz: !binary |-
13
+ ZTRkZmU3YjY2NTVlODdlZWNjYjkzZjE0ZmViNjE1MTE1NWVhYTY4MTJlNWNm
14
+ YjQyZjE2YTUwMGMyMDdmZTM5YTYwOTNmNjMzZGE0MTYzNWY0YjY0NjAyZGE4
15
+ N2MwODUyZGI3YTdkY2YwZjc5YzhhOWZkMDEwN2M3NWVhOGZkYWU=
@@ -14,14 +14,31 @@ module Creek
14
14
 
15
15
  def parse_shared_shared_strings
16
16
  path = "xl/sharedStrings.xml"
17
- @dictionary = Hash.new
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
- xml.css('t').each_with_index.map do |str, i|
22
- @dictionary[i] = str.content
20
+ parse_shared_string_from_document(xml)
21
+ end
22
+ end
23
+
24
+ def parse_shared_string_from_document(xml)
25
+ @dictionary = self.class.parse_shared_string_from_document(xml)
26
+ end
27
+
28
+ def self.parse_shared_string_from_document(xml)
29
+ dictionary = Hash.new
30
+
31
+ xml.css('si').each_with_index do |si, idx|
32
+ text_nodes = si.css('t')
33
+ if text_nodes.count == 1 # plain text node
34
+ dictionary[idx] = text_nodes.first.content
35
+ else # rich text nodes with text fragments
36
+ dictionary[idx] = text_nodes.map(&:content).join('')
23
37
  end
24
38
  end
39
+
40
+ dictionary
25
41
  end
42
+
26
43
  end
27
- end
44
+ end
data/lib/creek/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Creek
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -0,0 +1,78 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="6" uniqueCount="5">
3
+ <si>
4
+ <t>Cell A1</t>
5
+ </si>
6
+ <si>
7
+ <t>Cell B1</t>
8
+ </si>
9
+ <si>
10
+ <t>My Cell</t>
11
+ </si>
12
+ <si>
13
+ <r>
14
+ <rPr>
15
+ <sz val="11"/>
16
+ <color rgb="FFFF0000"/>
17
+ <rFont val="Calibri"/>
18
+ <family val="2"/>
19
+ <scheme val="minor"/>
20
+ </rPr>
21
+ <t>Cell</t>
22
+ </r>
23
+ <r>
24
+ <rPr>
25
+ <sz val="11"/>
26
+ <color theme="1"/>
27
+ <rFont val="Calibri"/>
28
+ <family val="2"/>
29
+ <scheme val="minor"/>
30
+ </rPr>
31
+ <t xml:space="preserve"> </t>
32
+ </r>
33
+ <r>
34
+ <rPr>
35
+ <b/>
36
+ <sz val="11"/>
37
+ <color theme="1"/>
38
+ <rFont val="Calibri"/>
39
+ <family val="2"/>
40
+ <scheme val="minor"/>
41
+ </rPr>
42
+ <t>A2</t>
43
+ </r>
44
+ </si>
45
+ <si>
46
+ <r>
47
+ <rPr>
48
+ <sz val="11"/>
49
+ <color rgb="FF00B0F0"/>
50
+ <rFont val="Calibri"/>
51
+ <family val="2"/>
52
+ <scheme val="minor"/>
53
+ </rPr>
54
+ <t>Cell</t>
55
+ </r>
56
+ <r>
57
+ <rPr>
58
+ <sz val="11"/>
59
+ <color theme="1"/>
60
+ <rFont val="Calibri"/>
61
+ <family val="2"/>
62
+ <scheme val="minor"/>
63
+ </rPr>
64
+ <t xml:space="preserve"> </t>
65
+ </r>
66
+ <r>
67
+ <rPr>
68
+ <i/>
69
+ <sz val="11"/>
70
+ <color theme="1"/>
71
+ <rFont val="Calibri"/>
72
+ <family val="2"/>
73
+ <scheme val="minor"/>
74
+ </rPr>
75
+ <t>B2</t>
76
+ </r>
77
+ </si>
78
+ </sst>
@@ -0,0 +1,18 @@
1
+ require 'creek'
2
+
3
+ describe 'shared strings' do
4
+
5
+ it 'parses rich text strings correctly' do
6
+ shared_strings_xml_file = File.open('spec/fixtures/sst.xml')
7
+ doc = Nokogiri::XML(shared_strings_xml_file)
8
+ dictionary = Creek::SharedStrings.parse_shared_string_from_document(doc)
9
+
10
+ dictionary.keys.size.should == 5
11
+ dictionary[0].should == 'Cell A1'
12
+ dictionary[1].should == 'Cell B1'
13
+ dictionary[2].should == 'My Cell'
14
+ dictionary[3].should == 'Cell A2'
15
+ dictionary[4].should == 'Cell B2'
16
+ end
17
+
18
+ end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: creek
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - pythonicrubyist
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-14 00:00:00.000000000 Z
11
+ date: 2014-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
47
  version: 2.13.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 2.13.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: nokogiri
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.6.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.6.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rubyzip
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - ! '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.0.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - ! '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.0.0
83
83
  description: A Ruby gem that streams and parses large Excel(xlsx and xlsm) files fast
@@ -88,7 +88,7 @@ executables: []
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
- - ".gitignore"
91
+ - .gitignore
92
92
  - Gemfile
93
93
  - LICENSE.txt
94
94
  - README.rdoc
@@ -102,7 +102,9 @@ files:
102
102
  - spec/fixtures/invalid.xls
103
103
  - spec/fixtures/sample-as-zip.zip
104
104
  - spec/fixtures/sample.xlsx
105
+ - spec/fixtures/sst.xml
105
106
  - spec/fixtures/temp_string_io_file_path_with_no_extension
107
+ - spec/shared_string_spec.rb
106
108
  - spec/test_spec.rb
107
109
  homepage: https://github.com/pythonicrubyist/creek
108
110
  licenses:
@@ -114,17 +116,17 @@ require_paths:
114
116
  - lib
115
117
  required_ruby_version: !ruby/object:Gem::Requirement
116
118
  requirements:
117
- - - ">="
119
+ - - ! '>='
118
120
  - !ruby/object:Gem::Version
119
121
  version: 1.9.2
120
122
  required_rubygems_version: !ruby/object:Gem::Requirement
121
123
  requirements:
122
- - - ">="
124
+ - - ! '>='
123
125
  - !ruby/object:Gem::Version
124
126
  version: '0'
125
127
  requirements: []
126
128
  rubyforge_project:
127
- rubygems_version: 2.2.0.rc.1
129
+ rubygems_version: 2.2.0
128
130
  signing_key:
129
131
  specification_version: 4
130
132
  summary: A Ruby gem for parsing large Excel(xlsx and xlsm) files.
@@ -132,5 +134,7 @@ test_files:
132
134
  - spec/fixtures/invalid.xls
133
135
  - spec/fixtures/sample-as-zip.zip
134
136
  - spec/fixtures/sample.xlsx
137
+ - spec/fixtures/sst.xml
135
138
  - spec/fixtures/temp_string_io_file_path_with_no_extension
139
+ - spec/shared_string_spec.rb
136
140
  - spec/test_spec.rb