creek 2.4 → 2.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bee3cecfd77048fd524de90b3c59d844295ac470
4
- data.tar.gz: ea3765e651c0657920c714da61492afce161dcf4
3
+ metadata.gz: ddab26a3269b8c9367e6e891bd9aff7e21c96310
4
+ data.tar.gz: 1959b38cd75e8836c39b2e2d0f8e332a8145f7bd
5
5
  SHA512:
6
- metadata.gz: 02de0c9ccc20d4489f66fcef6468e06adfba44320e0ccaf08091827706c53331d32fa641736a904c677e55e46c9ddde61894278eb63264d3567a551f4409fba1
7
- data.tar.gz: '009e354166eba703d3ecd49dbc9b48114d612cd093a6904eb75fe42136016dfe3738f6229c910cd1565cc15e3cc26fbd772626b97ebf22904d59fe5c9ce14a3f'
6
+ metadata.gz: 35d72aab09ffc085e5869fe6a93d3249733820175e711749c7b13574f0545e9101cde0acb28dc800eb8be3900c46860095df32de728eda269724de3849a5a7d1
7
+ data.tar.gz: 88eb9a761857575f87dcf45d72362e7bc4000c410ce7ccc924a54383987cf2a64fa3693a8b19a38ed4fc3544e8c6fc63b0aef540332f140aa70a15ca949bdda5
Binary file
@@ -54,8 +54,10 @@ module Creek
54
54
  # detected earlier and cast here by its standardized symbol
55
55
  ##
56
56
 
57
- when :string, :unsupported
57
+ when :string
58
58
  value
59
+ when :unsupported
60
+ convert_unknown(value)
59
61
  when :fixnum
60
62
  value.to_i
61
63
  when :float, :percentage
@@ -69,7 +71,23 @@ module Creek
69
71
 
70
72
  ## Nothing matched
71
73
  else
72
- value
74
+ convert_unknown(value)
75
+ end
76
+ end
77
+
78
+ def self.convert_unknown(value)
79
+ begin
80
+ if value.nil? or value.empty?
81
+ return value
82
+ elsif value.to_i.to_s == value.to_s
83
+ return value.to_i
84
+ elsif value.to_f.to_s == value.to_s
85
+ return value.to_f
86
+ else
87
+ return value
88
+ end
89
+ rescue
90
+ return value
73
91
  end
74
92
  end
75
93
 
@@ -1,3 +1,3 @@
1
1
  module Creek
2
- VERSION = "2.4"
2
+ VERSION = "2.4.1"
3
3
  end
Binary file
@@ -54,6 +54,27 @@ describe 'Creek parsing dates on a sample XLSX file' do
54
54
  end
55
55
  end
56
56
 
57
+ describe 'Creek parsing a file with large numbrts.' do
58
+ before(:all) do
59
+ @creek = Creek::Book.new 'spec/fixtures/large_numbers.xlsx'
60
+ @expected_simple_rows = [{"A"=>"7.83294732E8", "B"=>"783294732", "C"=>783294732.0}]
61
+ end
62
+
63
+ after(:all) do
64
+ @creek.close
65
+ end
66
+
67
+ it 'Parse simple rows successfully.' do
68
+ rows = Array.new
69
+ row_count = 0
70
+ @creek.sheets[0].simple_rows.each do |row|
71
+ rows << row
72
+ row_count += 1
73
+ end
74
+ expect(rows[0]).to eq(@expected_simple_rows[0])
75
+ end
76
+ end
77
+
57
78
  describe 'Creek parsing a sample XLSX file' do
58
79
  before(:all) do
59
80
  @creek = Creek::Book.new 'spec/fixtures/sample.xlsx'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: creek
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.4'
4
+ version: 2.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - pythonicrubyist
@@ -116,6 +116,7 @@ executables: []
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
+ - ".DS_Store"
119
120
  - ".gitignore"
120
121
  - Gemfile
121
122
  - LICENSE.txt
@@ -133,8 +134,10 @@ files:
133
134
  - lib/creek/styles/style_types.rb
134
135
  - lib/creek/utils.rb
135
136
  - lib/creek/version.rb
137
+ - spec/.DS_Store
136
138
  - spec/drawing_spec.rb
137
139
  - spec/fixtures/invalid.xls
140
+ - spec/fixtures/large_numbers.xlsx
138
141
  - spec/fixtures/sample-as-zip.zip
139
142
  - spec/fixtures/sample-with-images.xlsx
140
143
  - spec/fixtures/sample.xlsx
@@ -176,8 +179,10 @@ signing_key:
176
179
  specification_version: 4
177
180
  summary: A Ruby gem for parsing large Excel(xlsx and xlsm) files.
178
181
  test_files:
182
+ - spec/.DS_Store
179
183
  - spec/drawing_spec.rb
180
184
  - spec/fixtures/invalid.xls
185
+ - spec/fixtures/large_numbers.xlsx
181
186
  - spec/fixtures/sample-as-zip.zip
182
187
  - spec/fixtures/sample-with-images.xlsx
183
188
  - spec/fixtures/sample.xlsx