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
@@ -137,6 +137,23 @@ describe Caracal::Core::Models::ParagraphModel do
|
|
137
137
|
it { expect(subject.runs.size).to eq length + 1 }
|
138
138
|
end
|
139
139
|
|
140
|
+
# .field
|
141
|
+
describe '.field' do
|
142
|
+
let!(:length) { subject.runs.length }
|
143
|
+
|
144
|
+
context ':page' do
|
145
|
+
before { subject.field :page }
|
146
|
+
|
147
|
+
it { expect(subject.runs.size).to eq length + 1 }
|
148
|
+
end
|
149
|
+
|
150
|
+
context ':numpages' do
|
151
|
+
before { subject.field :numpages }
|
152
|
+
|
153
|
+
it { expect(subject.runs.size).to eq length + 1 }
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
140
157
|
# .bookmark
|
141
158
|
describe '.bookmark_start' do
|
142
159
|
let!(:length) { subject.runs.length }
|
@@ -149,7 +166,7 @@ describe Caracal::Core::Models::ParagraphModel do
|
|
149
166
|
describe '.bookmark_end' do
|
150
167
|
let!(:length) { subject.runs.length }
|
151
168
|
|
152
|
-
before { subject.bookmark_end
|
169
|
+
before { subject.bookmark_end(id:'1')}
|
153
170
|
|
154
171
|
it { expect(subject.runs.size).to eq length + 1 }
|
155
172
|
end
|
@@ -32,6 +32,7 @@ describe Caracal::Core::Models::StyleModel do
|
|
32
32
|
it { expect(described_class::DEFAULT_STYLE_LINE).to eq 360 }
|
33
33
|
it { expect(described_class::DEFAULT_STYLE_BASE).to eq 'Normal' }
|
34
34
|
it { expect(described_class::DEFAULT_STYLE_NEXT).to eq 'Normal' }
|
35
|
+
it { expect(described_class::DEFAULT_STYLE_OUTLINE).to eq 9 }
|
35
36
|
end
|
36
37
|
|
37
38
|
# accessors
|
@@ -53,6 +54,7 @@ describe Caracal::Core::Models::StyleModel do
|
|
53
54
|
it { expect(subject.style_line).to eq 360 }
|
54
55
|
it { expect(subject.style_base).to eq 'Normal' }
|
55
56
|
it { expect(subject.style_next).to eq 'Normal' }
|
57
|
+
it { expect(subject.style_outline).to eq 9 }
|
56
58
|
end
|
57
59
|
|
58
60
|
end
|
@@ -146,6 +148,11 @@ describe Caracal::Core::Models::StyleModel do
|
|
146
148
|
|
147
149
|
it { expect(subject.style_font).to eq 'Helvetica' }
|
148
150
|
end
|
151
|
+
describe '.outline' do
|
152
|
+
before { subject.outline(3) }
|
153
|
+
|
154
|
+
it { expect(subject.style_outline).to eq "3" }
|
155
|
+
end
|
149
156
|
|
150
157
|
# symbols
|
151
158
|
describe '.align' do
|
@@ -215,7 +222,7 @@ describe Caracal::Core::Models::StyleModel do
|
|
215
222
|
# .option_keys
|
216
223
|
describe '.option_keys' do
|
217
224
|
let(:actual) { subject.send(:option_keys).sort }
|
218
|
-
let(:expected) { [:type, :bold, :italic, :underline, :caps, :top, :bottom, :size, :line, :id, :name, :color, :font, :align, :indent_left, :indent_right, :indent_first].sort }
|
225
|
+
let(:expected) { [:type, :bold, :italic, :underline, :caps, :top, :bottom, :size, :line, :id, :name, :color, :font, :align, :indent_left, :indent_right, :indent_first, :outline].sort }
|
219
226
|
|
220
227
|
it { expect(actual).to eq expected }
|
221
228
|
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Caracal::Core::Models::TableOfContentsModel do
|
4
|
+
subject do
|
5
|
+
described_class.new
|
6
|
+
end
|
7
|
+
|
8
|
+
|
9
|
+
#-------------------------------------------------------------
|
10
|
+
# Configuration
|
11
|
+
#-------------------------------------------------------------
|
12
|
+
|
13
|
+
describe 'configuration tests' do
|
14
|
+
|
15
|
+
# accessors
|
16
|
+
describe 'accessors' do
|
17
|
+
it { expect(subject.toc_opts).to eq 'TOC \o "1-1" \h \z \u \t "Heading 5,1"' }
|
18
|
+
it { expect(subject.toc_size).to eq 32 }
|
19
|
+
it { expect(subject.toc_title).to eq 'Table of Contents' }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
#-------------------------------------------------------------
|
25
|
+
# Public Methods
|
26
|
+
#-------------------------------------------------------------
|
27
|
+
|
28
|
+
describe 'public method tests' do
|
29
|
+
#=============== GETTERS ==========================
|
30
|
+
|
31
|
+
|
32
|
+
#=============== SETTERS ==========================
|
33
|
+
|
34
|
+
# integers
|
35
|
+
describe '.size' do
|
36
|
+
before { subject.size(24) }
|
37
|
+
|
38
|
+
it { expect(subject.toc_size).to eq 24 }
|
39
|
+
end
|
40
|
+
|
41
|
+
# strings
|
42
|
+
describe '.opts' do
|
43
|
+
before { subject.opts('TOC \o "1-1"') }
|
44
|
+
|
45
|
+
it { expect(subject.toc_opts).to eq 'TOC \o "1-1"' }
|
46
|
+
end
|
47
|
+
describe '.title' do
|
48
|
+
before { subject.title('Hello World') }
|
49
|
+
|
50
|
+
it { expect(subject.toc_title).to eq 'Hello World' }
|
51
|
+
end
|
52
|
+
|
53
|
+
#=============== VALIDATION ===========================
|
54
|
+
|
55
|
+
describe '.valid?' do
|
56
|
+
describe 'when name provided' do
|
57
|
+
it { expect(subject.valid?).to eq true }
|
58
|
+
end
|
59
|
+
[:opts, :size, :title].each do |prop|
|
60
|
+
describe "when #{ prop } nil" do
|
61
|
+
before do
|
62
|
+
allow(subject).to receive("font_#{ prop }").and_return(nil)
|
63
|
+
end
|
64
|
+
|
65
|
+
it { expect(subject.valid?).to eq true }
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
#-------------------------------------------------------------
|
74
|
+
# Private Methods
|
75
|
+
#-------------------------------------------------------------
|
76
|
+
|
77
|
+
describe 'private method tests' do
|
78
|
+
|
79
|
+
# .option_keys
|
80
|
+
describe '.option_keys' do
|
81
|
+
let(:actual) { subject.send(:option_keys).sort }
|
82
|
+
let(:expected) { [:opts, :size, :title].sort }
|
83
|
+
|
84
|
+
it { expect(actual).to eq expected }
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Caracal::Core::PageFlips do
|
4
|
+
subject { Caracal::Document.new }
|
5
|
+
|
6
|
+
|
7
|
+
#-------------------------------------------------------------
|
8
|
+
# Public Methods
|
9
|
+
#-------------------------------------------------------------
|
10
|
+
|
11
|
+
describe 'public method tests' do
|
12
|
+
|
13
|
+
# .page
|
14
|
+
describe '.page_flip' do
|
15
|
+
let!(:size) { subject.contents.size }
|
16
|
+
|
17
|
+
before do
|
18
|
+
subject.page_flip do |x|
|
19
|
+
x.p
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it { expect(subject.contents.size).to eq size + 1 }
|
24
|
+
it { expect(subject.contents.last).to be_a(Caracal::Core::Models::PageFlipModel) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -15,7 +15,7 @@ describe Caracal::Core::Relationships do
|
|
15
15
|
|
16
16
|
# .default_relationships
|
17
17
|
describe '.default_relationships' do
|
18
|
-
let(:expected) { [:font, :footer, :numbering, :setting, :style] }
|
18
|
+
let(:expected) { [:font, :footer, :header, :numbering, :setting, :style] }
|
19
19
|
let(:actual) { subject.class.default_relationships.map { |r| r[:type] } }
|
20
20
|
|
21
21
|
it { expect(actual).to eq expected }
|
@@ -105,7 +105,7 @@ describe Caracal::Core::Relationships do
|
|
105
105
|
it { expect(subject.relationships.size).to eq default_length }
|
106
106
|
end
|
107
107
|
describe 'when not registered' do
|
108
|
-
before do
|
108
|
+
before do
|
109
109
|
subject.register_relationship(m1)
|
110
110
|
subject.unregister_relationship(m2.relationship_target)
|
111
111
|
end
|
metadata
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caracal_the_curve
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trade Infomatics
|
8
8
|
- John Dugan
|
9
|
+
- James Ridgway
|
10
|
+
- Matthew Barber
|
9
11
|
autorequire:
|
10
12
|
bindir: bin
|
11
13
|
cert_chain: []
|
12
|
-
date:
|
14
|
+
date: 2024-02-07 00:00:00.000000000 Z
|
13
15
|
dependencies:
|
14
16
|
- !ruby/object:Gem::Dependency
|
15
17
|
name: nokogiri
|
@@ -105,6 +107,8 @@ description: " Caracal is a pure Ruby Microsoft Word generation library that pro
|
|
105
107
|
professional quality MSWord documents (docx) using a simple, HTML-style DSL. "
|
106
108
|
email:
|
107
109
|
- jpdugan@gmail.com
|
110
|
+
- james.ridgway@tccs.io
|
111
|
+
- matthew.barber@tccs.io
|
108
112
|
executables: []
|
109
113
|
extensions: []
|
110
114
|
extra_rdoc_files: []
|
@@ -122,8 +126,11 @@ files:
|
|
122
126
|
- lib/caracal.rb
|
123
127
|
- lib/caracal/core/bookmarks.rb
|
124
128
|
- lib/caracal/core/custom_properties.rb
|
129
|
+
- lib/caracal/core/fields.rb
|
125
130
|
- lib/caracal/core/file_name.rb
|
126
131
|
- lib/caracal/core/fonts.rb
|
132
|
+
- lib/caracal/core/footer.rb
|
133
|
+
- lib/caracal/core/header.rb
|
127
134
|
- lib/caracal/core/iframes.rb
|
128
135
|
- lib/caracal/core/ignorables.rb
|
129
136
|
- lib/caracal/core/images.rb
|
@@ -133,7 +140,10 @@ files:
|
|
133
140
|
- lib/caracal/core/models/bookmark_model.rb
|
134
141
|
- lib/caracal/core/models/border_model.rb
|
135
142
|
- lib/caracal/core/models/custom_property_model.rb
|
143
|
+
- lib/caracal/core/models/field_model.rb
|
136
144
|
- lib/caracal/core/models/font_model.rb
|
145
|
+
- lib/caracal/core/models/footer_model.rb
|
146
|
+
- lib/caracal/core/models/header_model.rb
|
137
147
|
- lib/caracal/core/models/iframe_model.rb
|
138
148
|
- lib/caracal/core/models/image_model.rb
|
139
149
|
- lib/caracal/core/models/line_break_model.rb
|
@@ -144,6 +154,7 @@ files:
|
|
144
154
|
- lib/caracal/core/models/margin_model.rb
|
145
155
|
- lib/caracal/core/models/namespace_model.rb
|
146
156
|
- lib/caracal/core/models/page_break_model.rb
|
157
|
+
- lib/caracal/core/models/page_flip_model.rb
|
147
158
|
- lib/caracal/core/models/page_number_model.rb
|
148
159
|
- lib/caracal/core/models/page_size_model.rb
|
149
160
|
- lib/caracal/core/models/paragraph_model.rb
|
@@ -152,14 +163,17 @@ files:
|
|
152
163
|
- lib/caracal/core/models/style_model.rb
|
153
164
|
- lib/caracal/core/models/table_cell_model.rb
|
154
165
|
- lib/caracal/core/models/table_model.rb
|
166
|
+
- lib/caracal/core/models/table_of_contents_model.rb
|
155
167
|
- lib/caracal/core/models/text_model.rb
|
156
168
|
- lib/caracal/core/namespaces.rb
|
157
169
|
- lib/caracal/core/page_breaks.rb
|
170
|
+
- lib/caracal/core/page_flips.rb
|
158
171
|
- lib/caracal/core/page_numbers.rb
|
159
172
|
- lib/caracal/core/page_settings.rb
|
160
173
|
- lib/caracal/core/relationships.rb
|
161
174
|
- lib/caracal/core/rules.rb
|
162
175
|
- lib/caracal/core/styles.rb
|
176
|
+
- lib/caracal/core/table_of_contents.rb
|
163
177
|
- lib/caracal/core/tables.rb
|
164
178
|
- lib/caracal/core/text.rb
|
165
179
|
- lib/caracal/document.rb
|
@@ -171,6 +185,7 @@ files:
|
|
171
185
|
- lib/caracal/renderers/document_renderer.rb
|
172
186
|
- lib/caracal/renderers/fonts_renderer.rb
|
173
187
|
- lib/caracal/renderers/footer_renderer.rb
|
188
|
+
- lib/caracal/renderers/header_renderer.rb
|
174
189
|
- lib/caracal/renderers/numbering_renderer.rb
|
175
190
|
- lib/caracal/renderers/package_relationships_renderer.rb
|
176
191
|
- lib/caracal/renderers/relationships_renderer.rb
|
@@ -181,8 +196,11 @@ files:
|
|
181
196
|
- lib/caracal/version.rb
|
182
197
|
- lib/tilt/caracal.rb
|
183
198
|
- spec/lib/caracal/core/bookmarks_spec.rb
|
199
|
+
- spec/lib/caracal/core/fields_spec.rb
|
184
200
|
- spec/lib/caracal/core/file_name_spec.rb
|
185
201
|
- spec/lib/caracal/core/fonts_spec.rb
|
202
|
+
- spec/lib/caracal/core/footer_spec.rb
|
203
|
+
- spec/lib/caracal/core/header_spec.rb
|
186
204
|
- spec/lib/caracal/core/iframes_spec.rb
|
187
205
|
- spec/lib/caracal/core/ignorables_spec.rb
|
188
206
|
- spec/lib/caracal/core/images_spec.rb
|
@@ -192,6 +210,8 @@ files:
|
|
192
210
|
- spec/lib/caracal/core/models/bookmark_model_spec.rb
|
193
211
|
- spec/lib/caracal/core/models/border_model_spec.rb
|
194
212
|
- spec/lib/caracal/core/models/font_model_spec.rb
|
213
|
+
- spec/lib/caracal/core/models/footer_model_spec.rb
|
214
|
+
- spec/lib/caracal/core/models/header_model_spec.rb
|
195
215
|
- spec/lib/caracal/core/models/iframe_model_spec.rb
|
196
216
|
- spec/lib/caracal/core/models/image_model_spec.rb
|
197
217
|
- spec/lib/caracal/core/models/line_break_model_spec.rb
|
@@ -202,6 +222,7 @@ files:
|
|
202
222
|
- spec/lib/caracal/core/models/margin_model_spec.rb
|
203
223
|
- spec/lib/caracal/core/models/namespace_model_spec.rb
|
204
224
|
- spec/lib/caracal/core/models/page_break_model_spec.rb
|
225
|
+
- spec/lib/caracal/core/models/page_flip_model_spec.rb
|
205
226
|
- spec/lib/caracal/core/models/page_number_model_spec.rb
|
206
227
|
- spec/lib/caracal/core/models/page_size_model_spec.rb
|
207
228
|
- spec/lib/caracal/core/models/paragraph_model_spec.rb
|
@@ -210,9 +231,11 @@ files:
|
|
210
231
|
- spec/lib/caracal/core/models/style_model_spec.rb
|
211
232
|
- spec/lib/caracal/core/models/table_cell_model_spec.rb
|
212
233
|
- spec/lib/caracal/core/models/table_model_spec.rb
|
234
|
+
- spec/lib/caracal/core/models/table_of_contents_model_spec.rb
|
213
235
|
- spec/lib/caracal/core/models/text_model_spec.rb
|
214
236
|
- spec/lib/caracal/core/namespaces_spec.rb
|
215
237
|
- spec/lib/caracal/core/page_breaks_spec.rb
|
238
|
+
- spec/lib/caracal/core/page_flip_spec.rb
|
216
239
|
- spec/lib/caracal/core/page_numbers_spec.rb
|
217
240
|
- spec/lib/caracal/core/page_settings_spec.rb
|
218
241
|
- spec/lib/caracal/core/relationships_spec.rb
|
@@ -242,14 +265,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
242
265
|
- !ruby/object:Gem::Version
|
243
266
|
version: '0'
|
244
267
|
requirements: []
|
245
|
-
rubygems_version: 3.4.
|
268
|
+
rubygems_version: 3.4.19
|
246
269
|
signing_key:
|
247
270
|
specification_version: 4
|
248
271
|
summary: Fast, professional Microsoft Word (docx) writer for Ruby.
|
249
272
|
test_files:
|
250
273
|
- spec/lib/caracal/core/bookmarks_spec.rb
|
274
|
+
- spec/lib/caracal/core/fields_spec.rb
|
251
275
|
- spec/lib/caracal/core/file_name_spec.rb
|
252
276
|
- spec/lib/caracal/core/fonts_spec.rb
|
277
|
+
- spec/lib/caracal/core/footer_spec.rb
|
278
|
+
- spec/lib/caracal/core/header_spec.rb
|
253
279
|
- spec/lib/caracal/core/iframes_spec.rb
|
254
280
|
- spec/lib/caracal/core/ignorables_spec.rb
|
255
281
|
- spec/lib/caracal/core/images_spec.rb
|
@@ -259,6 +285,8 @@ test_files:
|
|
259
285
|
- spec/lib/caracal/core/models/bookmark_model_spec.rb
|
260
286
|
- spec/lib/caracal/core/models/border_model_spec.rb
|
261
287
|
- spec/lib/caracal/core/models/font_model_spec.rb
|
288
|
+
- spec/lib/caracal/core/models/footer_model_spec.rb
|
289
|
+
- spec/lib/caracal/core/models/header_model_spec.rb
|
262
290
|
- spec/lib/caracal/core/models/iframe_model_spec.rb
|
263
291
|
- spec/lib/caracal/core/models/image_model_spec.rb
|
264
292
|
- spec/lib/caracal/core/models/line_break_model_spec.rb
|
@@ -269,6 +297,7 @@ test_files:
|
|
269
297
|
- spec/lib/caracal/core/models/margin_model_spec.rb
|
270
298
|
- spec/lib/caracal/core/models/namespace_model_spec.rb
|
271
299
|
- spec/lib/caracal/core/models/page_break_model_spec.rb
|
300
|
+
- spec/lib/caracal/core/models/page_flip_model_spec.rb
|
272
301
|
- spec/lib/caracal/core/models/page_number_model_spec.rb
|
273
302
|
- spec/lib/caracal/core/models/page_size_model_spec.rb
|
274
303
|
- spec/lib/caracal/core/models/paragraph_model_spec.rb
|
@@ -277,9 +306,11 @@ test_files:
|
|
277
306
|
- spec/lib/caracal/core/models/style_model_spec.rb
|
278
307
|
- spec/lib/caracal/core/models/table_cell_model_spec.rb
|
279
308
|
- spec/lib/caracal/core/models/table_model_spec.rb
|
309
|
+
- spec/lib/caracal/core/models/table_of_contents_model_spec.rb
|
280
310
|
- spec/lib/caracal/core/models/text_model_spec.rb
|
281
311
|
- spec/lib/caracal/core/namespaces_spec.rb
|
282
312
|
- spec/lib/caracal/core/page_breaks_spec.rb
|
313
|
+
- spec/lib/caracal/core/page_flip_spec.rb
|
283
314
|
- spec/lib/caracal/core/page_numbers_spec.rb
|
284
315
|
- spec/lib/caracal/core/page_settings_spec.rb
|
285
316
|
- spec/lib/caracal/core/relationships_spec.rb
|