patinfo2csv 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ === 1.0.8 / 18.04.2012
2
+
3
+ * Added heading as strong tag
4
+
5
+ - if patinfo does not have subheading in chapter, add this heading.
6
+
1
7
  === 1.0.7 / 11.04.2012
2
8
 
3
9
  * Upated Manifest.txt to include loader
@@ -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 << [%Q!"#{code}"!, chapters].flatten.join(DELIMITER)
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.unshift([
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 @rows
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
- text << "<strong>#{section['subheading'].chomp}</strong><br />"
84
- end
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?
@@ -1,3 +1,3 @@
1
1
  module Patinfo2csv
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
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.7
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-11 00:00:00.000000000 Z
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: &11091500 !ruby/object:Gem::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: *11091500
24
+ version_requirements: *19689280
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hoe
27
- requirement: &11091040 !ruby/object:Gem::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: *11091040
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.