caracal_the_curve 1.4.1 → 1.4.3
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.
- checksums.yaml +4 -4
- data/caracal.gemspec +2 -2
- data/lib/caracal/core/fields.rb +34 -0
- data/lib/caracal/core/footer.rb +33 -0
- data/lib/caracal/core/header.rb +32 -0
- data/lib/caracal/core/models/field_model.rb +124 -0
- data/lib/caracal/core/models/footer_model.rb +42 -0
- data/lib/caracal/core/models/header_model.rb +42 -0
- data/lib/caracal/core/models/page_flip_model.rb +41 -0
- data/lib/caracal/core/models/paragraph_model.rb +15 -0
- data/lib/caracal/core/models/relationship_model.rb +1 -0
- data/lib/caracal/core/models/style_model.rb +6 -2
- data/lib/caracal/core/models/table_of_contents_model.rb +81 -0
- data/lib/caracal/core/page_flips.rb +34 -0
- data/lib/caracal/core/relationships.rb +1 -0
- data/lib/caracal/core/styles.rb +7 -7
- data/lib/caracal/core/table_of_contents.rb +34 -0
- data/lib/caracal/document.rb +26 -0
- data/lib/caracal/renderers/content_types_renderer.rb +1 -0
- data/lib/caracal/renderers/document_renderer.rb +105 -4
- data/lib/caracal/renderers/footer_renderer.rb +42 -29
- data/lib/caracal/renderers/header_renderer.rb +61 -0
- data/lib/caracal/renderers/settings_renderer.rb +2 -1
- data/lib/caracal/renderers/styles_renderer.rb +2 -0
- data/lib/caracal/version.rb +1 -1
- data/lib/caracal.rb +24 -0
- data/spec/lib/caracal/core/fields_spec.rb +25 -0
- data/spec/lib/caracal/core/footer_spec.rb +31 -0
- data/spec/lib/caracal/core/header_spec.rb +31 -0
- data/spec/lib/caracal/core/models/footer_model_spec.rb +40 -0
- data/spec/lib/caracal/core/models/header_model_spec.rb +40 -0
- data/spec/lib/caracal/core/models/page_flip_model_spec.rb +34 -0
- data/spec/lib/caracal/core/models/paragraph_model_spec.rb +18 -1
- data/spec/lib/caracal/core/models/style_model_spec.rb +8 -1
- data/spec/lib/caracal/core/models/table_of_contents_model_spec.rb +89 -0
- data/spec/lib/caracal/core/page_flip_spec.rb +27 -0
- data/spec/lib/caracal/core/relationships_spec.rb +2 -2
- metadata +34 -3
data/lib/caracal/document.rb
CHANGED
@@ -3,8 +3,11 @@ require 'zip'
|
|
3
3
|
|
4
4
|
require 'caracal/core/bookmarks'
|
5
5
|
require 'caracal/core/custom_properties'
|
6
|
+
require 'caracal/core/fields'
|
6
7
|
require 'caracal/core/file_name'
|
7
8
|
require 'caracal/core/fonts'
|
9
|
+
require 'caracal/core/footer'
|
10
|
+
require 'caracal/core/header'
|
8
11
|
require 'caracal/core/iframes'
|
9
12
|
require 'caracal/core/ignorables'
|
10
13
|
require 'caracal/core/images'
|
@@ -12,12 +15,14 @@ require 'caracal/core/list_styles'
|
|
12
15
|
require 'caracal/core/lists'
|
13
16
|
require 'caracal/core/namespaces'
|
14
17
|
require 'caracal/core/page_breaks'
|
18
|
+
require 'caracal/core/page_flips'
|
15
19
|
require 'caracal/core/page_numbers'
|
16
20
|
require 'caracal/core/page_settings'
|
17
21
|
require 'caracal/core/relationships'
|
18
22
|
require 'caracal/core/rules'
|
19
23
|
require 'caracal/core/styles'
|
20
24
|
require 'caracal/core/tables'
|
25
|
+
require 'caracal/core/table_of_contents'
|
21
26
|
require 'caracal/core/text'
|
22
27
|
|
23
28
|
require 'caracal/renderers/app_renderer'
|
@@ -27,6 +32,7 @@ require 'caracal/renderers/custom_renderer'
|
|
27
32
|
require 'caracal/renderers/document_renderer'
|
28
33
|
require 'caracal/renderers/fonts_renderer'
|
29
34
|
require 'caracal/renderers/footer_renderer'
|
35
|
+
require 'caracal/renderers/header_renderer'
|
30
36
|
require 'caracal/renderers/numbering_renderer'
|
31
37
|
require 'caracal/renderers/package_relationships_renderer'
|
32
38
|
require 'caracal/renderers/relationships_renderer'
|
@@ -55,14 +61,19 @@ module Caracal
|
|
55
61
|
include Caracal::Core::ListStyles
|
56
62
|
|
57
63
|
include Caracal::Core::Bookmarks
|
64
|
+
include Caracal::Core::Fields
|
58
65
|
include Caracal::Core::IFrames
|
59
66
|
include Caracal::Core::Images
|
60
67
|
include Caracal::Core::Lists
|
68
|
+
include Caracal::Core::PageFlips
|
61
69
|
include Caracal::Core::PageBreaks
|
62
70
|
include Caracal::Core::Rules
|
63
71
|
include Caracal::Core::Tables
|
72
|
+
include Caracal::Core::TableOfContents
|
64
73
|
include Caracal::Core::Text
|
65
74
|
|
75
|
+
include Caracal::Core::Footer
|
76
|
+
include Caracal::Core::Header
|
66
77
|
|
67
78
|
#------------------------------------------------------
|
68
79
|
# Public Class Methods
|
@@ -129,6 +140,13 @@ module Caracal
|
|
129
140
|
@contents ||= []
|
130
141
|
end
|
131
142
|
|
143
|
+
def footer_content
|
144
|
+
@footer_content
|
145
|
+
end
|
146
|
+
|
147
|
+
def header_content
|
148
|
+
@header_content
|
149
|
+
end
|
132
150
|
|
133
151
|
#============ RENDERING ===============================
|
134
152
|
|
@@ -144,6 +162,7 @@ module Caracal
|
|
144
162
|
render_custom(zip)
|
145
163
|
render_fonts(zip)
|
146
164
|
render_footer(zip)
|
165
|
+
render_header(zip)
|
147
166
|
render_settings(zip)
|
148
167
|
render_styles(zip)
|
149
168
|
render_document(zip)
|
@@ -219,6 +238,13 @@ module Caracal
|
|
219
238
|
zip.write(content)
|
220
239
|
end
|
221
240
|
|
241
|
+
def render_header(zip)
|
242
|
+
content = ::Caracal::Renderers::HeaderRenderer.render(self)
|
243
|
+
|
244
|
+
zip.put_next_entry('word/header1.xml')
|
245
|
+
zip.write(content)
|
246
|
+
end
|
247
|
+
|
222
248
|
def render_media(zip)
|
223
249
|
images = relationships.select { |r| r.relationship_type == :image }
|
224
250
|
images.each do |rel|
|
@@ -28,6 +28,7 @@ module Caracal
|
|
28
28
|
xml.send 'Override', { 'PartName' => '/docProps/custom.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.custom-properties+xml' }
|
29
29
|
xml.send 'Override', { 'PartName' => '/word/document.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml' }
|
30
30
|
xml.send 'Override', { 'PartName' => '/word/footer1.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml' }
|
31
|
+
xml.send 'Override', { 'PartName' => '/word/header1.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml' }
|
31
32
|
xml.send 'Override', { 'PartName' => '/word/fontTable.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml' }
|
32
33
|
xml.send 'Override', { 'PartName' => '/word/numbering.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml' }
|
33
34
|
xml.send 'Override', { 'PartName' => '/word/settings.xml', 'ContentType' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml' }
|
@@ -31,10 +31,11 @@ module Caracal
|
|
31
31
|
#============= PAGE SETTINGS ==============================
|
32
32
|
|
33
33
|
xml['w'].sectPr do
|
34
|
-
if document.
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
if rel = document.find_relationship('footer1.xml')
|
35
|
+
xml['w'].footerReference({ 'r:id' => rel.formatted_id, 'w:type' => 'default' })
|
36
|
+
end
|
37
|
+
if rel = document.find_relationship('header1.xml')
|
38
|
+
xml['w'].headerReference({ 'r:id' => rel.formatted_id, 'w:type' => 'default' })
|
38
39
|
end
|
39
40
|
xml['w'].pgSz page_size_options
|
40
41
|
xml['w'].pgMar page_margin_options
|
@@ -219,6 +220,79 @@ module Caracal
|
|
219
220
|
end
|
220
221
|
end
|
221
222
|
|
223
|
+
def render_tableofcontents(xml, model)
|
224
|
+
xml['w'].sdt do
|
225
|
+
xml['w'].sdtPr do
|
226
|
+
xml['w'].docPartObj do
|
227
|
+
xml['w'].docPartGallery({ 'w:val' => model.toc_title })
|
228
|
+
xml['w'].docPartUnique({ 'w:val' => true })
|
229
|
+
end
|
230
|
+
end
|
231
|
+
xml['w'].sdtContent do
|
232
|
+
xml['w'].p do
|
233
|
+
xml['w'].pPr do
|
234
|
+
xml['w'].pStyle({ 'w:val' => 'ContentsHeading' })
|
235
|
+
xml['w'].rPr do
|
236
|
+
xml['w'].b
|
237
|
+
xml['w'].b
|
238
|
+
xml['w'].bCs
|
239
|
+
xml['w'].sz({ 'w:val' => model.toc_size })
|
240
|
+
xml['w'].szCs({ 'w:val' => model.toc_size })
|
241
|
+
end
|
242
|
+
end
|
243
|
+
xml['w'].r do
|
244
|
+
xml['w'].rPr do
|
245
|
+
xml['w'].b
|
246
|
+
xml['w'].bCs
|
247
|
+
xml['w'].sz({ 'w:val' => model.toc_size })
|
248
|
+
xml['w'].szCs({ 'w:val' => model.toc_size })
|
249
|
+
end
|
250
|
+
xml['w'].t model.toc_title
|
251
|
+
end
|
252
|
+
end
|
253
|
+
xml['w'].p do
|
254
|
+
xml['w'].r do
|
255
|
+
xml['w'].fldChar({ 'w:fldCharType' => 'begin' })
|
256
|
+
end
|
257
|
+
xml['w'].r do
|
258
|
+
xml['w'].rPr do
|
259
|
+
render_run_attributes(xml, model, false)
|
260
|
+
end
|
261
|
+
xml['w'].instrText({ 'xml:space' => 'preserve' }) do
|
262
|
+
xml.text " #{model.toc_opts} "
|
263
|
+
end
|
264
|
+
end
|
265
|
+
xml['w'].r do
|
266
|
+
xml['w'].fldChar({ 'w:fldCharType' => 'separate' })
|
267
|
+
end
|
268
|
+
xml['w'].r do
|
269
|
+
xml['w'].fldChar({ 'w:fldCharType' => 'end' })
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
276
|
+
def render_field(xml, model)
|
277
|
+
xml['w'].r do
|
278
|
+
xml['w'].fldChar({ 'w:fldCharType' => 'begin' })
|
279
|
+
end
|
280
|
+
xml['w'].r do
|
281
|
+
xml['w'].rPr do
|
282
|
+
render_run_attributes(xml, model, false)
|
283
|
+
end
|
284
|
+
xml['w'].instrText({ 'xml:space' => 'preserve' }) do
|
285
|
+
xml.text " #{model.formatted_type} "
|
286
|
+
end
|
287
|
+
end
|
288
|
+
xml['w'].r do
|
289
|
+
xml['w'].fldChar({ 'w:fldCharType' => 'separate' })
|
290
|
+
end
|
291
|
+
xml['w'].r do
|
292
|
+
xml['w'].fldChar({ 'w:fldCharType' => 'end' })
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
222
296
|
def render_list(xml, model)
|
223
297
|
if model.list_level == 0
|
224
298
|
document.toplevel_lists << model
|
@@ -253,6 +327,33 @@ module Caracal
|
|
253
327
|
end
|
254
328
|
end
|
255
329
|
|
330
|
+
def render_pageflip(xml, model)
|
331
|
+
xml['w'].p paragraph_options do
|
332
|
+
xml['w'].pPr do
|
333
|
+
xml['w'].sectPr do
|
334
|
+
xml['w'].pgSz({
|
335
|
+
'w:w' => document.page_width,
|
336
|
+
'w:h' => document.page_height
|
337
|
+
})
|
338
|
+
end
|
339
|
+
end
|
340
|
+
end
|
341
|
+
model.contents.each do |model|
|
342
|
+
method = render_method_for_model(model)
|
343
|
+
send(method, xml, model)
|
344
|
+
end
|
345
|
+
xml['w'].p paragraph_options do
|
346
|
+
xml['w'].pPr do
|
347
|
+
xml['w'].sectPr do
|
348
|
+
xml['w'].pgSz({
|
349
|
+
'w:w' => document.page_height,
|
350
|
+
'w:h' => document.page_width
|
351
|
+
})
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
256
357
|
def render_pagebreak(xml, model)
|
257
358
|
if model.page_break_wrap
|
258
359
|
xml['w'].p paragraph_options do
|
@@ -5,52 +5,65 @@ require 'caracal/renderers/xml_renderer'
|
|
5
5
|
|
6
6
|
module Caracal
|
7
7
|
module Renderers
|
8
|
-
class FooterRenderer <
|
8
|
+
class FooterRenderer < DocumentRenderer
|
9
9
|
|
10
10
|
#-------------------------------------------------------------
|
11
11
|
# Public Methods
|
12
12
|
#-------------------------------------------------------------
|
13
13
|
|
14
|
-
# This method produces the xml required for the `word/
|
14
|
+
# This method produces the xml required for the `word/footer1.xml`
|
15
15
|
# sub-document.
|
16
16
|
#
|
17
17
|
def to_xml
|
18
18
|
builder = ::Nokogiri::XML::Builder.with(declaration_xml) do |xml|
|
19
|
-
|
20
|
-
xml['w'].
|
21
|
-
xml['w'].
|
22
|
-
xml['w'].
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
if document.page_number_show
|
20
|
+
xml['w'].ftr root_options do
|
21
|
+
xml['w'].p paragraph_options do
|
22
|
+
xml['w'].pPr do
|
23
|
+
xml['w'].contextualSpacing({ 'w:val' => '0' })
|
24
|
+
xml['w'].jc({ 'w:val' => "#{ document.page_number_align }" })
|
25
|
+
end
|
26
|
+
unless document.page_number_label.nil?
|
27
|
+
xml['w'].r run_options do
|
28
|
+
xml['w'].rPr do
|
29
|
+
xml['w'].rStyle({ 'w:val' => 'PageNumber' })
|
30
|
+
unless document.page_number_label_size.nil?
|
31
|
+
xml['w'].sz({ 'w:val' => document.page_number_label_size })
|
32
|
+
end
|
33
|
+
end
|
34
|
+
xml['w'].t({ 'xml:space' => 'preserve' }) do
|
35
|
+
xml.text "#{ document.page_number_label } "
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
26
39
|
xml['w'].r run_options do
|
27
40
|
xml['w'].rPr do
|
28
|
-
|
29
|
-
|
30
|
-
xml['w'].
|
41
|
+
unless document.page_number_number_size.nil?
|
42
|
+
xml['w'].sz({ 'w:val' => document.page_number_number_size })
|
43
|
+
xml['w'].szCs({ 'w:val' => document.page_number_number_size })
|
31
44
|
end
|
32
45
|
end
|
33
|
-
xml['w'].
|
34
|
-
|
46
|
+
xml['w'].fldChar({ 'w:fldCharType' => 'begin' })
|
47
|
+
xml['w'].instrText({ 'xml:space' => 'preserve' }) do
|
48
|
+
xml.text 'PAGE'
|
35
49
|
end
|
50
|
+
xml['w'].fldChar({ 'w:fldCharType' => 'end' })
|
36
51
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
unless document.page_number_number_size.nil?
|
41
|
-
xml['w'].sz({ 'w:val' => document.page_number_number_size })
|
42
|
-
xml['w'].szCs({ 'w:val' => document.page_number_number_size })
|
52
|
+
xml['w'].r run_options do
|
53
|
+
xml['w'].rPr do
|
54
|
+
xml['w'].rtl({ 'w:val' => '0' })
|
43
55
|
end
|
44
56
|
end
|
45
|
-
xml['w'].fldChar({ 'w:fldCharType' => 'begin' })
|
46
|
-
xml['w'].instrText({ 'xml:space' => 'preserve' }) do
|
47
|
-
xml.text 'PAGE'
|
48
|
-
end
|
49
|
-
xml['w'].fldChar({ 'w:fldCharType' => 'end' })
|
50
57
|
end
|
51
|
-
|
52
|
-
|
53
|
-
|
58
|
+
end
|
59
|
+
else
|
60
|
+
xml['w'].ftr root_options do
|
61
|
+
|
62
|
+
#============= CONTENTS ===================================
|
63
|
+
if document.footer_content&.valid?
|
64
|
+
document.footer_content.contents.each do |model|
|
65
|
+
method = render_method_for_model(model)
|
66
|
+
send(method, xml, model)
|
54
67
|
end
|
55
68
|
end
|
56
69
|
end
|
@@ -87,4 +100,4 @@ module Caracal
|
|
87
100
|
|
88
101
|
end
|
89
102
|
end
|
90
|
-
end
|
103
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
require 'caracal/renderers/xml_renderer'
|
4
|
+
|
5
|
+
|
6
|
+
module Caracal
|
7
|
+
module Renderers
|
8
|
+
class HeaderRenderer < DocumentRenderer
|
9
|
+
|
10
|
+
#-------------------------------------------------------------
|
11
|
+
# Public Methods
|
12
|
+
#-------------------------------------------------------------
|
13
|
+
|
14
|
+
# This method produces the xml required for the `word/header1.xml`
|
15
|
+
# sub-document.
|
16
|
+
#
|
17
|
+
def to_xml
|
18
|
+
builder = ::Nokogiri::XML::Builder.with(declaration_xml) do |xml|
|
19
|
+
xml['w'].hdr root_options do
|
20
|
+
|
21
|
+
#============= CONTENTS ===================================
|
22
|
+
if document.header_content&.valid?
|
23
|
+
document.header_content.contents.each do |model|
|
24
|
+
method = render_method_for_model(model)
|
25
|
+
send(method, xml, model)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
builder.to_xml(save_options)
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
#-------------------------------------------------------------
|
35
|
+
# Private Methods
|
36
|
+
#-------------------------------------------------------------
|
37
|
+
private
|
38
|
+
|
39
|
+
def root_options
|
40
|
+
{
|
41
|
+
'xmlns:mc' => 'http://schemas.openxmlformats.org/markup-compatibility/2006',
|
42
|
+
'xmlns:o' => 'urn:schemas-microsoft-com:office:office',
|
43
|
+
'xmlns:r' => 'http://schemas.openxmlformats.org/officeDocument/2006/relationships',
|
44
|
+
'xmlns:m' => 'http://schemas.openxmlformats.org/officeDocument/2006/math',
|
45
|
+
'xmlns:v' => 'urn:schemas-microsoft-com:vml',
|
46
|
+
'xmlns:wp' => 'http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing',
|
47
|
+
'xmlns:w10' => 'urn:schemas-microsoft-com:office:word',
|
48
|
+
'xmlns:w' => 'http://schemas.openxmlformats.org/wordprocessingml/2006/main',
|
49
|
+
'xmlns:wne' => 'http://schemas.microsoft.com/office/word/2006/wordml',
|
50
|
+
'xmlns:sl' => 'http://schemas.openxmlformats.org/schemaLibrary/2006/main',
|
51
|
+
'xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main',
|
52
|
+
'xmlns:pic' => 'http://schemas.openxmlformats.org/drawingml/2006/picture',
|
53
|
+
'xmlns:c' => 'http://schemas.openxmlformats.org/drawingml/2006/chart',
|
54
|
+
'xmlns:lc' => 'http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas',
|
55
|
+
'xmlns:dgm' => 'http://schemas.openxmlformats.org/drawingml/2006/diagram'
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -22,6 +22,7 @@ module Caracal
|
|
22
22
|
xml['w'].compat do
|
23
23
|
xml['w'].compatSetting({ 'w:val' => '14', 'w:name' => 'compatibilityMode', 'w:uri' => 'http://schemas.microsoft.com/office/word' })
|
24
24
|
end
|
25
|
+
xml['w'].updateFields({ 'w:val' => true })
|
25
26
|
end
|
26
27
|
end
|
27
28
|
builder.to_xml(save_options)
|
@@ -55,4 +56,4 @@ module Caracal
|
|
55
56
|
|
56
57
|
end
|
57
58
|
end
|
58
|
-
end
|
59
|
+
end
|
@@ -31,6 +31,7 @@ module Caracal
|
|
31
31
|
xml['w'].b({ 'w:val' => (s.style_bold ? '1' : '0') })
|
32
32
|
xml['w'].i({ 'w:val' => (s.style_italic ? '1' : '0') })
|
33
33
|
xml['w'].caps({ 'w:val' => (s.style_caps ? '1' : '0') })
|
34
|
+
xml['w'].outlineLvl({ 'w:val' => s.style_outline })
|
34
35
|
xml['w'].smallCaps({ 'w:val' => '0' })
|
35
36
|
xml['w'].strike({ 'w:val' => '0' })
|
36
37
|
xml['w'].color({ 'w:val' => s.style_color })
|
@@ -75,6 +76,7 @@ module Caracal
|
|
75
76
|
xml['w'].widowControl({ 'w:val' => '1' })
|
76
77
|
xml['w'].spacing(spacing_options(s)) unless spacing_options(s).nil?
|
77
78
|
xml['w'].contextualSpacing({ 'w:val' => '1' })
|
79
|
+
xml['w'].outlineLvl({ 'w:val' => s.style_outline }) unless s.style_outline.nil?
|
78
80
|
xml['w'].jc({ 'w:val' => s.style_align.to_s }) unless s.style_align.nil?
|
79
81
|
xml['w'].ind(indentation_options(s)) unless indentation_options(s).nil?
|
80
82
|
end
|
data/lib/caracal/version.rb
CHANGED
data/lib/caracal.rb
CHANGED
@@ -38,3 +38,27 @@ Caracal::Core::Models::TableCellModel.class_eval do
|
|
38
38
|
include Caracal::Core::Tables
|
39
39
|
include Caracal::Core::Text
|
40
40
|
end
|
41
|
+
|
42
|
+
Caracal::Core::Models::PageFlipModel.class_eval do
|
43
|
+
include Caracal::Core::Images
|
44
|
+
include Caracal::Core::Lists
|
45
|
+
include Caracal::Core::Rules
|
46
|
+
include Caracal::Core::Tables
|
47
|
+
include Caracal::Core::Text
|
48
|
+
end
|
49
|
+
|
50
|
+
Caracal::Core::Models::FooterModel.class_eval do
|
51
|
+
include Caracal::Core::Images
|
52
|
+
include Caracal::Core::Lists
|
53
|
+
include Caracal::Core::Rules
|
54
|
+
include Caracal::Core::Tables
|
55
|
+
include Caracal::Core::Text
|
56
|
+
end
|
57
|
+
|
58
|
+
Caracal::Core::Models::HeaderModel.class_eval do
|
59
|
+
include Caracal::Core::Images
|
60
|
+
include Caracal::Core::Lists
|
61
|
+
include Caracal::Core::Rules
|
62
|
+
include Caracal::Core::Tables
|
63
|
+
include Caracal::Core::Text
|
64
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Caracal::Core::Fields do
|
4
|
+
subject { Caracal::Document.new }
|
5
|
+
|
6
|
+
|
7
|
+
#-------------------------------------------------------------
|
8
|
+
# Public Methods
|
9
|
+
#-------------------------------------------------------------
|
10
|
+
|
11
|
+
describe 'public method tests' do
|
12
|
+
|
13
|
+
# .table
|
14
|
+
describe '.field' do
|
15
|
+
let!(:size) { subject.contents.size }
|
16
|
+
|
17
|
+
before { subject.field :table_of_contents }
|
18
|
+
|
19
|
+
it { expect(subject.contents.size).to eq size + 1 }
|
20
|
+
it { expect(subject.contents.last).to be_a(Caracal::Core::Models::FieldModel) }
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Caracal::Core::Text do
|
4
|
+
subject { Caracal::Document.new }
|
5
|
+
|
6
|
+
#-------------------------------------------------------------
|
7
|
+
# Configuration
|
8
|
+
#-------------------------------------------------------------
|
9
|
+
|
10
|
+
describe 'configuration tests' do
|
11
|
+
|
12
|
+
# accessors
|
13
|
+
describe 'accessors' do
|
14
|
+
it { expect(subject.footer_content).to be_nil }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
#-------------------------------------------------------------
|
19
|
+
# Public Methods
|
20
|
+
#-------------------------------------------------------------
|
21
|
+
|
22
|
+
describe 'public method tests' do
|
23
|
+
|
24
|
+
describe '.footer' do
|
25
|
+
before { subject.footer }
|
26
|
+
|
27
|
+
it { expect(subject.footer_content).not_to be_nil }
|
28
|
+
it { expect(subject.footer_content).to be_a(Caracal::Core::Models::FooterModel) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Caracal::Core::Text do
|
4
|
+
subject { Caracal::Document.new }
|
5
|
+
|
6
|
+
#-------------------------------------------------------------
|
7
|
+
# Configuration
|
8
|
+
#-------------------------------------------------------------
|
9
|
+
|
10
|
+
describe 'configuration tests' do
|
11
|
+
|
12
|
+
# accessors
|
13
|
+
describe 'accessors' do
|
14
|
+
it { expect(subject.header_content).to be_nil }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
#-------------------------------------------------------------
|
19
|
+
# Public Methods
|
20
|
+
#-------------------------------------------------------------
|
21
|
+
|
22
|
+
describe 'public method tests' do
|
23
|
+
|
24
|
+
describe '.header' do
|
25
|
+
before { subject.header }
|
26
|
+
|
27
|
+
it { expect(subject.header_content).not_to be_nil }
|
28
|
+
it { expect(subject.header_content).to be_a(Caracal::Core::Models::HeaderModel) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Caracal::Core::Models::FooterModel do
|
4
|
+
subject do
|
5
|
+
described_class.new
|
6
|
+
end
|
7
|
+
|
8
|
+
#-------------------------------------------------------------
|
9
|
+
# Public Methods
|
10
|
+
#-------------------------------------------------------------
|
11
|
+
|
12
|
+
describe 'public method tests' do
|
13
|
+
|
14
|
+
#=============== DATA ACCESSORS ====================
|
15
|
+
|
16
|
+
describe 'data tests' do
|
17
|
+
|
18
|
+
# .contents
|
19
|
+
describe '.contents' do
|
20
|
+
it { expect(subject.contents).to be_a(Array) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
#=============== VALIDATION ========================
|
25
|
+
|
26
|
+
describe '.valid?' do
|
27
|
+
describe 'when content provided' do
|
28
|
+
before { allow(subject).to receive(:contents).and_return(['a']) }
|
29
|
+
|
30
|
+
it { expect(subject.valid?).to eq true }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'when content not provided' do
|
34
|
+
before { allow(subject).to receive(:contents).and_return([]) }
|
35
|
+
|
36
|
+
it { expect(subject.valid?).to eq false }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Caracal::Core::Models::HeaderModel do
|
4
|
+
subject do
|
5
|
+
described_class.new
|
6
|
+
end
|
7
|
+
|
8
|
+
#-------------------------------------------------------------
|
9
|
+
# Public Methods
|
10
|
+
#-------------------------------------------------------------
|
11
|
+
|
12
|
+
describe 'public method tests' do
|
13
|
+
|
14
|
+
#=============== DATA ACCESSORS ====================
|
15
|
+
|
16
|
+
describe 'data tests' do
|
17
|
+
|
18
|
+
# .contents
|
19
|
+
describe '.contents' do
|
20
|
+
it { expect(subject.contents).to be_a(Array) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
#=============== VALIDATION ========================
|
25
|
+
|
26
|
+
describe '.valid?' do
|
27
|
+
describe 'when content provided' do
|
28
|
+
before { allow(subject).to receive(:contents).and_return(['a']) }
|
29
|
+
|
30
|
+
it { expect(subject.valid?).to eq true }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'when content not provided' do
|
34
|
+
before { allow(subject).to receive(:contents).and_return([]) }
|
35
|
+
|
36
|
+
it { expect(subject.valid?).to eq false }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Caracal::Core::Models::PageFlipModel do
|
4
|
+
let(:name) { 'Arial' }
|
5
|
+
|
6
|
+
subject { described_class.new }
|
7
|
+
|
8
|
+
|
9
|
+
#-------------------------------------------------------------
|
10
|
+
# Configuration
|
11
|
+
#-------------------------------------------------------------
|
12
|
+
|
13
|
+
describe 'configuration tests' do
|
14
|
+
|
15
|
+
describe 'inheritance' do
|
16
|
+
it { expect(subject).to be_a(Caracal::Core::Models::BaseModel) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
#=============== VALIDATION ===========================
|
21
|
+
|
22
|
+
describe '.valid?' do
|
23
|
+
describe 'when content provided' do
|
24
|
+
before { allow(subject).to receive(:contents).and_return(['a']) }
|
25
|
+
|
26
|
+
it { expect(subject.valid?).to eq true }
|
27
|
+
end
|
28
|
+
describe 'when content not provided' do
|
29
|
+
before { allow(subject).to receive(:contents).and_return([]) }
|
30
|
+
|
31
|
+
it { expect(subject.valid?).to eq false }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|