oddb2tdat 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/History.txt +6 -0
  2. data/bin/oddb2tdat +5 -2
  3. data/lib/oddb2tdat.rb +41 -3
  4. metadata +26 -14
data/History.txt CHANGED
@@ -1,5 +1,11 @@
1
1
  === 1.0.4 / 13.01.2012
2
2
 
3
+ * Added readable instance variable @updated_prmo
4
+ * This fix will ad more PRMO prices for doctors if we have the price.
5
+ * First EAN then Pharmacode are matched.
6
+
7
+ === 1.0.4 / 13.01.2012
8
+
3
9
  * Update CMUT, if Gültig bis is before today CMUT = 3
4
10
  * Updated RECA, CMUT, PRMO, ITHE format
5
11
 
data/bin/oddb2tdat CHANGED
@@ -6,12 +6,15 @@ require 'oddb2tdat'
6
6
  def usage
7
7
  puts <<-EOS
8
8
  #$0 ver.#{Oddb2tdat::VERSION}
9
- Usage: #$0 <input file (oddb.csv)> <output file (oddb.dat)>
9
+ Usage:
10
+ #$0 <input file (oddb.csv)> <output file (oddb.dat)>
11
+ or
12
+ #$0 <input file (oddb.csv)> <output file (oddb.dat)> <transfer file (trasfer.dat)>
10
13
 
11
14
  EOS
12
15
  end
13
16
 
14
- if ARGV.length < 2 or !File.exist?(ARGV[0])
17
+ if ARGV.length < 2 or !File.exist?(ARGV[0]) or (ARGV[2] and !File.exist?(ARGV[2]))
15
18
  usage
16
19
  exit
17
20
  end
data/lib/oddb2tdat.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  #! /usr/bin/env ruby
2
2
  # encoding: utf-8
3
- # Oddb2tdat -- 13.01.2012 -- mhatakeyama@ywesee.com
3
+ # Oddb2tdat -- 20.01.2012 -- mhatakeyama@ywesee.com
4
4
 
5
5
  require 'date'
6
6
  =begin
@@ -22,7 +22,7 @@ require 'date'
22
22
  =end
23
23
 
24
24
  class Oddb2tdat
25
- VERSION = '1.0.4'
25
+ VERSION = '1.0.5'
26
26
  COL = {
27
27
  :CMUT => 30, # AE
28
28
  :PHAR => 6, # G
@@ -52,14 +52,25 @@ class Oddb2tdat
52
52
  :ITHE => 7,
53
53
  :CEAN => 13,
54
54
  }
55
+ POS = {
56
+ :PHAR => 3,
57
+ :PRMO => 60,
58
+ :PRPU => 66,
59
+ :CEAN => 83,
60
+ }
55
61
 
56
- def initialize(input, output)
62
+ def initialize(input, output, import=nil)
57
63
  @input = input
58
64
  @output = output
65
+ @import = import
59
66
  end
60
67
  def run
61
68
  parse
62
69
  output
70
+ if @import
71
+ @input = @output
72
+ import_prmo
73
+ end
63
74
  end
64
75
  def format_price(price_str, len=6, int_len=4, frac_len=2)
65
76
  price = price_str.split('.')
@@ -130,6 +141,33 @@ class Oddb2tdat
130
141
  end
131
142
  end
132
143
  end
144
+ attr_reader :updated_prmo
145
+ def import_prmo
146
+ import_ean = {}
147
+ import_pha = {}
148
+ File.readlines(@import).each do |line|
149
+ import_ean.store(line[POS[:CEAN], LEN[:CEAN]], line.chomp)
150
+ import_pha.store(line[POS[:PHAR], LEN[:PHAR]], line.chomp)
151
+ end
152
+
153
+ @rows = []
154
+ @updated_prmo = 0
155
+ File.readlines(@input).each do |line|
156
+ row = ''
157
+ if (ean_code = line[POS[:CEAN], LEN[:CEAN]] and line_imp = import_ean[ean_code]) \
158
+ or (pharma_code = line[POS[:PHAR], LEN[:PHAR]] and line_imp = import_pha[pharma_code])
159
+ row << line[0..(POS[:PRMO]-1)]
160
+ row << line_imp[POS[:PRMO], LEN[:PRMO]]
161
+ row << line[POS[:PRPU], 1000].chomp
162
+ @updated_prmo += 1
163
+ else
164
+ row << line.chomp
165
+ end
166
+ @rows << row
167
+ end
168
+
169
+ output
170
+ end
133
171
  def output
134
172
  open(@output, "w") do |out|
135
173
  @rows.each do |line|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oddb2tdat
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 4
10
- version: 1.0.4
9
+ - 5
10
+ version: 1.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Masaomi Hatakeyama, Zeno R.R. Davatz
@@ -15,25 +15,38 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-01-13 00:00:00 +01:00
19
- default_executable:
18
+ date: 2012-01-20 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- name: hoe
21
+ name: rdoc
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
27
- - - ">="
26
+ - - ~>
28
27
  - !ruby/object:Gem::Version
29
- hash: 41
28
+ hash: 19
30
29
  segments:
31
- - 2
32
- - 9
33
- - 1
34
- version: 2.9.1
30
+ - 3
31
+ - 10
32
+ version: "3.10"
35
33
  type: :development
36
34
  version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: hoe
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 27
44
+ segments:
45
+ - 2
46
+ - 12
47
+ version: "2.12"
48
+ type: :development
49
+ version_requirements: *id002
37
50
  description: |-
38
51
  * oddb2tdat converts oddb.csv to oddb.dat
39
52
  * http://dev.ywesee.com/wiki.php/ODDB/Oddb2tdat
@@ -54,7 +67,6 @@ files:
54
67
  - Rakefile
55
68
  - bin/oddb2tdat
56
69
  - lib/oddb2tdat.rb
57
- has_rdoc: true
58
70
  homepage: http://scm.ywesee.com/?p=oddb2tdat/.git;a=summary
59
71
  licenses: []
60
72
 
@@ -85,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
97
  requirements: []
86
98
 
87
99
  rubyforge_project: oddb2tdat
88
- rubygems_version: 1.4.2
100
+ rubygems_version: 1.8.15
89
101
  signing_key:
90
102
  specification_version: 3
91
103
  summary: "* oddb2tdat converts oddb.csv to oddb.dat * http://dev.ywesee.com/wiki.php/ODDB/Oddb2tdat"