rocx 0.5.6 → 0.5.7

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 (71) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -0
  3. data/Gemfile.lock +1 -1
  4. data/lib/rocx.rb +1 -1
  5. data/lib/rocx/elements/base_container.rb +17 -2
  6. data/lib/rocx/elements/paragraph.rb +33 -21
  7. data/lib/rocx/elements/run.rb +2 -2
  8. data/lib/rocx/elements/style.rb +19 -0
  9. data/lib/rocx/parts/base_part.rb +4 -0
  10. data/lib/rocx/parts/content_types.rb +2 -6
  11. data/lib/rocx/parts/document.rb +2 -3
  12. data/lib/rocx/parts/global_rels.rb +2 -3
  13. data/lib/rocx/parts/rels.rb +2 -3
  14. data/lib/rocx/parts/settings.rb +2 -3
  15. data/lib/rocx/parts/styles.rb +2 -3
  16. data/lib/rocx/properties/alignment.rb +1 -1
  17. data/lib/rocx/properties/attribute_builder.rb +283 -0
  18. data/lib/rocx/properties/base_property.rb +4 -0
  19. data/lib/rocx/properties/border.rb +32 -0
  20. data/lib/rocx/properties/borders.rb +48 -0
  21. data/lib/rocx/properties/compress_punctuation.rb +11 -0
  22. data/lib/rocx/properties/frame.rb +70 -0
  23. data/lib/rocx/properties/indentation.rb +1 -1
  24. data/lib/rocx/properties/numbering.rb +28 -0
  25. data/lib/rocx/properties/shading.rb +75 -0
  26. data/lib/rocx/properties/spacing.rb +38 -0
  27. data/lib/rocx/properties/tab.rb +77 -0
  28. data/lib/rocx/properties/tabs.rb +55 -0
  29. data/lib/rocx/properties/text_direction.rb +15 -0
  30. data/lib/rocx/properties/textbox_tight_wrap.rb +15 -0
  31. data/lib/rocx/properties/vertical_alignment.rb +19 -0
  32. data/lib/rocx/version.rb +1 -1
  33. data/rocx.gemspec +1 -0
  34. data/test/package_test.rb +6 -6
  35. data/test/properties/auto_adjust_right_indent_test.rb +4 -4
  36. data/test/properties/auto_space_de_test.rb +4 -4
  37. data/test/properties/auto_space_dn_test.rb +4 -4
  38. data/test/properties/bidi_test.rb +4 -4
  39. data/test/properties/bold_test.rb +4 -4
  40. data/test/properties/border_test.rb +216 -0
  41. data/test/properties/borders_test.rb +95 -0
  42. data/test/properties/compress_punctuation_test.rb +50 -0
  43. data/test/properties/conditional_formatting_test.rb +4 -4
  44. data/test/properties/contextual_spacing_test.rb +4 -4
  45. data/test/properties/div_id_test.rb +3 -3
  46. data/test/properties/frame_test.rb +497 -0
  47. data/test/properties/italics_test.rb +4 -4
  48. data/test/properties/keep_lines_test.rb +4 -4
  49. data/test/properties/keep_next_test.rb +4 -4
  50. data/test/properties/kinsoku_test.rb +4 -4
  51. data/test/properties/mirror_indent_test.rb +4 -4
  52. data/test/properties/numbering_test.rb +86 -0
  53. data/test/properties/outline_level_test.rb +4 -4
  54. data/test/properties/overflow_punctuation_test.rb +4 -4
  55. data/test/properties/page_break_before_test.rb +4 -4
  56. data/test/properties/shading_test.rb +225 -0
  57. data/test/properties/snap_to_grid_test.rb +4 -4
  58. data/test/properties/spacing_test.rb +248 -0
  59. data/test/properties/style_test.rb +30 -0
  60. data/test/properties/supress_auto_hyphens_test.rb +4 -4
  61. data/test/properties/supress_line_numbers_test.rb +4 -4
  62. data/test/properties/supress_overlap_test.rb +4 -4
  63. data/test/properties/tab_test.rb +63 -0
  64. data/test/properties/tabs_test.rb +54 -0
  65. data/test/properties/text_direction_test.rb +100 -0
  66. data/test/properties/textbox_tight_wrap_test.rb +88 -0
  67. data/test/properties/vertical_alignment_test.rb +88 -0
  68. data/test/properties/widow_control_test.rb +4 -4
  69. data/test/properties/word_wrap_test.rb +4 -4
  70. data/test/test_helper.rb +2 -5
  71. metadata +45 -3
@@ -5,7 +5,7 @@ class SnapToGridTest < PropertyTest
5
5
 
6
6
  context "always" do
7
7
  setup do
8
- @snap_to_grid = Rocx::Properties::SnapToGrid.new(:on)
8
+ @snap_to_grid = SnapToGrid.new(:on)
9
9
  end
10
10
 
11
11
  should "have the right tag" do
@@ -19,7 +19,7 @@ class SnapToGridTest < PropertyTest
19
19
 
20
20
  context "when the value is on, it" do
21
21
  setup do
22
- @snap_to_grid = Rocx::Properties::SnapToGrid.new(:on)
22
+ @snap_to_grid = SnapToGrid.new(:on)
23
23
  end
24
24
 
25
25
  should "return XML to that effect" do
@@ -29,7 +29,7 @@ class SnapToGridTest < PropertyTest
29
29
 
30
30
  context "when the value is off, it" do
31
31
  setup do
32
- @snap_to_grid = Rocx::Properties::SnapToGrid.new(:off)
32
+ @snap_to_grid = SnapToGrid.new(:off)
33
33
  end
34
34
 
35
35
  should "return XML to that effect" do
@@ -39,7 +39,7 @@ class SnapToGridTest < PropertyTest
39
39
 
40
40
  context "when the value is nil, it" do
41
41
  setup do
42
- @snap_to_grid = Rocx::Properties::SnapToGrid.new(nil)
42
+ @snap_to_grid = SnapToGrid.new(nil)
43
43
  end
44
44
 
45
45
  should "not return XML" do
@@ -0,0 +1,248 @@
1
+ require "test_helper"
2
+
3
+ class SpacingTest < PropertyTest
4
+ attr_reader :spacing
5
+
6
+ context "always" do
7
+ setup do
8
+ @spacing = Spacing.new
9
+ end
10
+
11
+ should "have the right name" do
12
+ assert_equal "spacing", spacing.name
13
+ end
14
+
15
+ should "have the right tag" do
16
+ assert_equal :spacing, spacing.tag
17
+ end
18
+ end
19
+
20
+ context "for the after attribute, it" do
21
+ setup do
22
+ @spacing = Spacing.new
23
+ end
24
+
25
+ should "allow positive integers" do
26
+ assert_nothing_raised do
27
+ spacing.after = 24
28
+ end
29
+ end
30
+
31
+ should "not allow anything else" do
32
+ assert_raises ArgumentError do
33
+ spacing.after = -24
34
+ end
35
+
36
+ assert_raises ArgumentError do
37
+ spacing.after = :big
38
+ end
39
+ end
40
+ end
41
+
42
+ context "for the after autospacing attribute, it" do
43
+ setup do
44
+ @spacing = Spacing.new
45
+ end
46
+
47
+ should "allow :on" do
48
+ assert_nothing_raised do
49
+ spacing.after_auto = :on
50
+ end
51
+ end
52
+
53
+ should "allow :off" do
54
+ assert_nothing_raised do
55
+ spacing.after_auto = :off
56
+ end
57
+ end
58
+
59
+ should "not allow anything else" do
60
+ assert_raises ArgumentError do
61
+ spacing.after_auto = :on_and_off
62
+ end
63
+ end
64
+ end
65
+
66
+ context "for the after lines attribute, it" do
67
+ setup do
68
+ @spacing = Spacing.new
69
+ end
70
+
71
+ should "allow positive integers" do
72
+ assert_nothing_raised do
73
+ spacing.after_lines = 24
74
+ end
75
+ end
76
+
77
+ should "allow negative integers" do
78
+ assert_nothing_raised do
79
+ spacing.after_lines = -24
80
+ end
81
+ end
82
+
83
+ should "not allow anything else" do
84
+ assert_raises ArgumentError do
85
+ spacing.after_lines = 2.5
86
+ end
87
+
88
+ assert_raises ArgumentError do
89
+ spacing.after_lines = :big
90
+ end
91
+ end
92
+ end
93
+
94
+ context "for the before attribute, it" do
95
+ setup do
96
+ @spacing = Spacing.new
97
+ end
98
+
99
+ should "allow positive integers" do
100
+ assert_nothing_raised do
101
+ spacing.before = 24
102
+ end
103
+ end
104
+
105
+ should "not allow anything else" do
106
+ assert_raises ArgumentError do
107
+ spacing.before = -24
108
+ end
109
+
110
+ assert_raises ArgumentError do
111
+ spacing.before = :big
112
+ end
113
+ end
114
+ end
115
+
116
+ context "for the before autospacing attribute, it" do
117
+ setup do
118
+ @spacing = Spacing.new
119
+ end
120
+
121
+ should "allow :on" do
122
+ assert_nothing_raised do
123
+ spacing.before_auto = :on
124
+ end
125
+ end
126
+
127
+ should "allow :off" do
128
+ assert_nothing_raised do
129
+ spacing.before_auto = :off
130
+ end
131
+ end
132
+
133
+ should "not allow anything else" do
134
+ assert_raises ArgumentError do
135
+ spacing.before_auto = :on_and_off
136
+ end
137
+ end
138
+ end
139
+
140
+ context "for the before lines attribute, it" do
141
+ setup do
142
+ @spacing = Spacing.new
143
+ end
144
+
145
+ should "allow positive integers" do
146
+ assert_nothing_raised do
147
+ spacing.before_lines = 24
148
+ end
149
+ end
150
+
151
+ should "allow negative integers" do
152
+ assert_nothing_raised do
153
+ spacing.before_lines = -24
154
+ end
155
+ end
156
+
157
+ should "not allow anything else" do
158
+ assert_raises ArgumentError do
159
+ spacing.before_lines = 2.5
160
+ end
161
+
162
+ assert_raises ArgumentError do
163
+ spacing.before_lines = :big
164
+ end
165
+ end
166
+ end
167
+
168
+ context "for the line attribute, it" do
169
+ setup do
170
+ @spacing = Spacing.new
171
+ end
172
+
173
+ should "allow positive integers" do
174
+ assert_nothing_raised do
175
+ spacing.line = 24
176
+ end
177
+ end
178
+
179
+ should "allow negative integers" do
180
+ assert_nothing_raised do
181
+ spacing.line = -24
182
+ end
183
+ end
184
+
185
+ should "not allow anything else" do
186
+ assert_raises ArgumentError do
187
+ spacing.line = 2.5
188
+ end
189
+
190
+ assert_raises ArgumentError do
191
+ spacing.line = :big
192
+ end
193
+ end
194
+ end
195
+
196
+ context "for the line rule attribute, it" do
197
+ setup do
198
+ @spacing = Spacing.new
199
+ end
200
+
201
+ should "allow :atLeast" do
202
+ assert_nothing_raised do
203
+ spacing.line_rule = :atLeast
204
+ end
205
+ end
206
+
207
+ should "allow :auto" do
208
+ assert_nothing_raised do
209
+ spacing.line_rule = :auto
210
+ end
211
+ end
212
+
213
+ should "allow :exact" do
214
+ assert_nothing_raised do
215
+ spacing.line_rule = :exact
216
+ end
217
+ end
218
+
219
+ should "not all anything else" do
220
+ assert_raises ArgumentError do
221
+ spacing.line_rule = :bad
222
+ end
223
+ end
224
+ end
225
+
226
+ context "when no attributes are set, it" do
227
+ setup do
228
+ @spacing = Spacing.new
229
+ end
230
+
231
+ should "not output any XML" do
232
+ assert_equal "", xml(spacing)
233
+ end
234
+ end
235
+
236
+ context "when attribuets are set with valid values, it" do
237
+ setup do
238
+ @spacing = Spacing.new
239
+ spacing.line = 276
240
+ spacing.line_rule = :auto
241
+ end
242
+
243
+ should "output the correct XML" do
244
+ assert_equal "<w:spacing w:line=\"276\" w:lineRule=\"auto\"/>", xml(spacing)
245
+ end
246
+ end
247
+
248
+ end
@@ -0,0 +1,30 @@
1
+ require "test_helper"
2
+
3
+ class StylePropertyTest < PropertyTest
4
+ attr_reader :style
5
+
6
+ context "always" do
7
+ setup do
8
+ @style = Style.new("Nope Style 1")
9
+ end
10
+
11
+ should "set the right tag" do
12
+ assert_equal :pStyle, style.tag
13
+ end
14
+
15
+ should "set the right name" do
16
+ assert_equal "style", style.name
17
+ end
18
+ end
19
+
20
+ context "with a valid style" do
21
+ setup do
22
+ @style = Style.new("Nope Style 1")
23
+ end
24
+
25
+ should "return the proper XML" do
26
+ assert_equal "<w:pStyle w:val=\"Nope Style 1\"/>", xml(style)
27
+ end
28
+ end
29
+
30
+ end
@@ -5,7 +5,7 @@ class SupressAutoHyphensTest < PropertyTest
5
5
 
6
6
  context "always" do
7
7
  setup do
8
- @supress_auto_hyphens = Rocx::Properties::SupressAutoHyphens.new(false)
8
+ @supress_auto_hyphens = SupressAutoHyphens.new(false)
9
9
  end
10
10
 
11
11
  should "have the right tag" do
@@ -19,7 +19,7 @@ class SupressAutoHyphensTest < PropertyTest
19
19
 
20
20
  context "when the value is true, it" do
21
21
  setup do
22
- @supress_auto_hyphens = Rocx::Properties::SupressAutoHyphens.new(true)
22
+ @supress_auto_hyphens = SupressAutoHyphens.new(true)
23
23
  end
24
24
 
25
25
  should "return XML" do
@@ -29,7 +29,7 @@ class SupressAutoHyphensTest < PropertyTest
29
29
 
30
30
  context "when the value is false, it" do
31
31
  setup do
32
- @supress_auto_hyphens = Rocx::Properties::SupressAutoHyphens.new(false)
32
+ @supress_auto_hyphens = SupressAutoHyphens.new(false)
33
33
  end
34
34
 
35
35
  should "not return XML" do
@@ -39,7 +39,7 @@ class SupressAutoHyphensTest < PropertyTest
39
39
 
40
40
  context "when the value is nil, it" do
41
41
  setup do
42
- @supress_auto_hyphens = Rocx::Properties::SupressAutoHyphens.new(nil)
42
+ @supress_auto_hyphens = SupressAutoHyphens.new(nil)
43
43
  end
44
44
 
45
45
  should "not return XML" do
@@ -5,7 +5,7 @@ class SupressLineNumbersTest < PropertyTest
5
5
 
6
6
  context "always" do
7
7
  setup do
8
- @supress_line_numbers = Rocx::Properties::SupressLineNumbers.new(false)
8
+ @supress_line_numbers = SupressLineNumbers.new(false)
9
9
  end
10
10
 
11
11
  should "have the right tag" do
@@ -19,7 +19,7 @@ class SupressLineNumbersTest < PropertyTest
19
19
 
20
20
  context "when the value is true, it" do
21
21
  setup do
22
- @supress_line_numbers = Rocx::Properties::SupressLineNumbers.new(true)
22
+ @supress_line_numbers = SupressLineNumbers.new(true)
23
23
  end
24
24
 
25
25
  should "return XML" do
@@ -29,7 +29,7 @@ class SupressLineNumbersTest < PropertyTest
29
29
 
30
30
  context "when the value is false, it" do
31
31
  setup do
32
- @supress_line_numbers = Rocx::Properties::SupressLineNumbers.new(false)
32
+ @supress_line_numbers = SupressLineNumbers.new(false)
33
33
  end
34
34
 
35
35
  should "not return XML" do
@@ -39,7 +39,7 @@ class SupressLineNumbersTest < PropertyTest
39
39
 
40
40
  context "when the value is nil, it" do
41
41
  setup do
42
- @supress_line_numbers = Rocx::Properties::SupressLineNumbers.new(nil)
42
+ @supress_line_numbers = SupressLineNumbers.new(nil)
43
43
  end
44
44
 
45
45
  should "not return XML" do
@@ -5,7 +5,7 @@ class SupressOverlapTest < PropertyTest
5
5
 
6
6
  context "always" do
7
7
  setup do
8
- @supress_overlap = Rocx::Properties::SupressOverlap.new(false)
8
+ @supress_overlap = SupressOverlap.new(false)
9
9
  end
10
10
 
11
11
  should "have the right tag" do
@@ -19,7 +19,7 @@ class SupressOverlapTest < PropertyTest
19
19
 
20
20
  context "when the value is true, it" do
21
21
  setup do
22
- @supress_overlap = Rocx::Properties::SupressOverlap.new(true)
22
+ @supress_overlap = SupressOverlap.new(true)
23
23
  end
24
24
 
25
25
  should "return XML" do
@@ -29,7 +29,7 @@ class SupressOverlapTest < PropertyTest
29
29
 
30
30
  context "when the value is false, it" do
31
31
  setup do
32
- @supress_overlap = Rocx::Properties::SupressOverlap.new(false)
32
+ @supress_overlap = SupressOverlap.new(false)
33
33
  end
34
34
 
35
35
  should "not return XML" do
@@ -39,7 +39,7 @@ class SupressOverlapTest < PropertyTest
39
39
 
40
40
  context "when the value is nil, it" do
41
41
  setup do
42
- @supress_overlap = Rocx::Properties::SupressOverlap.new(nil)
42
+ @supress_overlap = SupressOverlap.new(nil)
43
43
  end
44
44
 
45
45
  should "not return XML" do
@@ -0,0 +1,63 @@
1
+ require "test_helper"
2
+
3
+ class TabTest < PropertyTest
4
+ attr_reader :tab
5
+
6
+ context "always" do
7
+ setup do
8
+ @tab = Tab.new(1234, :start)
9
+ end
10
+
11
+ should "have the right name" do
12
+ assert_equal "tab", tab.name
13
+ end
14
+
15
+ should "have the right tag" do
16
+ assert_equal :tab, tab.tag
17
+ end
18
+ end
19
+
20
+ context "when assigning bad position values, it" do
21
+ should "raise an exception" do
22
+ assert_raises ArgumentError do
23
+ @tab = Tab.new(:bad, :start)
24
+ end
25
+ end
26
+ end
27
+
28
+ context "when assigning bad type values, it" do
29
+ should "raise an exception" do
30
+ assert_raises ArgumentError do
31
+ @tab = Tab.new(1234, :bad)
32
+ end
33
+ end
34
+ end
35
+
36
+ context "when assigniing bad leader values, it" do
37
+ should "raise an exception" do
38
+ assert_raises ArgumentError do
39
+ @tab = Tab.new(1234, :clear, :bad)
40
+ end
41
+ end
42
+ end
43
+
44
+ context "with valid values, it" do
45
+ setup do
46
+ @tab = Tab.new(1234, :start)
47
+ end
48
+
49
+ should "return the right XML" do
50
+ assert_equal "<w:tab w:pos=\"1234\" w:val=\"start\"/>", xml(tab)
51
+ end
52
+ end
53
+
54
+ context "with valid values and a specified leader, it" do
55
+ setup do
56
+ @tab = Tab.new(1234, :start, :dot)
57
+ end
58
+
59
+ should "Return the right XML" do
60
+ assert_equal "<w:tab w:pos=\"1234\" w:val=\"start\" w:leader=\"dot\"/>", xml(tab)
61
+ end
62
+ end
63
+ end