saxlsx 1.2.0 → 1.3.0

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: 8846f61615fb9bef698366383838cca50957a242
4
- data.tar.gz: 5fd15e93f3cac8c82eb292abe9202eeea69259d4
3
+ metadata.gz: da2ce81245e5789f61d744d62b959ebf6f42102c
4
+ data.tar.gz: ea8fc650ffb52f4f2928a35a40d3978babbc5453
5
5
  SHA512:
6
- metadata.gz: 2450c4efabb247287a16e9daf331f6be1c6ddc8c3f3abdd47b556c8e09e6234a86fb1bbad533fa0a7f18631cdd8dd7207931d78e127eb30045b5a2b95b37844c
7
- data.tar.gz: d272886859b32e9e851a52163d8c86f4fcfa5b5f5395e42687eebaaa61525f1672357f009a15bca982c9b8d89df75028aa358a32d9691189db1c32e31f9c72c8
6
+ metadata.gz: 51437661a84eca9d1023b582a13a9f32fe658e42fc9c72d3b5b119185c730e57db3337d6d45f296351ea8fada0558729b17828b854149e2da6b580796085eb68
7
+ data.tar.gz: 7030c2fbd6c6729321ba9ba6ebf6847989155bafecaefdd79acb6c53fefdcdd2bb55d1b9ad0febf2efd44db7ab36159e75e5b39196d082d74d9b533f26c26590
@@ -1,34 +1,17 @@
1
1
  module Saxlsx
2
2
  class ColumnNameGenerator
3
-
4
3
  FIRST = 'A'
5
- LAST = 'Z'
4
+ LAST = 'Z'
6
5
 
7
6
  def self.next_to(previous)
8
- cache previous do
9
- parts = (previous || '').chars.to_a
10
- char = parts.pop
11
-
12
- if char.nil? || char.empty?
13
- FIRST
14
- elsif char < LAST
15
- parts << (char.ord + 1).chr
16
- parts.join
17
- else
18
- "#{next_to(parts.join)}A"
19
- end
7
+ char = previous ? previous[-1] : nil
8
+ if char.nil?
9
+ FIRST
10
+ elsif char < LAST
11
+ previous[0..-2] + char.next
12
+ else
13
+ next_to(previous[0..-2]) + FIRST
20
14
  end
21
15
  end
22
-
23
- private
24
-
25
- def self.cache(key, &block)
26
- @cache ||= {}
27
-
28
- return @cache[key] if @cache.has_key? key
29
-
30
- @cache[key] = block.call
31
- end
32
-
33
16
  end
34
17
  end
@@ -1,5 +1,6 @@
1
1
  module Saxlsx
2
2
  class RowsCollectionParser < Ox::Sax
3
+ SECONDS_IN_DAY = BigDecimal.new(86400)
3
4
  NUM_FORMATS = {
4
5
  0 => :string, # General
5
6
  1 => :fixnum, # 0
@@ -105,7 +106,7 @@ module Saxlsx
105
106
  @base_date + text.to_i
106
107
  when :date_time
107
108
  # Round time to seconds
108
- date = @base_date + (text.to_f * 86400).round.fdiv(86400)
109
+ date = @base_date + (BigDecimal.new(text) * SECONDS_IN_DAY).round / SECONDS_IN_DAY
109
110
  DateTime.new(date.year, date.month, date.day, date.hour, date.minute, date.second)
110
111
  when :fixnum
111
112
  text.to_i
@@ -1,3 +1,3 @@
1
1
  module Saxlsx
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'
3
3
  end
data/spec/data/Spec.xlsx CHANGED
Binary file
data/spec/sheet_spec.rb CHANGED
@@ -33,7 +33,7 @@ describe Sheet do
33
33
  'LevenshteinDistance',
34
34
  3.14,
35
35
  3,
36
- DateTime.new(1970, 1, 1, 1, 0, 0),
36
+ DateTime.new(2013, 12, 13, 8, 0, 58),
37
37
  DateTime.new(1970, 1, 1),
38
38
  BigDecimal.new('3.4028236692093801E+38')
39
39
  ]
@@ -80,7 +80,7 @@ describe Sheet do
80
80
  w.sheets[0].to_csv tmp_path
81
81
 
82
82
  csv = File.open(csv_file, 'r') { |f| f.readlines }
83
- csv[0].should eq %{"LevenshteinDistance","3.14","3","1970-01-01T01:00:00+00:00","1970-01-01T00:00:00+00:00","0.34028236692093801E39"\n}
83
+ csv[0].should eq %{"LevenshteinDistance","3.14","3","2013-12-13T08:00:58+00:00","1970-01-01T00:00:00+00:00","0.34028236692093801E39"\n}
84
84
  csv[1].should eq %{"Case sensitive","false","3.0","1970-01-01T01:00:00+00:00"\n}
85
85
  csv[2].should eq "\"Fields\",\"Type\",\"URL Mining\"\n"
86
86
  csv[3].should eq "\"autor\",\"text\",\"false\"\n"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saxlsx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgars Beigarts
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-26 00:00:00.000000000 Z
11
+ date: 2015-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip