ebps 1.0.2
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 +3 -0
- data/InstalledFiles +36 -0
- data/LICENSE.txt +339 -0
- data/Manifest.txt +56 -0
- data/README.txt +28 -0
- data/Rakefile +28 -0
- data/SetupConfig +30 -0
- data/bin/ebps +86 -0
- data/example/config.yml +12 -0
- data/example/converter_for_firefox.rb +59 -0
- data/example/data.yml +60 -0
- data/example/example.sh +3 -0
- data/example/sample.epub +0 -0
- data/lib/ebps.rb +5 -0
- data/lib/ebps/config.rb +61 -0
- data/lib/ebps/conversion/de_fachinfo_yaml.rb +81 -0
- data/lib/ebps/conversion/epub.rb +38 -0
- data/lib/ebps/conversion/fachinfo_xml.rb +170 -0
- data/lib/ebps/conversion/fachinfo_yaml.rb +113 -0
- data/lib/ebps/conversion/import_module_sample.rb +86 -0
- data/lib/ebps/conversion/mobi_pocket.rb +30 -0
- data/lib/ebps/conversion/oebps.rb +537 -0
- data/lib/ebps/conversion/patinfo_yaml.rb +107 -0
- data/lib/ebps/data/default_cover.jpg +0 -0
- data/lib/ebps/data/stylesheet.css +16 -0
- data/lib/ebps/postprocess/bookworm.rb +16 -0
- data/lib/ebps/postprocess/copy.rb +28 -0
- data/lib/ebps/postprocess/system_call.rb +18 -0
- data/lib/ebps/preprocess/copy.rb +28 -0
- data/lib/ebps/preprocess/system_call.rb +18 -0
- data/lib/ebps/text/chapter.rb +36 -0
- data/lib/ebps/text/document.rb +36 -0
- data/lib/ebps/text/format.rb +34 -0
- data/lib/ebps/text/paragraph.rb +63 -0
- data/lib/ebps/text/picture.rb +41 -0
- data/lib/ebps/text/table.rb +65 -0
- data/lib/ebps/util/mail.rb +47 -0
- data/lib/ebps/util/smtp_tls.rb +62 -0
- data/spec/conversion/data/DF_15164_1_3.gif +0 -0
- data/spec/conversion/data/DF_15164_2_3.gif +0 -0
- data/spec/conversion/data/appendix.png +0 -0
- data/spec/conversion/data/fachinfo.xml +1151 -0
- data/spec/conversion/data/fachinfo.yaml +1214 -0
- data/spec/conversion/data/fachinfo_with_image.xml +334 -0
- data/spec/conversion/data/fachinfo_with_table.xml +1101 -0
- data/spec/conversion/data/fachinfos.de.oddb.yaml +5789 -0
- data/spec/conversion/data/images/5c/5c54d52c8132230e8c40c37a428fe761.png +0 -0
- data/spec/conversion/de_fachinfo_yaml_spec.rb +86 -0
- data/spec/conversion/epub_spec.rb +59 -0
- data/spec/conversion/fachinfo_xml_spec.rb +245 -0
- data/spec/conversion/fachinfo_yaml_spec.rb +52 -0
- data/spec/conversion/mobi_pocket_spec.rb +55 -0
- data/spec/conversion/oebps_spec.rb +555 -0
- data/spec/text/chapter_spec.rb +65 -0
- data/spec/text/document_spec.rb +78 -0
- data/spec/text/paragraph_spec.rb +77 -0
- metadata +145 -0
Binary file
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# - encoding:utf-8
|
2
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'ebps/conversion/de_fachinfo_yaml'
|
5
|
+
|
6
|
+
module EBPS
|
7
|
+
module Conversion
|
8
|
+
describe DeFachinfoYaml, ".import" do
|
9
|
+
before :each do
|
10
|
+
EBPS.config.language = 'de'
|
11
|
+
EBPS.config.image_prefix = File.expand_path('data', File.dirname(__FILE__))
|
12
|
+
end
|
13
|
+
it "returns an Array of Documents" do
|
14
|
+
DeFachinfoYaml.import('').should == []
|
15
|
+
path = File.expand_path 'data/fachinfos.de.oddb.yaml',
|
16
|
+
File.dirname(__FILE__)
|
17
|
+
docs = DeFachinfoYaml.import File.open(path)
|
18
|
+
docs.should be_an_instance_of Array
|
19
|
+
docs.size.should == 3
|
20
|
+
doc = docs.first
|
21
|
+
doc.should be_an_instance_of EBPS::Text::Document
|
22
|
+
doc.title.should == 'Fortecortin 4'
|
23
|
+
chapters = doc.chapters
|
24
|
+
chapters.size.should == 28
|
25
|
+
chapter = chapters.first
|
26
|
+
chapter.heading.should == "1.\tBezeichnung des Arzneimittels"
|
27
|
+
paragraphs = chapter.paragraphs
|
28
|
+
paragraphs.size.should == 4
|
29
|
+
paragraph = paragraphs.first
|
30
|
+
paragraph.should be_instance_of(EBPS::Text::Paragraph)
|
31
|
+
paragraph.text.should == "Fortecortin 0,5 mg Tabletten "
|
32
|
+
chapter = chapters.at(1)
|
33
|
+
chapter.heading.should == "2.\tQualitative und quantitative Zusammensetzung"
|
34
|
+
paragraphs = chapter.paragraphs
|
35
|
+
paragraphs.size.should == 5
|
36
|
+
p1, p2, p3 = paragraphs
|
37
|
+
p1.should be_instance_of(EBPS::Text::Paragraph)
|
38
|
+
p1.text.should == "Für Tabletten 0,5 mg: 1 Tablette enthält 0,5 mg Dexamethason."
|
39
|
+
p2.should be_instance_of(EBPS::Text::Paragraph)
|
40
|
+
p2.text.should == "Für Tabletten 2 mg: 1 Tablette enthält 2 mg Dexamethason."
|
41
|
+
p3.should be_instance_of(EBPS::Text::Paragraph)
|
42
|
+
p3.text.should == "Für Tabletten 4 mg: 1 Tablette enthält 4 mg Dexamethason."
|
43
|
+
|
44
|
+
doc = docs.at(1)
|
45
|
+
doc.should be_an_instance_of EBPS::Text::Document
|
46
|
+
doc.title.should == 'Sirdalud'
|
47
|
+
chapters = doc.chapters
|
48
|
+
chapters.size.should == 29
|
49
|
+
chapter = chapters.at(5)
|
50
|
+
chapter.heading.should == '4.2 Dosierung, Art und Dauer der Anwendung'
|
51
|
+
paragraphs = chapter.paragraphs
|
52
|
+
paragraphs.size.should == 23
|
53
|
+
subheading = paragraphs.first
|
54
|
+
subheading.should be_instance_of(EBPS::Text::Subheading)
|
55
|
+
subheading.text.should == "Behandlung peripher bedingter schmerzhafter Muskelverspannungen"
|
56
|
+
chapter = chapters.at(11)
|
57
|
+
chapter.heading.should == '4.8 Nebenwirkungen'
|
58
|
+
paragraphs = chapter.paragraphs
|
59
|
+
paragraphs.size.should == 5
|
60
|
+
paragraph = paragraphs.first
|
61
|
+
paragraph.should be_instance_of(EBPS::Text::Paragraph)
|
62
|
+
paragraph.text.should == "Bei der Bewertung von Nebenwirkungen werden folgende Häufigkeitsangaben zugrunde gelegt: Sehr häufig: > 10 %; häufig: > 1 % -< 10 %; gelegentlich: > 0,1 % - < 1 %; selten: > 0,01 % -< 0,1 %; sehr selten: < 0,01 %."
|
63
|
+
table = paragraphs.at(1)
|
64
|
+
table.should be_instance_of(EBPS::Text::Table)
|
65
|
+
rows = table.rows
|
66
|
+
rows.size.should == 20
|
67
|
+
row = rows.first
|
68
|
+
row.size.should == 1
|
69
|
+
paragraph = row.first
|
70
|
+
paragraph.should be_instance_of(EBPS::Text::Paragraph)
|
71
|
+
paragraph.text.should == 'Psychiatrische Erkrankungen'
|
72
|
+
|
73
|
+
doc = docs.last
|
74
|
+
doc.should be_an_instance_of EBPS::Text::Document
|
75
|
+
doc.title.should == 'Ate Lich'
|
76
|
+
chapters = doc.chapters
|
77
|
+
chapters.size.should == 28
|
78
|
+
chapter = chapters.at 16
|
79
|
+
paragraphs = chapter.paragraphs
|
80
|
+
paragraphs.size.should == 21
|
81
|
+
paragraph = paragraphs.at 20
|
82
|
+
paragraph.should be_instance_of(EBPS::Text::Picture)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# - encoding:utf-8
|
2
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'ebps/conversion/epub'
|
5
|
+
require 'rexml/document'
|
6
|
+
|
7
|
+
module EBPS
|
8
|
+
module Conversion
|
9
|
+
describe Epub, ".export" do
|
10
|
+
before :each do
|
11
|
+
@var = File.expand_path 'var', File.dirname(__FILE__)
|
12
|
+
FileUtils.mkdir_p @var
|
13
|
+
@doc1 = EBPS::Text::Document.new
|
14
|
+
@doc1.title = 'My Title'
|
15
|
+
c1 = EBPS::Text::Chapter.new
|
16
|
+
c1.heading << '1. Introduction'
|
17
|
+
c1.add_paragraph EBPS::Text::Paragraph.new('Some text')
|
18
|
+
@doc1.add_chapter c1
|
19
|
+
c2 = EBPS::Text::Chapter.new
|
20
|
+
c2.heading << '2. Abstract'
|
21
|
+
c2.add_paragraph EBPS::Text::Subheading.new('2.1 Current Status')
|
22
|
+
c2.add_paragraph EBPS::Text::Paragraph.new('Some more text')
|
23
|
+
par = EBPS::Text::Paragraph.new
|
24
|
+
par << 'Some '
|
25
|
+
par.set_format 'i'
|
26
|
+
par << 'formatted '
|
27
|
+
par.set_format 'b'
|
28
|
+
par << 'text '
|
29
|
+
par.set_format 'b', 'i'
|
30
|
+
par << 'bits.'
|
31
|
+
c2.add_paragraph par
|
32
|
+
@doc1.add_chapter c2
|
33
|
+
@doc2 = EBPS::Text::Document.new
|
34
|
+
@doc2.title = 'Much Shorter'
|
35
|
+
c3 = EBPS::Text::Chapter.new
|
36
|
+
c3.heading << '1. Short Story'
|
37
|
+
c3.add_paragraph EBPS::Text::Paragraph.new('Why did the Chicken?')
|
38
|
+
EBPS.config.language = 'en'
|
39
|
+
EBPS.config.xml_indent = 2
|
40
|
+
EBPS.config.content_title = 'Content'
|
41
|
+
end
|
42
|
+
after :each do
|
43
|
+
FileUtils.rm_r @var
|
44
|
+
end
|
45
|
+
it "creates all necessary files and compiles the book to a temporary ouput file" do
|
46
|
+
target = 'result.epub'
|
47
|
+
Epub.export [@doc1, @doc2], target, @var
|
48
|
+
File.should exist(target)
|
49
|
+
stream = Zip::ZipInputStream.new target
|
50
|
+
entry = stream.get_next_entry
|
51
|
+
entry.name.should == 'mimetype'
|
52
|
+
entry.get_input_stream.read.should == 'application/epub+zip'
|
53
|
+
entry.compression_method.should == 0
|
54
|
+
entry = stream.get_next_entry
|
55
|
+
entry.name.should == 'META-INF/container.xml'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,245 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'ebps/conversion/fachinfo_xml'
|
5
|
+
|
6
|
+
module EBPS
|
7
|
+
module Conversion
|
8
|
+
module FachinfoXml
|
9
|
+
describe StreamListener do
|
10
|
+
before :each do
|
11
|
+
@listener = StreamListener.new
|
12
|
+
end
|
13
|
+
it "initially returns an empty Array" do
|
14
|
+
@listener.documents.should == []
|
15
|
+
end
|
16
|
+
it "ignores the monographies tag" do
|
17
|
+
@listener.documents.should == []
|
18
|
+
@listener.start_monographies({})
|
19
|
+
@listener.documents.should == []
|
20
|
+
end
|
21
|
+
it "creates a new document for each fi tag" do
|
22
|
+
@listener.documents.should == []
|
23
|
+
fi = @listener.start_fi({})
|
24
|
+
fi.should equal(@listener.current_document)
|
25
|
+
@listener.documents.should == [fi]
|
26
|
+
end
|
27
|
+
it "sets the current document's title after the title tag has closed" do
|
28
|
+
document = @listener.start_fi({})
|
29
|
+
@listener.start_title({})
|
30
|
+
@listener.text 'my title'
|
31
|
+
document.title.should == 'my title'
|
32
|
+
end
|
33
|
+
it "the owner tag generates a new chapter" do
|
34
|
+
document = @listener.start_fi({})
|
35
|
+
chapter = @listener.start_owner({})
|
36
|
+
document.chapters.size.should == 1
|
37
|
+
@listener.text 'the owner'
|
38
|
+
chapter.to_s.should == 'the owner'
|
39
|
+
end
|
40
|
+
it "the paragraph tag generates a new chapter" do
|
41
|
+
document = @listener.start_fi({})
|
42
|
+
chapter = @listener.start_paragraph({})
|
43
|
+
chapter.should be_instance_of(EBPS::Text::Chapter)
|
44
|
+
@listener.current_chapter.should equal(chapter)
|
45
|
+
document.chapters.should == [chapter]
|
46
|
+
@listener.end_paragraph
|
47
|
+
@listener.current_chapter.should == nil
|
48
|
+
end
|
49
|
+
it "the paragraphTitle tag targets the current chapter's heading" do
|
50
|
+
document = @listener.start_fi({})
|
51
|
+
chapter = @listener.start_paragraph({})
|
52
|
+
heading = @listener.start_paragraphTitle({})
|
53
|
+
@listener.current_target.should equal(heading)
|
54
|
+
heading.should == ''
|
55
|
+
@listener.text 'the heading'
|
56
|
+
heading.should == 'the heading'
|
57
|
+
@listener.end_paragraphTitle
|
58
|
+
@listener.current_target.should == nil
|
59
|
+
end
|
60
|
+
it "the p tag generates a new paragraph" do
|
61
|
+
document = @listener.start_fi({})
|
62
|
+
chapter = @listener.start_paragraph({})
|
63
|
+
paragraph = @listener.start_p({})
|
64
|
+
paragraph.should be_instance_of(EBPS::Text::Paragraph)
|
65
|
+
@listener.current_target.should equal(paragraph)
|
66
|
+
paragraph.to_s.should == ''
|
67
|
+
paragraph.formats.size.should == 1
|
68
|
+
paragraph.formats.first.should be_instance_of(EBPS::Text::Format)
|
69
|
+
paragraph.formats.first.values.should == []
|
70
|
+
@listener.text 'the paragraph'
|
71
|
+
paragraph.to_s.should == 'the paragraph'
|
72
|
+
paragraph.formats.size.should == 1
|
73
|
+
paragraph.formats.first.should be_instance_of(EBPS::Text::Format)
|
74
|
+
paragraph.formats.first.values.should == []
|
75
|
+
@listener.end_p
|
76
|
+
@listener.current_target.should == nil
|
77
|
+
end
|
78
|
+
it "the paragraphSubtitle tag generates a Subheading" do
|
79
|
+
document = @listener.start_fi({})
|
80
|
+
chapter = @listener.start_paragraph({})
|
81
|
+
paragraph = @listener.start_paragraphSubtitle({})
|
82
|
+
paragraph.should be_instance_of(EBPS::Text::Subheading)
|
83
|
+
@listener.current_target.should equal(paragraph)
|
84
|
+
paragraph.to_s.should == ''
|
85
|
+
paragraph.formats.size.should == 1
|
86
|
+
paragraph.formats.first.should be_instance_of(EBPS::Text::Format)
|
87
|
+
paragraph.formats.first.values.should == []
|
88
|
+
@listener.text 'the paragraph'
|
89
|
+
paragraph.to_s.should == 'the paragraph'
|
90
|
+
paragraph.formats.size.should == 1
|
91
|
+
paragraph.formats.first.should be_instance_of(EBPS::Text::Format)
|
92
|
+
paragraph.formats.first.values.should == []
|
93
|
+
@listener.end_p
|
94
|
+
@listener.current_target.should == nil
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
describe FachinfoXml, ".import" do
|
99
|
+
before :each do
|
100
|
+
@dir = File.expand_path 'data', File.dirname(__FILE__)
|
101
|
+
EBPS.config.image_prefix = @dir
|
102
|
+
EBPS.config.image_suffix = '.gif'
|
103
|
+
end
|
104
|
+
it "returns an Array of Documents" do
|
105
|
+
FachinfoXml.import('').should == []
|
106
|
+
path = File.join @dir, 'fachinfo.xml'
|
107
|
+
docs = FachinfoXml.import File.open(path)
|
108
|
+
docs.should be_an_instance_of Array
|
109
|
+
docs.size.should == 2
|
110
|
+
doc = docs.first
|
111
|
+
doc.should be_an_instance_of EBPS::Text::Document
|
112
|
+
doc.title.should == 'Abilify®'
|
113
|
+
doc.chapters.size.should == 20
|
114
|
+
chapter = doc.chapters.at(2)
|
115
|
+
chapter.heading.should == 'Zusammensetzung'
|
116
|
+
chapter.paragraphs.size.should == 5
|
117
|
+
chapter.paragraphs.first.to_s.should == "Wirkstoff: Aripiprazolum."
|
118
|
+
chapter.paragraphs.last.to_s.should == <<-EOS.strip
|
119
|
+
Sirup: Saccharum (400 mg/ml), Fructosum (200 mg/ml), Dinatrii edetas, Glycerolum, Acidum lacticum, Propylenglycolum, Natrii hydroxidum, Aqua purificata, Aromatica: Vanillinum et alia; Conserv.: Methylis parahydroxybenzoas (E218), Propylis parahydroxybenzoas (E216).
|
120
|
+
EOS
|
121
|
+
end
|
122
|
+
it "can handle table tags (and treats them as preformatted text)" do
|
123
|
+
FachinfoXml.import('').should == []
|
124
|
+
path = File.join @dir, 'fachinfo_with_table.xml'
|
125
|
+
docs = FachinfoXml.import File.open(path)
|
126
|
+
docs.should be_an_instance_of Array
|
127
|
+
docs.size.should == 2
|
128
|
+
doc = docs.first
|
129
|
+
doc.should be_an_instance_of EBPS::Text::Document
|
130
|
+
doc.title.should == 'Actilyse®'
|
131
|
+
doc.chapters.size.should == 20
|
132
|
+
chapter = doc.chapters.at(11)
|
133
|
+
chapter.heading.should == 'Unerwünschte Wirkungen'
|
134
|
+
chapter.paragraphs.size.should == 43
|
135
|
+
par = chapter.paragraphs.at(7)
|
136
|
+
par.formats.size.should == 1
|
137
|
+
fmt = par.formats.first
|
138
|
+
fmt.values.should == ['pre']
|
139
|
+
par.to_s.should == <<-EOS
|
140
|
+
Unerwünschte Wirkungen % Patienten
|
141
|
+
Funktionsstörungen des Herzens und der Gefässe
|
142
|
+
Blutungen insgesamt (wie Hämatom) 29,81
|
143
|
+
Allgemeine Störungen und Bedingungen
|
144
|
+
am Applikationsort
|
145
|
+
Oberflächliche Blutung, normalerweise
|
146
|
+
von Punktionen oder Gefässverletzungen
|
147
|
+
(wie Katheter-Hämatom, Blutung an
|
148
|
+
der Katheterstelle, Blutung an
|
149
|
+
der Injektionsstelle) 11,93
|
150
|
+
Untersuchungen
|
151
|
+
Blutdruckabfall 16,01
|
152
|
+
EOS
|
153
|
+
end
|
154
|
+
it "can handle table tags (and preserves leading whitespace)" do
|
155
|
+
FachinfoXml.import('').should == []
|
156
|
+
path = File.join @dir, 'fachinfo_with_table.xml'
|
157
|
+
docs = FachinfoXml.import File.open(path)
|
158
|
+
docs.should be_an_instance_of Array
|
159
|
+
docs.size.should == 2
|
160
|
+
doc = docs.last
|
161
|
+
doc.should be_an_instance_of EBPS::Text::Document
|
162
|
+
doc.title.should == 'Amoxicillin - 1 A Pharma'
|
163
|
+
doc.chapters.size.should == 20
|
164
|
+
chapter = doc.chapters.at(13)
|
165
|
+
chapter.heading.should == 'Eigenschaften/Wirkungen'
|
166
|
+
chapter.paragraphs.size.should == 17
|
167
|
+
par = chapter.paragraphs.at(6)
|
168
|
+
par.formats.size.should == 1
|
169
|
+
fmt = par.formats.first
|
170
|
+
fmt.values.should == ['pre']
|
171
|
+
par.to_s.should == <<-EOS
|
172
|
+
Erreger Minimale Hemmkonzentration
|
173
|
+
MHK (µg/ml)
|
174
|
+
0,01–0,10 0,11–1,0 1,1–5
|
175
|
+
Staphylococcus aureus
|
176
|
+
(ausgenommen die
|
177
|
+
beta-Lactamase
|
178
|
+
bildenden Stämme) X
|
179
|
+
Streptococcus pyogenes X
|
180
|
+
Streptococcus pneumoniae X
|
181
|
+
Streptococcus viridans X
|
182
|
+
Streptococcus faecalis X
|
183
|
+
Listeria monocytogenes X
|
184
|
+
Clostridium difficile 0 X
|
185
|
+
Clostridium perfringens X
|
186
|
+
Peptococcus spp. X
|
187
|
+
Peptostreptococcus X
|
188
|
+
Escherichia coli 0
|
189
|
+
Proteus mirabilis X
|
190
|
+
Haemophilus influenzae
|
191
|
+
(ausgenommen die
|
192
|
+
beta-Lactamase
|
193
|
+
bildenden Stämme) X
|
194
|
+
Salmonella spp. X
|
195
|
+
Shigella spp. 0
|
196
|
+
Helicobacter pylori 0 X
|
197
|
+
Neisseria gonorrhoeae
|
198
|
+
(ausgenommen die
|
199
|
+
beta-Lactamase
|
200
|
+
bildenden Stämme) X
|
201
|
+
Neisseria meningitidis X
|
202
|
+
Borrelia burgdorferi X
|
203
|
+
EOS
|
204
|
+
end
|
205
|
+
it "can handle image tags (and downloads them to a temporary directory)" do
|
206
|
+
FachinfoXml.import('').should == []
|
207
|
+
path = File.join @dir, 'fachinfo_with_image.xml'
|
208
|
+
docs = FachinfoXml.import File.open(path)
|
209
|
+
docs.should be_an_instance_of Array
|
210
|
+
docs.size.should == 1
|
211
|
+
doc = docs.first
|
212
|
+
doc.should be_an_instance_of EBPS::Text::Document
|
213
|
+
doc.title.should == 'Apidra®'
|
214
|
+
doc.chapters.size.should == 20
|
215
|
+
chapter = doc.chapters.at(13)
|
216
|
+
chapter.heading.should == 'Eigenschaften/Wirkungen'
|
217
|
+
chapter.paragraphs.size.should == 14
|
218
|
+
chapter.paragraphs.at(6).should be_a(EBPS::Text::Picture)
|
219
|
+
end
|
220
|
+
it "raises an error if image pre- and postfix aren't configured" do
|
221
|
+
FachinfoXml.import('').should == []
|
222
|
+
EBPS.config.image_prefix = nil
|
223
|
+
EBPS.config.image_suffix = nil
|
224
|
+
path = File.join @dir, 'fachinfo_with_image.xml'
|
225
|
+
txt = <<-EOS
|
226
|
+
This monography contains images.
|
227
|
+
Please configure both image_prefix and image_suffix
|
228
|
+
EOS
|
229
|
+
lambda do
|
230
|
+
FachinfoXml.import File.open(path)
|
231
|
+
|
232
|
+
end.should raise_error RuntimeError, txt
|
233
|
+
EBPS.config.image_prefix = @dir
|
234
|
+
lambda do
|
235
|
+
FachinfoXml.import File.open(path)
|
236
|
+
end.should raise_error RuntimeError, txt
|
237
|
+
EBPS.config.image_prefix = nil
|
238
|
+
EBPS.config.image_suffix = '.gif'
|
239
|
+
lambda do
|
240
|
+
FachinfoXml.import File.open(path)
|
241
|
+
end.should raise_error RuntimeError, txt
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# - encoding:utf-8
|
2
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'ebps/conversion/fachinfo_yaml'
|
5
|
+
|
6
|
+
module EBPS
|
7
|
+
module Conversion
|
8
|
+
describe FachinfoYaml, ".import" do
|
9
|
+
before :each do
|
10
|
+
EBPS.config.language = 'de'
|
11
|
+
end
|
12
|
+
it "returns an Array of Documents" do
|
13
|
+
FachinfoYaml.import('').should == []
|
14
|
+
path = File.expand_path 'data/fachinfo.yaml', File.dirname(__FILE__)
|
15
|
+
docs = FachinfoYaml.import File.open(path)
|
16
|
+
docs.should be_an_instance_of Array
|
17
|
+
docs.size.should == 2
|
18
|
+
doc = docs.first
|
19
|
+
doc.should be_an_instance_of EBPS::Text::Document
|
20
|
+
doc.title.should == 'Cerumenol'
|
21
|
+
chapters = doc.chapters
|
22
|
+
chapters.size.should == 13
|
23
|
+
chapter = chapters.first
|
24
|
+
chapter.heading.should == ''
|
25
|
+
paragraphs = chapter.paragraphs
|
26
|
+
paragraphs.size.should == 1
|
27
|
+
paragraph = paragraphs.first
|
28
|
+
paragraph.should be_instance_of(EBPS::Text::Subheading)
|
29
|
+
paragraph.text.should == "Lösung zum Aufweichen von Ceruminalpfropfen"
|
30
|
+
chapter = chapters.at(1)
|
31
|
+
chapter.heading.should == 'Zusammensetzung'
|
32
|
+
paragraphs = chapter.paragraphs
|
33
|
+
paragraphs.size.should == 3
|
34
|
+
p1, p2, p3 = paragraphs
|
35
|
+
p1.should be_instance_of(EBPS::Text::Paragraph)
|
36
|
+
p1.text.should == "1\xC2\xA0ml enthält:"
|
37
|
+
p2.should be_instance_of(EBPS::Text::Subheading)
|
38
|
+
p2.text.should == "Wirkstoffe:"
|
39
|
+
p3.should be_instance_of(EBPS::Text::Paragraph)
|
40
|
+
p3.text.should == "Paradichlorobenzenum 20 mg; Orthodichlorobenzenum 145 mg; Chlorobutanolum hemihydricum 50 mg; Terebinthinae aetheroleum medicinale 86 mg; 3-Methoxy-butylis acetas 95 mg."
|
41
|
+
|
42
|
+
doc = docs.last
|
43
|
+
doc.should be_an_instance_of EBPS::Text::Document
|
44
|
+
doc.title.should == 'Phol-Tux® expectorans'
|
45
|
+
doc.metadata.should == {
|
46
|
+
"oid" => 605,
|
47
|
+
"article_codes" => [ { :article_ean13=>"7680426370173", :article_pcode=>"1057172" } ]
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# - encoding:utf-8
|
2
|
+
$: << File.expand_path('../../lib', File.dirname(__FILE__))
|
3
|
+
|
4
|
+
require 'ebps/conversion/mobi_pocket'
|
5
|
+
require 'rexml/document'
|
6
|
+
|
7
|
+
module EBPS
|
8
|
+
module Conversion
|
9
|
+
describe MobiPocket, ".export" do
|
10
|
+
before :each do
|
11
|
+
@var = File.expand_path 'var', File.dirname(__FILE__)
|
12
|
+
FileUtils.mkdir_p @var
|
13
|
+
@doc1 = EBPS::Text::Document.new
|
14
|
+
@doc1.title = 'My Title'
|
15
|
+
c1 = EBPS::Text::Chapter.new
|
16
|
+
c1.heading << '1. Introduction'
|
17
|
+
c1.add_paragraph EBPS::Text::Paragraph.new('Some text')
|
18
|
+
@doc1.add_chapter c1
|
19
|
+
c2 = EBPS::Text::Chapter.new
|
20
|
+
c2.heading << '2. Abstract'
|
21
|
+
c2.add_paragraph EBPS::Text::Subheading.new('2.1 Current Status')
|
22
|
+
c2.add_paragraph EBPS::Text::Paragraph.new('Some more text')
|
23
|
+
par = EBPS::Text::Paragraph.new
|
24
|
+
par << 'Some '
|
25
|
+
par.set_format 'i'
|
26
|
+
par << 'formatted '
|
27
|
+
par.set_format 'b'
|
28
|
+
par << 'text '
|
29
|
+
par.set_format 'b', 'i'
|
30
|
+
par << 'bits.'
|
31
|
+
c2.add_paragraph par
|
32
|
+
@doc1.add_chapter c2
|
33
|
+
@doc2 = EBPS::Text::Document.new
|
34
|
+
@doc2.title = 'Much Shorter'
|
35
|
+
c3 = EBPS::Text::Chapter.new
|
36
|
+
c3.heading << '1. Short Story'
|
37
|
+
c3.add_paragraph EBPS::Text::Paragraph.new('Why did the Chicken?')
|
38
|
+
EBPS.config.language = 'en'
|
39
|
+
EBPS.config.xml_indent = 2
|
40
|
+
EBPS.config.content_title = 'Content'
|
41
|
+
end
|
42
|
+
after :each do
|
43
|
+
FileUtils.rm_r @var
|
44
|
+
EBPS.config.kindle_quirks = false
|
45
|
+
end
|
46
|
+
it "creates all necessary files and compiles the book to a temporary ouput file" do
|
47
|
+
target = File.join @var, 'target.mobi'
|
48
|
+
MobiPocket.export [@doc1, @doc2], target, @var
|
49
|
+
output = File.join @var, 'mobipocket.azw'
|
50
|
+
File.should exist(output)
|
51
|
+
File.should exist(target)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|