swissmedic-diff 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +5 -5
- data/History.txt +8 -0
- data/lib/swissmedic-diff.rb +3 -2
- data/test/test_swissmedic-diff.rb +31 -13
- metadata +6 -6
data/Gemfile.lock
CHANGED
@@ -10,20 +10,20 @@ GEM
|
|
10
10
|
ansi (1.4.3)
|
11
11
|
builder (3.2.2)
|
12
12
|
hashie (2.0.5)
|
13
|
-
hoe (3.7.
|
13
|
+
hoe (3.7.2)
|
14
14
|
rake (>= 0.8, < 11.0)
|
15
|
-
minitest (
|
16
|
-
minitest-reporters (0.
|
15
|
+
minitest (5.1.0)
|
16
|
+
minitest-reporters (1.0.0)
|
17
17
|
ansi
|
18
18
|
builder
|
19
|
-
minitest (>=
|
19
|
+
minitest (>= 5.0)
|
20
20
|
powerbar
|
21
21
|
powerbar (1.0.11)
|
22
22
|
ansi (~> 1.4.0)
|
23
23
|
hashie (>= 1.1.0)
|
24
24
|
rake (10.1.0)
|
25
25
|
ruby-ole (1.2.11.7)
|
26
|
-
spreadsheet (0.9.
|
26
|
+
spreadsheet (0.9.6)
|
27
27
|
ruby-ole (>= 1.0)
|
28
28
|
|
29
29
|
PLATFORMS
|
data/History.txt
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
=== 0.1.5 / 11.12.2010
|
2
|
+
|
3
|
+
* Updated tests as we no longer raise an error
|
4
|
+
* Update to spreadsheet 0.9.6
|
5
|
+
* Just display unhandled line instead of raising an exception
|
6
|
+
* daily_travis_ci.rb on 20131124
|
7
|
+
* updated Manifest.txt
|
8
|
+
|
1
9
|
=== 0.1.4 / 22.10.2010
|
2
10
|
|
3
11
|
* Add utility proc rows_to_skip
|
data/lib/swissmedic-diff.rb
CHANGED
@@ -17,7 +17,7 @@ require 'spreadsheet'
|
|
17
17
|
#License:: GPLv2.0 Compliance
|
18
18
|
#Source:: http://scm.ywesee.com/?p=swissmedic-diff/.git;a=summary
|
19
19
|
class SwissmedicDiff
|
20
|
-
VERSION = '0.1.
|
20
|
+
VERSION = '0.1.5'
|
21
21
|
|
22
22
|
module Diff
|
23
23
|
COLUMNS = [ :iksnr, :seqnr, :name_base, :company,
|
@@ -294,7 +294,8 @@ class SwissmedicDiff
|
|
294
294
|
worksheet.each(skipRows) {
|
295
295
|
|row|
|
296
296
|
if row.size < COLUMNS.size/2 || row.select{|val| val==nil}.size > COLUMNS.size/2
|
297
|
-
|
297
|
+
$stdout.puts "Data missing in \n(line " + (row.idx+1).to_s + "): " + row.join(", ").to_s + "\n"
|
298
|
+
next
|
298
299
|
end
|
299
300
|
next if (cell(row, column(:production_science)) == 'Tierarzneimittel')
|
300
301
|
row[column(:iksnr)] = "%05i" % cell(row, column(:iksnr)).to_i
|
@@ -4,11 +4,11 @@
|
|
4
4
|
|
5
5
|
$: << File.expand_path("../lib", File.dirname(__FILE__))
|
6
6
|
|
7
|
-
require '
|
7
|
+
require 'minitest/autorun'
|
8
8
|
require 'swissmedic-diff'
|
9
9
|
|
10
10
|
module ODDB
|
11
|
-
class SwissmedicPluginTest < Test
|
11
|
+
class SwissmedicPluginTest < Minitest::Test
|
12
12
|
def setup
|
13
13
|
@diff = SwissmedicDiff.new
|
14
14
|
@data = File.expand_path 'data/Packungen.xls',
|
@@ -26,6 +26,26 @@ module ODDB
|
|
26
26
|
@workbook = Spreadsheet.open(@data)
|
27
27
|
end
|
28
28
|
|
29
|
+
# This is not a unit test as it takes way too long (> 1 minute)
|
30
|
+
# Instead it might just tell you how to test with real data
|
31
|
+
def test_real_diff
|
32
|
+
require 'pp'
|
33
|
+
@diff = SwissmedicDiff.new
|
34
|
+
last_month = File.expand_path 'data/Packungen-2013.08.16.xls', File.dirname(__FILE__)
|
35
|
+
this_month = File.expand_path 'data/Packungen-2013.11.04.xls', File.dirname(__FILE__)
|
36
|
+
result = @diff.diff last_month, this_month, [:atc_class, :sequence_date]
|
37
|
+
pp result.news.first
|
38
|
+
pp result.news.last
|
39
|
+
pp result.updates.first
|
40
|
+
pp result.replacements.first
|
41
|
+
# assert(result.changes.flatten.index('Zulassungs-Nummer') == nil, "Should not find Zulassungs-Nummer in changes")
|
42
|
+
# assert(result.news.flatten.index('Zulassungs-Nummer') == nil, "Should not find Zulassungs-Nummer in changes")
|
43
|
+
# assert(result.news.flatten.index('00277') == nil, "Should not find 00277 in news")
|
44
|
+
pp result.news.size
|
45
|
+
pp result.updates.size
|
46
|
+
pp result.replacements.size
|
47
|
+
end if false
|
48
|
+
|
29
49
|
def test_iterate
|
30
50
|
diff = SwissmedicDiff.new
|
31
51
|
strings = []
|
@@ -51,7 +71,9 @@ module ODDB
|
|
51
71
|
|
52
72
|
def test_diff_pre_2013_to_2013
|
53
73
|
result = @diff.diff(@data_2013, @data)
|
54
|
-
assert(result.changes.flatten.index('Zulassungs-Nummer') == nil, "Should not find Zulassungs-Nummer in
|
74
|
+
assert(result.changes.flatten.index('Zulassungs-Nummer') == nil, "Should not find Zulassungs-Nummer in changes")
|
75
|
+
assert(result.news.flatten.index('Zulassungs-Nummer') == nil, "Should not find Zulassungs-Nummer in changes")
|
76
|
+
assert(result.news.flatten.index('00277') == nil, "Should not find 00277 in news")
|
55
77
|
assert_equal 6, result.news.size
|
56
78
|
expected = {
|
57
79
|
"00277"=>[:company, :sequence_date, :substances, :composition, :name_base],
|
@@ -112,23 +134,21 @@ module ODDB
|
|
112
134
|
assert_equal '005', result.replacements.values.first
|
113
135
|
end
|
114
136
|
def test_diff_error_column
|
115
|
-
|
137
|
+
assert_raises(RuntimeError) {
|
116
138
|
@diff.diff(@data_error_column, @older)
|
117
139
|
}
|
118
140
|
end
|
119
141
|
|
120
142
|
# if row.size < COLUMNS.size/2
|
143
|
+
# as per december 2013 does no longer raise an error, but outputs the problematic line
|
121
144
|
def test_diff_error_missing_case1
|
122
|
-
|
123
|
-
@diff.diff(@data_error_missing_case1, @older)
|
124
|
-
}
|
145
|
+
@diff.diff(@data_error_missing_case1, @older)
|
125
146
|
end
|
126
147
|
|
127
148
|
# if row.select{|val| val==nil}.size > COLUMNS.size/2
|
149
|
+
# as per december 2013 does no longer raise an error, but outputs the problematic line
|
128
150
|
def test_diff_error_missing_case2
|
129
|
-
|
130
|
-
@diff.diff(@data_error_missing_case2, @older)
|
131
|
-
}
|
151
|
+
@diff.diff(@data_error_missing_case2, @older)
|
132
152
|
end
|
133
153
|
def test_diff__ignore
|
134
154
|
ignore = [:company, :atc_class]
|
@@ -162,9 +182,7 @@ module ODDB
|
|
162
182
|
assert_equal '005', result.replacements.values.first
|
163
183
|
end
|
164
184
|
def test_to_s
|
165
|
-
|
166
|
-
@diff.to_s
|
167
|
-
}
|
185
|
+
@diff.to_s
|
168
186
|
@diff.diff(@data, @older)
|
169
187
|
assert_equal <<-EOS.strip, @diff.to_s
|
170
188
|
+ 00275: Cardio-Pulmo-Rénal Sérocytol, suppositoire
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swissmedic-diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdoc
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '4.0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '4.0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: hoe
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
37
|
+
version: '3.6'
|
38
38
|
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ~>
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: '
|
45
|
+
version: '3.6'
|
46
46
|
description: ! '* Compares two Excel Documents provided by Swissmedic and displays
|
47
47
|
the
|
48
48
|
|