patinfo2csv 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +6 -0
- data/lib/patinfo2csv/converter.rb +12 -8
- data/lib/version.rb +1 -1
- metadata +6 -6
data/History.txt
CHANGED
@@ -6,7 +6,6 @@ require 'thread'
|
|
6
6
|
module Patinfo2csv
|
7
7
|
class Converter
|
8
8
|
attr_accessor :patinfos, :codes, :lang
|
9
|
-
attr_reader :rows
|
10
9
|
CHAPTERS = [
|
11
10
|
:effects,
|
12
11
|
:contra_indications,
|
@@ -22,7 +21,7 @@ module Patinfo2csv
|
|
22
21
|
@lang = "de"
|
23
22
|
@patinfos = []
|
24
23
|
@codes = []
|
25
|
-
@rows =
|
24
|
+
@rows = {}
|
26
25
|
end
|
27
26
|
def to_csv
|
28
27
|
@patinfos.each do |row|
|
@@ -51,14 +50,15 @@ module Patinfo2csv
|
|
51
50
|
next if chapters.empty?
|
52
51
|
target.each do |code|
|
53
52
|
@mutex.synchronize do
|
54
|
-
@rows
|
53
|
+
@rows[code.to_i] = [%Q!"#{code}"!, chapters].flatten.join(DELIMITER)
|
55
54
|
end
|
56
55
|
end
|
57
56
|
end
|
58
57
|
end
|
59
58
|
end.map(&:join)
|
60
59
|
unless @rows.empty? #header
|
61
|
-
@rows.
|
60
|
+
rows = @rows.sort_by{|k, v| k}.map{|row| row[1]}
|
61
|
+
rows.unshift([
|
62
62
|
"EAN",
|
63
63
|
#"Pharmacode",
|
64
64
|
"Effects",
|
@@ -68,7 +68,7 @@ module Patinfo2csv
|
|
68
68
|
"Composition"
|
69
69
|
].join(DELIMITER))
|
70
70
|
end
|
71
|
-
return
|
71
|
+
return rows
|
72
72
|
end
|
73
73
|
def extract_chapters(row)
|
74
74
|
return nil if row['descriptions'][@lang].empty?
|
@@ -78,10 +78,14 @@ module Patinfo2csv
|
|
78
78
|
if (desc.has_key?(chapter.to_s) and !desc[chapter.to_s].nil?) and
|
79
79
|
!desc[chapter.to_s]['sections'].nil?
|
80
80
|
text = ''
|
81
|
+
heading = desc[chapter.to_s]['heading']
|
81
82
|
desc[chapter.to_s]['sections'].each do |section|
|
82
|
-
unless section['subheading'].empty?
|
83
|
-
|
84
|
-
|
83
|
+
heading = unless section['subheading'].empty?
|
84
|
+
section['subheading'].chomp
|
85
|
+
else
|
86
|
+
heading.chomp
|
87
|
+
end
|
88
|
+
text << "<strong>#{heading}</strong><br />"
|
85
89
|
if section.has_key?('paragraphs')
|
86
90
|
section['paragraphs'].each do |paragraph|
|
87
91
|
unless paragraph['text'].empty?
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patinfo2csv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdoc
|
16
|
-
requirement: &
|
16
|
+
requirement: &19689280 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.10'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *19689280
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: hoe
|
27
|
-
requirement: &
|
27
|
+
requirement: &19688840 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '2.13'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *19688840
|
36
36
|
description: ! 'Patinfo2csv extracts and converts patinfo.yaml to patinfo.csv;
|
37
37
|
|
38
38
|
only 4 chapters(de, text) in patinfo.yaml are extracted.
|