swissmedic-diff 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2M2ZjQwMDk0YmZmYmNmNzZjNDZlMWI2ZDc5OTU3MGVlZTJmOWQxZA==
4
+ ZjYzOTlmOTY3NjE1MTVkOGZhN2I5YzViMWQyYzYxMjU4NmZhZDg5MQ==
5
5
  data.tar.gz: !binary |-
6
- MjI1NTljZGZhMTA2N2I0YmI3MDZlZWJiYWNjNWY5NTNjOGE1NjAxZA==
6
+ YWUxY2U2MTRjOWFiNjEwNTNhMWQ1ZGI0ZDVjNGQ3NzRkNzA0MjViNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWI3ZWYwYjg2NjE1ZDc3Yzk3NDBjMDY4N2RhZTAxMWFjMzJkYWMzNDJjZGU5
10
- MmM5ODMwYTBlYTgzZDk3M2MxYTBlMjBkYzQzYjRkOWE4NmE1Y2U2NTk3MDQ0
11
- YzMwN2I0NmQ3MjNkMjYxNjc2NjJiNTIxODAzMDc4M2I2MDIxYTc=
9
+ MTJiY2QwMThmMDU1ZGJlZGI4YzljYTA3YjIwNjU1OThhZGJiYTBhN2RhMGQ3
10
+ ZWM0MTdhMjNiYTM2M2ZjOGM2MzQ5YzYwMjExMTcxN2I4YjhmMDZmZDMyMTk4
11
+ NDg2NjRhNWY0NTZlMDM0MDdiYzZlYzMwMTQ1MTQ1ZTFmYmIzMTQ=
12
12
  data.tar.gz: !binary |-
13
- MDViOTFhOGFkY2JhYTgxOGE3ZjM0MmNmZmE2Y2I5MzMyZDFkMzI4MTZhM2I3
14
- OTU1NzQ5ZTY4MTczMDU3ZjczNTY4ZTdkYWEwZjRmMDlhYmJiNGRiZmE2ZGM4
15
- MjViYTU0MWU3ODgyOTY1MmIzOTRlMmEwOTBlZmM5ZmEzZWUzMzk=
13
+ NTdjNWQ4ZDFkZWNiYTI4NTllYWRhOGVjYTk1MThmZDY2YTc5NWM5MjQ5MTg4
14
+ OWYxZDFlNGM3NmZjY2Q4OGZjNWQyODFmYTIzYWI4ZGYwMmU0ZDAyMTI4NDhh
15
+ NTYzYjk0OGUzM2MwYTk3ZjdiOGVlYzFiNTRkMDY5ZDhjNDk5OWE=
@@ -8,11 +8,10 @@ notifications:
8
8
  - zdavatz@ywesee.com
9
9
  rvm:
10
10
  - ruby-head
11
+ - 2.1.2
11
12
  - 2.0.0
12
13
  - 1.9.3
13
14
  - 1.8.7
14
15
  matrix:
15
16
  allow_failures:
16
17
  - rvm: ruby-head
17
- - rvm: 2.0.0
18
- - rvm: 1.8.7
data/Gemfile CHANGED
@@ -8,4 +8,4 @@ end
8
8
 
9
9
  group :debugger do
10
10
  gem 'pry-debugger'
11
- end
11
+ end unless RUBY_VERSION =~ /^1\.8/
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- swissmedic-diff (0.1.6)
4
+ swissmedic-diff (0.1.8)
5
5
  nokogiri
6
6
  rubyXL
7
- rubyzip (= 0.9.9)
7
+ rubyzip
8
8
  spreadsheet
9
9
 
10
10
  GEM
@@ -13,42 +13,41 @@ GEM
13
13
  ansi (1.4.3)
14
14
  builder (3.2.2)
15
15
  coderay (1.1.0)
16
- columnize (0.3.6)
17
- debugger (1.6.5)
16
+ columnize (0.8.9)
17
+ debugger (1.6.8)
18
18
  columnize (>= 0.3.1)
19
19
  debugger-linecache (~> 1.2.0)
20
- debugger-ruby_core_source (~> 1.3.1)
20
+ debugger-ruby_core_source (~> 1.3.5)
21
21
  debugger-linecache (1.2.0)
22
- debugger-ruby_core_source (1.3.1)
23
- hashie (2.0.5)
24
- hoe (3.7.4)
22
+ debugger-ruby_core_source (1.3.5)
23
+ hoe (3.12.0)
25
24
  rake (>= 0.8, < 11.0)
26
25
  method_source (0.8.2)
27
- mini_portile (0.5.2)
28
- minitest (5.2.1)
29
- minitest-reporters (1.0.0)
26
+ mini_portile (0.6.0)
27
+ minitest (5.3.5)
28
+ minitest-reporters (1.0.5)
30
29
  ansi
31
30
  builder
32
31
  minitest (>= 5.0)
33
- powerbar
34
- nokogiri (1.6.0)
35
- mini_portile (~> 0.5.0)
36
- powerbar (1.0.11)
37
- ansi (~> 1.4.0)
38
- hashie (>= 1.1.0)
39
- pry (0.9.12.4)
40
- coderay (~> 1.0)
41
- method_source (~> 0.8)
32
+ ruby-progressbar
33
+ nokogiri (1.6.2.1)
34
+ mini_portile (= 0.6.0)
35
+ pry (0.10.0)
36
+ coderay (~> 1.1.0)
37
+ method_source (~> 0.8.1)
42
38
  slop (~> 3.4)
43
- pry-debugger (0.2.2)
39
+ pry-debugger (0.2.3)
44
40
  debugger (~> 1.3)
45
- pry (~> 0.9.10)
46
- rake (10.1.1)
41
+ pry (>= 0.9.10, < 0.11.0)
42
+ rake (10.3.2)
47
43
  ruby-ole (1.2.11.7)
48
- rubyXL (1.2.10)
49
- rubyzip (0.9.9)
50
- slop (3.4.7)
51
- spreadsheet (0.9.6)
44
+ ruby-progressbar (1.5.1)
45
+ rubyXL (3.1.2)
46
+ nokogiri (>= 1.4.4)
47
+ rubyzip (>= 1.1.6)
48
+ rubyzip (1.1.6)
49
+ slop (3.5.0)
50
+ spreadsheet (0.9.7)
52
51
  ruby-ole (>= 1.0)
53
52
 
54
53
  PLATFORMS
@@ -1,3 +1,7 @@
1
+ === 0.1.8 / 07.07.2014
2
+
3
+ * Support parsing xlsx of Swissmedic July
4
+
1
5
  === 0.1.7 / 15.01.2014
2
6
 
3
7
  * Support comparing xls and xslx files
@@ -26,18 +26,28 @@ module Spreadsheet
26
26
  row.at(idx) && row.date(idx)
27
27
  else
28
28
  data = row[idx]
29
- return Date.new(1899,12,30)+data.value.to_i if data.is_a?(RubyXL::Cell)
29
+ if data.is_a?(RubyXL::Cell)
30
+ return data.value.respond_to?(:to_i) ? data.value.to_i : data.value
31
+ return data.value if data.value.is_a?(DateTime)
32
+ if data.value.class.to_s == 'DateTime'
33
+ puts "data is_a RubyXL::Cell and value #{data.value.class} is_a? Date #{data.value.is_a?(Date)} DateTime #{data.value.is_a?(DateTime)}"
34
+ return Date.new(1899,12,30)+data.to_date.value.to_i
35
+ else
36
+ return Date.new(1899,12,30)+data.value.to_i if data.is_a?(RubyXL::Cell)
37
+ end
38
+ end
30
39
  end
31
40
  end
32
41
  end
33
42
 
34
43
  module RubyXL
35
- class Worksheet < PrivateClass
44
+ class Worksheet
36
45
  def row(row_index)
37
46
  x = @sheet_data[row_index]
38
47
  def x.date(column_index)
39
48
  data = self[column_index]
40
- return Date.new(1899,12,30)+data.value.to_i if data.is_a?(RubyXL::Cell)
49
+ return data.value.respond_to?(:to_i) ? data.value.to_i : data.value
50
+ # return Date.new(1899,12,30)+data.value.to_i if data.is_a?(RubyXL::Cell)
41
51
  end unless defined?(x.date)
42
52
  x
43
53
  end
@@ -47,9 +57,14 @@ module RubyXL
47
57
  self[idx]
48
58
  end
49
59
  end
60
+ class Row < OOXMLObject
61
+ def []=(ind, value)
62
+ cells[ind] = value
63
+ end
64
+ end
50
65
  class Cell
51
66
  def to_i
52
- self.value.to_i
67
+ self.value.respond_to?(:to_i) ? self.value.to_i : self.value
53
68
  end
54
69
  def to_s
55
70
  self.value.to_s
@@ -301,7 +301,7 @@ class SwissmedicDiff
301
301
  |row|
302
302
  row_nr += 1
303
303
  next if row_nr <= skipRows
304
- if row.size < COLUMNS.size/2 || row.select{|val| val==nil}.size > COLUMNS.size/2
304
+ if row.size < COLUMNS.size/2
305
305
  $stdout.puts "Data missing in \n(line " + (row_nr).to_s + "): " + row.join(", ").to_s + "\n"
306
306
  next
307
307
  end
@@ -317,7 +317,12 @@ class SwissmedicDiff
317
317
  # Packungen.xls of swissmedic before October 2013 had 3 leading rows
318
318
  # Packungen.xls of swissmedic after October 2013 have 4 leading rows
319
319
  j = 0
320
- j += 1 while spreadsheet.worksheet(0).row(j)[0].to_i == 0
320
+ while true
321
+ cell = spreadsheet.worksheet(0).row(j)[0]
322
+ cell = cell.value if cell.is_a?(RubyXL::Cell)
323
+ break if cell.respond_to?(:to_i) and cell.to_i != 0
324
+ j += 1
325
+ end
321
326
  j
322
327
  end
323
328
 
@@ -1,3 +1,3 @@
1
1
  class SwissmedicDiff
2
- VERSION = '0.1.7'
2
+ VERSION = '0.1.8'
3
3
  end
@@ -17,7 +17,7 @@ spec = Gem::Specification.new do |s|
17
17
  s.executables << 'swissmedic-diff'
18
18
  s.add_dependency('rubyXL')
19
19
  s.add_dependency('nokogiri')
20
- s.add_dependency('rubyzip', '0.9.9')
20
+ s.add_dependency('rubyzip')
21
21
  s.add_dependency('spreadsheet')
22
22
  s.add_development_dependency "hoe"
23
23
  s.add_development_dependency "minitest"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swissmedic-diff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaomi Hatakeyama, Zeno R.R. Davatz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-15 00:00:00.000000000 Z
11
+ date: 2014-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc