caracal 1.0.1 → 1.2.0

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.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +95 -5
  4. data/README.md +171 -35
  5. data/caracal.gemspec +4 -4
  6. data/lib/caracal/core/custom_properties.rb +49 -0
  7. data/lib/caracal/core/iframes.rb +42 -0
  8. data/lib/caracal/core/ignorables.rb +47 -0
  9. data/lib/caracal/core/models/custom_property_model.rb +60 -0
  10. data/lib/caracal/core/models/iframe_model.rb +148 -0
  11. data/lib/caracal/core/models/namespace_model.rb +65 -0
  12. data/lib/caracal/core/models/page_break_model.rb +50 -4
  13. data/lib/caracal/core/models/page_number_model.rb +50 -24
  14. data/lib/caracal/core/models/page_size_model.rb +34 -25
  15. data/lib/caracal/core/models/paragraph_model.rb +11 -4
  16. data/lib/caracal/core/models/style_model.rb +44 -15
  17. data/lib/caracal/core/models/table_cell_model.rb +61 -50
  18. data/lib/caracal/core/models/table_model.rb +1 -1
  19. data/lib/caracal/core/models/text_model.rb +42 -20
  20. data/lib/caracal/core/namespaces.rb +89 -0
  21. data/lib/caracal/core/page_numbers.rb +22 -16
  22. data/lib/caracal/core/page_settings.rb +18 -16
  23. data/lib/caracal/document.rb +75 -58
  24. data/lib/caracal/renderers/content_types_renderer.rb +18 -17
  25. data/lib/caracal/renderers/core_renderer.rb +1 -1
  26. data/lib/caracal/renderers/custom_renderer.rb +64 -0
  27. data/lib/caracal/renderers/document_renderer.rb +205 -118
  28. data/lib/caracal/renderers/fonts_renderer.rb +2 -2
  29. data/lib/caracal/renderers/footer_renderer.rb +41 -20
  30. data/lib/caracal/renderers/numbering_renderer.rb +27 -26
  31. data/lib/caracal/renderers/package_relationships_renderer.rb +14 -13
  32. data/lib/caracal/renderers/settings_renderer.rb +5 -5
  33. data/lib/caracal/renderers/styles_renderer.rb +88 -73
  34. data/lib/caracal/renderers/xml_renderer.rb +20 -20
  35. data/lib/caracal/version.rb +1 -1
  36. data/lib/caracal.rb +11 -2
  37. data/spec/lib/caracal/core/iframes_spec.rb +29 -0
  38. data/spec/lib/caracal/core/ignorables_spec.rb +79 -0
  39. data/spec/lib/caracal/core/models/iframe_model_spec.rb +83 -0
  40. data/spec/lib/caracal/core/models/image_model_spec.rb +60 -62
  41. data/spec/lib/caracal/core/models/link_model_spec.rb +12 -11
  42. data/spec/lib/caracal/core/models/namespace_model_spec.rb +107 -0
  43. data/spec/lib/caracal/core/models/page_number_model_spec.rb +66 -31
  44. data/spec/lib/caracal/core/models/page_size_model_spec.rb +42 -32
  45. data/spec/lib/caracal/core/models/style_model_spec.rb +32 -1
  46. data/spec/lib/caracal/core/models/table_cell_model_spec.rb +10 -1
  47. data/spec/lib/caracal/core/models/text_model_spec.rb +18 -10
  48. data/spec/lib/caracal/core/namespaces_spec.rb +116 -0
  49. data/spec/lib/caracal/core/page_numbers_spec.rb +32 -23
  50. data/spec/lib/caracal/core/page_settings_spec.rb +33 -25
  51. data/spec/lib/caracal/core/relationships_spec.rb +47 -47
  52. data/spec/support/_fixtures/snippet.docx +0 -0
  53. metadata +28 -8
@@ -1,37 +1,37 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Caracal::Core::Relationships do
4
- let(:r1) { Caracal::Core::Models::RelationshipModel.new({ target: 'footer.xml', type: :footer }) }
5
- let(:r2) { Caracal::Core::Models::RelationshipModel.new({ target: 'setting.xml', type: :setting }) }
6
-
4
+ let(:m1) { Caracal::Core::Models::RelationshipModel.new({ target: 'footer.xml', type: :footer }) }
5
+ let(:m2) { Caracal::Core::Models::RelationshipModel.new({ target: 'setting.xml', type: :setting }) }
6
+
7
7
  subject { Caracal::Document.new }
8
-
9
-
8
+
9
+
10
10
  #-------------------------------------------------------------
11
11
  # Class Methods
12
12
  #-------------------------------------------------------------
13
13
 
14
14
  describe 'public class tests' do
15
-
15
+
16
16
  # .default_relationships
17
17
  describe '.default_relationships' do
18
18
  let(:expected) { [:font, :footer, :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 }
22
22
  end
23
-
23
+
24
24
  end
25
-
26
-
25
+
26
+
27
27
  #-------------------------------------------------------------
28
28
  # Public Methods
29
29
  #-------------------------------------------------------------
30
30
 
31
31
  describe 'public method tests' do
32
-
32
+
33
33
  #============== ATTRIBUTES =====================
34
-
34
+
35
35
  # .relationship
36
36
  describe '.relationship' do
37
37
  it 'delegates to registration method' do
@@ -39,81 +39,81 @@ describe Caracal::Core::Relationships do
39
39
  subject.relationship({ target: 'new.gif', type: :image })
40
40
  end
41
41
  end
42
-
43
-
42
+
43
+
44
44
  #============== GETTERS ========================
45
-
45
+
46
46
  # .relationships
47
47
  describe '.relationships' do
48
48
  it { expect(subject.relationships).to be_a(Array) }
49
49
  end
50
-
50
+
51
51
  # .find_relationship
52
52
  describe '.find_relationship' do
53
53
  let(:actual) { subject.find_relationship(key) }
54
-
54
+
55
55
  before do
56
- allow(subject).to receive(:relationships).and_return([r1])
56
+ allow(subject).to receive(:relationships).and_return([m1])
57
57
  end
58
-
58
+
59
59
  describe 'when key is registered' do
60
- let(:key) { r1.relationship_key }
61
-
62
- it { expect(actual).to eq r1 }
60
+ let(:key) { m1.relationship_key }
61
+
62
+ it { expect(actual).to eq m1 }
63
63
  end
64
64
  describe 'when key is not registered' do
65
- let(:key) { r2.relationship_key }
66
-
65
+ let(:key) { m2.relationship_key }
66
+
67
67
  it { expect(actual).to eq nil }
68
68
  end
69
69
  end
70
-
71
-
70
+
71
+
72
72
  #============== REGISTRATION ========================
73
-
73
+
74
74
  # .register_relationship
75
75
  describe '.register_relationship' do
76
76
  let(:default_length) { subject.class.default_relationships.size }
77
-
77
+
78
78
  describe 'when not already registered' do
79
- before do
80
- subject.register_relationship(r1)
79
+ before do
80
+ subject.register_relationship(m1)
81
81
  end
82
-
82
+
83
83
  it { expect(subject.relationships.size).to eq default_length + 1 }
84
84
  end
85
85
  describe 'when already registered' do
86
- before do
87
- subject.register_relationship(r1)
88
- subject.register_relationship(r1)
86
+ before do
87
+ subject.register_relationship(m1)
88
+ subject.register_relationship(m1)
89
89
  end
90
-
90
+
91
91
  it { expect(subject.relationships.size).to eq default_length + 1 }
92
92
  end
93
93
  end
94
-
94
+
95
95
  # .unregister_relationship
96
96
  describe '.unregister_relationship' do
97
97
  let(:default_length) { subject.class.default_relationships.size }
98
-
98
+
99
99
  describe 'when registered' do
100
- before do
101
- subject.register_relationship(r1)
102
- subject.unregister_relationship(r1.relationship_target)
100
+ before do
101
+ subject.register_relationship(m1)
102
+ subject.unregister_relationship(m1.relationship_target)
103
103
  end
104
-
104
+
105
105
  it { expect(subject.relationships.size).to eq default_length }
106
106
  end
107
107
  describe 'when not registered' do
108
108
  before do
109
- subject.register_relationship(r1)
110
- subject.unregister_relationship(r2.relationship_target)
109
+ subject.register_relationship(m1)
110
+ subject.unregister_relationship(m2.relationship_target)
111
111
  end
112
-
112
+
113
113
  it { expect(subject.relationships.size).to eq default_length + 1 }
114
114
  end
115
115
  end
116
-
116
+
117
117
  end
118
-
119
- end
118
+
119
+ end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caracal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trade Infomatics
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-29 00:00:00.000000000 Z
12
+ date: 2018-05-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -43,14 +43,14 @@ dependencies:
43
43
  name: tilt
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '1.4'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '1.4'
56
56
  - !ruby/object:Gem::Dependency
@@ -95,8 +95,8 @@ dependencies:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
97
  version: '3.0'
98
- description: " Caracal is a pure Ruby MSWord generation library that produces professional
99
- quality Word documents using a simple, HTML-style DSL. "
98
+ description: " Caracal is a pure Ruby Microsoft Word generation library that produces
99
+ professional quality MSWord documents (docx) using a simple, HTML-style DSL. "
100
100
  email:
101
101
  - jpdugan@gmail.com
102
102
  executables: []
@@ -112,14 +112,19 @@ files:
112
112
  - Rakefile
113
113
  - caracal.gemspec
114
114
  - lib/caracal.rb
115
+ - lib/caracal/core/custom_properties.rb
115
116
  - lib/caracal/core/file_name.rb
116
117
  - lib/caracal/core/fonts.rb
118
+ - lib/caracal/core/iframes.rb
119
+ - lib/caracal/core/ignorables.rb
117
120
  - lib/caracal/core/images.rb
118
121
  - lib/caracal/core/list_styles.rb
119
122
  - lib/caracal/core/lists.rb
120
123
  - lib/caracal/core/models/base_model.rb
121
124
  - lib/caracal/core/models/border_model.rb
125
+ - lib/caracal/core/models/custom_property_model.rb
122
126
  - lib/caracal/core/models/font_model.rb
127
+ - lib/caracal/core/models/iframe_model.rb
123
128
  - lib/caracal/core/models/image_model.rb
124
129
  - lib/caracal/core/models/line_break_model.rb
125
130
  - lib/caracal/core/models/link_model.rb
@@ -127,6 +132,7 @@ files:
127
132
  - lib/caracal/core/models/list_model.rb
128
133
  - lib/caracal/core/models/list_style_model.rb
129
134
  - lib/caracal/core/models/margin_model.rb
135
+ - lib/caracal/core/models/namespace_model.rb
130
136
  - lib/caracal/core/models/page_break_model.rb
131
137
  - lib/caracal/core/models/page_number_model.rb
132
138
  - lib/caracal/core/models/page_size_model.rb
@@ -137,6 +143,7 @@ files:
137
143
  - lib/caracal/core/models/table_cell_model.rb
138
144
  - lib/caracal/core/models/table_model.rb
139
145
  - lib/caracal/core/models/text_model.rb
146
+ - lib/caracal/core/namespaces.rb
140
147
  - lib/caracal/core/page_breaks.rb
141
148
  - lib/caracal/core/page_numbers.rb
142
149
  - lib/caracal/core/page_settings.rb
@@ -150,6 +157,7 @@ files:
150
157
  - lib/caracal/renderers/app_renderer.rb
151
158
  - lib/caracal/renderers/content_types_renderer.rb
152
159
  - lib/caracal/renderers/core_renderer.rb
160
+ - lib/caracal/renderers/custom_renderer.rb
153
161
  - lib/caracal/renderers/document_renderer.rb
154
162
  - lib/caracal/renderers/fonts_renderer.rb
155
163
  - lib/caracal/renderers/footer_renderer.rb
@@ -164,12 +172,15 @@ files:
164
172
  - lib/tilt/caracal.rb
165
173
  - spec/lib/caracal/core/file_name_spec.rb
166
174
  - spec/lib/caracal/core/fonts_spec.rb
175
+ - spec/lib/caracal/core/iframes_spec.rb
176
+ - spec/lib/caracal/core/ignorables_spec.rb
167
177
  - spec/lib/caracal/core/images_spec.rb
168
178
  - spec/lib/caracal/core/list_styles_spec.rb
169
179
  - spec/lib/caracal/core/lists_spec.rb
170
180
  - spec/lib/caracal/core/models/base_model_spec.rb
171
181
  - spec/lib/caracal/core/models/border_model_spec.rb
172
182
  - spec/lib/caracal/core/models/font_model_spec.rb
183
+ - spec/lib/caracal/core/models/iframe_model_spec.rb
173
184
  - spec/lib/caracal/core/models/image_model_spec.rb
174
185
  - spec/lib/caracal/core/models/line_break_model_spec.rb
175
186
  - spec/lib/caracal/core/models/link_model_spec.rb
@@ -177,6 +188,7 @@ files:
177
188
  - spec/lib/caracal/core/models/list_model_spec.rb
178
189
  - spec/lib/caracal/core/models/list_style_model_spec.rb
179
190
  - spec/lib/caracal/core/models/margin_model_spec.rb
191
+ - spec/lib/caracal/core/models/namespace_model_spec.rb
180
192
  - spec/lib/caracal/core/models/page_break_model_spec.rb
181
193
  - spec/lib/caracal/core/models/page_number_model_spec.rb
182
194
  - spec/lib/caracal/core/models/page_size_model_spec.rb
@@ -187,6 +199,7 @@ files:
187
199
  - spec/lib/caracal/core/models/table_cell_model_spec.rb
188
200
  - spec/lib/caracal/core/models/table_model_spec.rb
189
201
  - spec/lib/caracal/core/models/text_model_spec.rb
202
+ - spec/lib/caracal/core/namespaces_spec.rb
190
203
  - spec/lib/caracal/core/page_breaks_spec.rb
191
204
  - spec/lib/caracal/core/page_numbers_spec.rb
192
205
  - spec/lib/caracal/core/page_settings_spec.rb
@@ -197,6 +210,7 @@ files:
197
210
  - spec/lib/caracal/core/text_spec.rb
198
211
  - spec/lib/caracal/errors_spec.rb
199
212
  - spec/spec_helper.rb
213
+ - spec/support/_fixtures/snippet.docx
200
214
  homepage: https://github.com/trade-informatics/caracal
201
215
  licenses:
202
216
  - MIT
@@ -217,19 +231,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
231
  version: '0'
218
232
  requirements: []
219
233
  rubyforge_project:
220
- rubygems_version: 2.4.8
234
+ rubygems_version: 2.7.6
221
235
  signing_key:
222
236
  specification_version: 4
223
- summary: Fast, professional MSWord writer for Ruby.
237
+ summary: Fast, professional Microsoft Word (docx) writer for Ruby.
224
238
  test_files:
225
239
  - spec/lib/caracal/core/file_name_spec.rb
226
240
  - spec/lib/caracal/core/fonts_spec.rb
241
+ - spec/lib/caracal/core/iframes_spec.rb
242
+ - spec/lib/caracal/core/ignorables_spec.rb
227
243
  - spec/lib/caracal/core/images_spec.rb
228
244
  - spec/lib/caracal/core/list_styles_spec.rb
229
245
  - spec/lib/caracal/core/lists_spec.rb
230
246
  - spec/lib/caracal/core/models/base_model_spec.rb
231
247
  - spec/lib/caracal/core/models/border_model_spec.rb
232
248
  - spec/lib/caracal/core/models/font_model_spec.rb
249
+ - spec/lib/caracal/core/models/iframe_model_spec.rb
233
250
  - spec/lib/caracal/core/models/image_model_spec.rb
234
251
  - spec/lib/caracal/core/models/line_break_model_spec.rb
235
252
  - spec/lib/caracal/core/models/link_model_spec.rb
@@ -237,6 +254,7 @@ test_files:
237
254
  - spec/lib/caracal/core/models/list_model_spec.rb
238
255
  - spec/lib/caracal/core/models/list_style_model_spec.rb
239
256
  - spec/lib/caracal/core/models/margin_model_spec.rb
257
+ - spec/lib/caracal/core/models/namespace_model_spec.rb
240
258
  - spec/lib/caracal/core/models/page_break_model_spec.rb
241
259
  - spec/lib/caracal/core/models/page_number_model_spec.rb
242
260
  - spec/lib/caracal/core/models/page_size_model_spec.rb
@@ -247,6 +265,7 @@ test_files:
247
265
  - spec/lib/caracal/core/models/table_cell_model_spec.rb
248
266
  - spec/lib/caracal/core/models/table_model_spec.rb
249
267
  - spec/lib/caracal/core/models/text_model_spec.rb
268
+ - spec/lib/caracal/core/namespaces_spec.rb
250
269
  - spec/lib/caracal/core/page_breaks_spec.rb
251
270
  - spec/lib/caracal/core/page_numbers_spec.rb
252
271
  - spec/lib/caracal/core/page_settings_spec.rb
@@ -257,3 +276,4 @@ test_files:
257
276
  - spec/lib/caracal/core/text_spec.rb
258
277
  - spec/lib/caracal/errors_spec.rb
259
278
  - spec/spec_helper.rb
279
+ - spec/support/_fixtures/snippet.docx