caracal 1.0.9 → 1.0.10

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.
@@ -0,0 +1,107 @@
1
+ require 'spec_helper'
2
+
3
+ describe Caracal::Core::Models::NamespaceModel do
4
+ subject do
5
+ described_class.new do
6
+ prefix 'com'
7
+ href 'http://www.example.com'
8
+ end
9
+ end
10
+
11
+
12
+ #-------------------------------------------------------------
13
+ # Configuration
14
+ #-------------------------------------------------------------
15
+
16
+ describe 'configuration tests' do
17
+
18
+ # accessors
19
+ describe 'accessors' do
20
+ it { expect(subject.namespace_prefix).to eq 'com' }
21
+ it { expect(subject.namespace_href).to eq 'http://www.example.com' }
22
+ end
23
+
24
+ end
25
+
26
+
27
+ #-------------------------------------------------------------
28
+ # Public Methods
29
+ #-------------------------------------------------------------
30
+
31
+ describe 'public method tests' do
32
+
33
+ #=================== ATTRIBUTES ==========================
34
+
35
+ # .prefix
36
+ describe '.prefix' do
37
+ before do
38
+ subject.prefix('org')
39
+ end
40
+
41
+ it { expect(subject.namespace_prefix).to eq 'org' }
42
+ end
43
+
44
+ # .href
45
+ describe '.href' do
46
+ before do
47
+ subject.href('http://www.example.org')
48
+ end
49
+
50
+ it { expect(subject.namespace_href).to eq 'http://www.example.org' }
51
+ end
52
+
53
+
54
+ #=================== STATE ===============================
55
+
56
+ # .matches?
57
+ describe '.matches?' do
58
+ describe 'when search term matches key' do
59
+ let(:actual) { subject.matches?('com') }
60
+
61
+ it { expect(actual).to eq true }
62
+ end
63
+ describe 'when search term does not match key' do
64
+ let(:actual) { subject.matches?('org') }
65
+
66
+ it { expect(actual).to eq false }
67
+ end
68
+ end
69
+
70
+
71
+ #=============== VALIDATION ===========================
72
+
73
+ describe '.valid?' do
74
+ describe 'when prefix and href provided' do
75
+ it { expect(subject.valid?).to eq true }
76
+ end
77
+ [:prefix, :href].each do |prop|
78
+ describe "when #{ prop } nil" do
79
+ before do
80
+ allow(subject).to receive("namespace_#{ prop }").and_return(nil)
81
+ end
82
+
83
+ it { expect(subject.valid?).to eq false }
84
+ end
85
+ end
86
+ end
87
+
88
+ end
89
+
90
+
91
+ #-------------------------------------------------------------
92
+ # Private Methods
93
+ #-------------------------------------------------------------
94
+
95
+ describe 'private method tests' do
96
+
97
+ # .option_keys
98
+ describe '.option_keys' do
99
+ let(:actual) { subject.send(:option_keys).sort }
100
+ let(:expected) { [:prefix, :href].sort }
101
+
102
+ it { expect(actual).to eq expected }
103
+ end
104
+
105
+ end
106
+
107
+ end
@@ -0,0 +1,116 @@
1
+ require 'spec_helper'
2
+
3
+ describe Caracal::Core::Namespaces do
4
+ let(:m1) { Caracal::Core::Models::NamespaceModel.new({ prefix: 'com', href: 'http://www.example.com' }) }
5
+ let(:m2) { Caracal::Core::Models::NamespaceModel.new({ prefix: 'org', href: 'http://www.example.org' }) }
6
+
7
+ subject { Caracal::Document.new }
8
+
9
+
10
+ #-------------------------------------------------------------
11
+ # Class Methods
12
+ #-------------------------------------------------------------
13
+
14
+ describe 'public class tests' do
15
+
16
+ # .default_namespaces
17
+ describe '.default_namespaces' do
18
+ it { expect(subject.class.default_namespaces).to be_a(Array) }
19
+ end
20
+
21
+ end
22
+
23
+
24
+ #-------------------------------------------------------------
25
+ # Public Methods
26
+ #-------------------------------------------------------------
27
+
28
+ describe 'public method tests' do
29
+
30
+ #============== ATTRIBUTES =====================
31
+
32
+ # .namespace
33
+ describe '.namespace' do
34
+ it 'delegates to registration method' do
35
+ expect(subject).to receive(:register_namespace)
36
+ subject.namespace({ prefix: 'dummy', href: 'http://www.dummy.com' })
37
+ end
38
+ end
39
+
40
+
41
+ #============== GETTERS ========================
42
+
43
+ # .namespaces
44
+ describe '.namespaces' do
45
+ it { expect(subject.namespaces).to be_a(Array) }
46
+ end
47
+
48
+ # .find_namespace
49
+ describe '.find_namespace' do
50
+ let(:actual) { subject.find_namespace(key) }
51
+
52
+ before do
53
+ allow(subject).to receive(:namespaces).and_return([m1])
54
+ end
55
+
56
+ describe 'when key is registered' do
57
+ let(:key) { m1.namespace_prefix }
58
+
59
+ it { expect(actual).to eq m1 }
60
+ end
61
+ describe 'when key is not registered' do
62
+ let(:key) { m2.namespace_prefix }
63
+
64
+ it { expect(actual).to eq nil }
65
+ end
66
+ end
67
+
68
+
69
+ #============== REGISTRATION ========================
70
+
71
+ # .register_namespace
72
+ describe '.register_namespace' do
73
+ let(:default_length) { subject.class.default_namespaces.size }
74
+
75
+ describe 'when not already registered' do
76
+ before do
77
+ subject.register_namespace(m1)
78
+ end
79
+
80
+ it { expect(subject.namespaces.size).to eq default_length + 1 }
81
+ end
82
+ describe 'when already registered' do
83
+ before do
84
+ subject.register_namespace(m1)
85
+ subject.register_namespace(m1)
86
+ end
87
+
88
+ it { expect(subject.namespaces.size).to eq default_length + 1 }
89
+ end
90
+ end
91
+
92
+ # .unregister_namespace
93
+ describe '.unregister_namespace' do
94
+ let(:default_length) { subject.class.default_namespaces.size }
95
+
96
+ describe 'when registered' do
97
+ before do
98
+ subject.register_namespace(m1)
99
+ subject.unregister_namespace(m1.namespace_prefix)
100
+ end
101
+
102
+ it { expect(subject.namespaces.size).to eq default_length }
103
+ end
104
+ describe 'when not registered' do
105
+ before do
106
+ subject.register_namespace(m1)
107
+ subject.unregister_namespace(m2.namespace_prefix)
108
+ end
109
+
110
+ it { expect(subject.namespaces.size).to eq default_length + 1 }
111
+ end
112
+ end
113
+
114
+ end
115
+
116
+ end
@@ -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
data/tmp_caracal ADDED
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.9
4
+ version: 1.0.10
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: 2017-06-08 00:00:00.000000000 Z
12
+ date: 2017-06-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -115,6 +115,8 @@ files:
115
115
  - lib/caracal/core/custom_properties.rb
116
116
  - lib/caracal/core/file_name.rb
117
117
  - lib/caracal/core/fonts.rb
118
+ - lib/caracal/core/iframes.rb
119
+ - lib/caracal/core/ignorables.rb
118
120
  - lib/caracal/core/images.rb
119
121
  - lib/caracal/core/list_styles.rb
120
122
  - lib/caracal/core/lists.rb
@@ -122,6 +124,7 @@ files:
122
124
  - lib/caracal/core/models/border_model.rb
123
125
  - lib/caracal/core/models/custom_property_model.rb
124
126
  - lib/caracal/core/models/font_model.rb
127
+ - lib/caracal/core/models/iframe_model.rb
125
128
  - lib/caracal/core/models/image_model.rb
126
129
  - lib/caracal/core/models/line_break_model.rb
127
130
  - lib/caracal/core/models/link_model.rb
@@ -129,6 +132,7 @@ files:
129
132
  - lib/caracal/core/models/list_model.rb
130
133
  - lib/caracal/core/models/list_style_model.rb
131
134
  - lib/caracal/core/models/margin_model.rb
135
+ - lib/caracal/core/models/namespace_model.rb
132
136
  - lib/caracal/core/models/page_break_model.rb
133
137
  - lib/caracal/core/models/page_number_model.rb
134
138
  - lib/caracal/core/models/page_size_model.rb
@@ -139,6 +143,7 @@ files:
139
143
  - lib/caracal/core/models/table_cell_model.rb
140
144
  - lib/caracal/core/models/table_model.rb
141
145
  - lib/caracal/core/models/text_model.rb
146
+ - lib/caracal/core/namespaces.rb
142
147
  - lib/caracal/core/page_breaks.rb
143
148
  - lib/caracal/core/page_numbers.rb
144
149
  - lib/caracal/core/page_settings.rb
@@ -167,12 +172,15 @@ files:
167
172
  - lib/tilt/caracal.rb
168
173
  - spec/lib/caracal/core/file_name_spec.rb
169
174
  - spec/lib/caracal/core/fonts_spec.rb
175
+ - spec/lib/caracal/core/iframes_spec.rb
176
+ - spec/lib/caracal/core/ignorables_spec.rb
170
177
  - spec/lib/caracal/core/images_spec.rb
171
178
  - spec/lib/caracal/core/list_styles_spec.rb
172
179
  - spec/lib/caracal/core/lists_spec.rb
173
180
  - spec/lib/caracal/core/models/base_model_spec.rb
174
181
  - spec/lib/caracal/core/models/border_model_spec.rb
175
182
  - spec/lib/caracal/core/models/font_model_spec.rb
183
+ - spec/lib/caracal/core/models/iframe_model_spec.rb
176
184
  - spec/lib/caracal/core/models/image_model_spec.rb
177
185
  - spec/lib/caracal/core/models/line_break_model_spec.rb
178
186
  - spec/lib/caracal/core/models/link_model_spec.rb
@@ -180,6 +188,7 @@ files:
180
188
  - spec/lib/caracal/core/models/list_model_spec.rb
181
189
  - spec/lib/caracal/core/models/list_style_model_spec.rb
182
190
  - spec/lib/caracal/core/models/margin_model_spec.rb
191
+ - spec/lib/caracal/core/models/namespace_model_spec.rb
183
192
  - spec/lib/caracal/core/models/page_break_model_spec.rb
184
193
  - spec/lib/caracal/core/models/page_number_model_spec.rb
185
194
  - spec/lib/caracal/core/models/page_size_model_spec.rb
@@ -190,6 +199,7 @@ files:
190
199
  - spec/lib/caracal/core/models/table_cell_model_spec.rb
191
200
  - spec/lib/caracal/core/models/table_model_spec.rb
192
201
  - spec/lib/caracal/core/models/text_model_spec.rb
202
+ - spec/lib/caracal/core/namespaces_spec.rb
193
203
  - spec/lib/caracal/core/page_breaks_spec.rb
194
204
  - spec/lib/caracal/core/page_numbers_spec.rb
195
205
  - spec/lib/caracal/core/page_settings_spec.rb
@@ -200,6 +210,8 @@ files:
200
210
  - spec/lib/caracal/core/text_spec.rb
201
211
  - spec/lib/caracal/errors_spec.rb
202
212
  - spec/spec_helper.rb
213
+ - spec/support/_fixtures/snippet.docx
214
+ - tmp_caracal
203
215
  homepage: https://github.com/trade-informatics/caracal
204
216
  licenses:
205
217
  - MIT
@@ -227,12 +239,15 @@ summary: Fast, professional MSWord writer for Ruby.
227
239
  test_files:
228
240
  - spec/lib/caracal/core/file_name_spec.rb
229
241
  - spec/lib/caracal/core/fonts_spec.rb
242
+ - spec/lib/caracal/core/iframes_spec.rb
243
+ - spec/lib/caracal/core/ignorables_spec.rb
230
244
  - spec/lib/caracal/core/images_spec.rb
231
245
  - spec/lib/caracal/core/list_styles_spec.rb
232
246
  - spec/lib/caracal/core/lists_spec.rb
233
247
  - spec/lib/caracal/core/models/base_model_spec.rb
234
248
  - spec/lib/caracal/core/models/border_model_spec.rb
235
249
  - spec/lib/caracal/core/models/font_model_spec.rb
250
+ - spec/lib/caracal/core/models/iframe_model_spec.rb
236
251
  - spec/lib/caracal/core/models/image_model_spec.rb
237
252
  - spec/lib/caracal/core/models/line_break_model_spec.rb
238
253
  - spec/lib/caracal/core/models/link_model_spec.rb
@@ -240,6 +255,7 @@ test_files:
240
255
  - spec/lib/caracal/core/models/list_model_spec.rb
241
256
  - spec/lib/caracal/core/models/list_style_model_spec.rb
242
257
  - spec/lib/caracal/core/models/margin_model_spec.rb
258
+ - spec/lib/caracal/core/models/namespace_model_spec.rb
243
259
  - spec/lib/caracal/core/models/page_break_model_spec.rb
244
260
  - spec/lib/caracal/core/models/page_number_model_spec.rb
245
261
  - spec/lib/caracal/core/models/page_size_model_spec.rb
@@ -250,6 +266,7 @@ test_files:
250
266
  - spec/lib/caracal/core/models/table_cell_model_spec.rb
251
267
  - spec/lib/caracal/core/models/table_model_spec.rb
252
268
  - spec/lib/caracal/core/models/text_model_spec.rb
269
+ - spec/lib/caracal/core/namespaces_spec.rb
253
270
  - spec/lib/caracal/core/page_breaks_spec.rb
254
271
  - spec/lib/caracal/core/page_numbers_spec.rb
255
272
  - spec/lib/caracal/core/page_settings_spec.rb
@@ -260,3 +277,4 @@ test_files:
260
277
  - spec/lib/caracal/core/text_spec.rb
261
278
  - spec/lib/caracal/errors_spec.rb
262
279
  - spec/spec_helper.rb
280
+ - spec/support/_fixtures/snippet.docx