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 ItalicsTest < PropertyTest
5
5
 
6
6
  context "always" do
7
7
  setup do
8
- @italics = Rocx::Properties::Italics.new(false)
8
+ @italics = Italics.new(false)
9
9
  end
10
10
 
11
11
  should "have the right tag" do
@@ -19,7 +19,7 @@ class ItalicsTest < PropertyTest
19
19
 
20
20
  context "when the value is true, it" do
21
21
  setup do
22
- @italics = Rocx::Properties::Italics.new(true)
22
+ @italics = Italics.new(true)
23
23
  end
24
24
 
25
25
  should "return XML" do
@@ -29,7 +29,7 @@ class ItalicsTest < PropertyTest
29
29
 
30
30
  context "when the value is false, it" do
31
31
  setup do
32
- @italics = Rocx::Properties::Italics.new(false)
32
+ @italics = Italics.new(false)
33
33
  end
34
34
 
35
35
  should "not return XML" do
@@ -39,7 +39,7 @@ class ItalicsTest < PropertyTest
39
39
 
40
40
  context "when the value is nil, it" do
41
41
  setup do
42
- @italics = Rocx::Properties::Italics.new(nil)
42
+ @italics = Italics.new(nil)
43
43
  end
44
44
 
45
45
  should "not return XML" do
@@ -5,7 +5,7 @@ class KeepLinesTest < PropertyTest
5
5
 
6
6
  context "always" do
7
7
  setup do
8
- @keep_lines = Rocx::Properties::KeepLines.new(false)
8
+ @keep_lines = KeepLines.new(false)
9
9
  end
10
10
 
11
11
  should "have the right tag" do
@@ -19,7 +19,7 @@ class KeepLinesTest < PropertyTest
19
19
 
20
20
  context "when the value is true, it" do
21
21
  setup do
22
- @keep_lines = Rocx::Properties::KeepLines.new(true)
22
+ @keep_lines = KeepLines.new(true)
23
23
  end
24
24
 
25
25
  should "return XML" do
@@ -29,7 +29,7 @@ class KeepLinesTest < PropertyTest
29
29
 
30
30
  context "when the value is false, it" do
31
31
  setup do
32
- @keep_lines = Rocx::Properties::KeepLines.new(false)
32
+ @keep_lines = KeepLines.new(false)
33
33
  end
34
34
 
35
35
  should "not return XML" do
@@ -39,7 +39,7 @@ class KeepLinesTest < PropertyTest
39
39
 
40
40
  context "when the value is nil, it" do
41
41
  setup do
42
- @keep_lines = Rocx::Properties::KeepLines.new(nil)
42
+ @keep_lines = KeepLines.new(nil)
43
43
  end
44
44
 
45
45
  should "not return XML" do
@@ -5,7 +5,7 @@ class KeepNextTest < PropertyTest
5
5
 
6
6
  context "always" do
7
7
  setup do
8
- @keep_next = Rocx::Properties::KeepNext.new(false)
8
+ @keep_next = KeepNext.new(false)
9
9
  end
10
10
 
11
11
  should "have the right tag" do
@@ -19,7 +19,7 @@ class KeepNextTest < PropertyTest
19
19
 
20
20
  context "when the value is true, it" do
21
21
  setup do
22
- @keep_next = Rocx::Properties::KeepNext.new(true)
22
+ @keep_next = KeepNext.new(true)
23
23
  end
24
24
 
25
25
  should "return XML" do
@@ -29,7 +29,7 @@ class KeepNextTest < PropertyTest
29
29
 
30
30
  context "when the value is false, it" do
31
31
  setup do
32
- @keep_next = Rocx::Properties::KeepNext.new(false)
32
+ @keep_next = KeepNext.new(false)
33
33
  end
34
34
 
35
35
  should "not return XML" do
@@ -39,7 +39,7 @@ class KeepNextTest < PropertyTest
39
39
 
40
40
  context "when the value is nil, it" do
41
41
  setup do
42
- @keep_next = Rocx::Properties::KeepNext.new(nil)
42
+ @keep_next = KeepNext.new(nil)
43
43
  end
44
44
 
45
45
  should "not return XML" do
@@ -5,7 +5,7 @@ class KinsokuTest < PropertyTest
5
5
 
6
6
  context "always" do
7
7
  setup do
8
- @kinsoku = Rocx::Properties::Kinsoku.new(:on)
8
+ @kinsoku = Kinsoku.new(:on)
9
9
  end
10
10
 
11
11
  should "have the right tag" do
@@ -19,7 +19,7 @@ class KinsokuTest < PropertyTest
19
19
 
20
20
  context "when the value is on, it" do
21
21
  setup do
22
- @kinsoku = Rocx::Properties::Kinsoku.new(:on)
22
+ @kinsoku = Kinsoku.new(:on)
23
23
  end
24
24
 
25
25
  should "return XML to that effect" do
@@ -29,7 +29,7 @@ class KinsokuTest < PropertyTest
29
29
 
30
30
  context "when the value is off, it" do
31
31
  setup do
32
- @kinsoku = Rocx::Properties::Kinsoku.new(:off)
32
+ @kinsoku = Kinsoku.new(:off)
33
33
  end
34
34
 
35
35
  should "return XML to that effect" do
@@ -39,7 +39,7 @@ class KinsokuTest < PropertyTest
39
39
 
40
40
  context "when the value is nil, it" do
41
41
  setup do
42
- @kinsoku = Rocx::Properties::Kinsoku.new(nil)
42
+ @kinsoku = Kinsoku.new(nil)
43
43
  end
44
44
 
45
45
  should "not return XML" do
@@ -5,7 +5,7 @@ class MirrorIndentTest < PropertyTest
5
5
 
6
6
  context "always" do
7
7
  setup do
8
- @mirror_indent = Rocx::Properties::MirrorIndent.new(false)
8
+ @mirror_indent = MirrorIndent.new(false)
9
9
  end
10
10
 
11
11
  should "have the right tag" do
@@ -19,7 +19,7 @@ class MirrorIndentTest < PropertyTest
19
19
 
20
20
  context "when the value is true, it" do
21
21
  setup do
22
- @mirror_indent = Rocx::Properties::MirrorIndent.new(true)
22
+ @mirror_indent = MirrorIndent.new(true)
23
23
  end
24
24
 
25
25
  should "return XML" do
@@ -29,7 +29,7 @@ class MirrorIndentTest < PropertyTest
29
29
 
30
30
  context "when the value is false, it" do
31
31
  setup do
32
- @mirror_indent = Rocx::Properties::MirrorIndent.new(false)
32
+ @mirror_indent = MirrorIndent.new(false)
33
33
  end
34
34
 
35
35
  should "not return XML" do
@@ -39,7 +39,7 @@ class MirrorIndentTest < PropertyTest
39
39
 
40
40
  context "when the value is nil, it" do
41
41
  setup do
42
- @mirror_indent = Rocx::Properties::MirrorIndent.new(nil)
42
+ @mirror_indent = MirrorIndent.new(nil)
43
43
  end
44
44
 
45
45
  should "not return XML" do
@@ -0,0 +1,86 @@
1
+ require "test_helper"
2
+
3
+ class NumberingTest < PropertyTest
4
+ attr_reader :numbering
5
+
6
+ context "always" do
7
+ setup do
8
+ @numbering = Numbering.new
9
+ end
10
+
11
+ should "have the right name" do
12
+ assert_equal "numbering", numbering.name
13
+ end
14
+
15
+ should "have the right tag" do
16
+ assert_equal :numPr, numbering.tag
17
+ end
18
+ end
19
+
20
+ context "for the level property, it" do
21
+ setup do
22
+ @numbering = Numbering.new
23
+ end
24
+
25
+ should "allow positive integers" do
26
+ assert_nothing_raised do
27
+ numbering.level = 24
28
+ end
29
+ end
30
+
31
+ should "not allow anything else" do
32
+ assert_raises ArgumentError do
33
+ numbering.level = -24
34
+ end
35
+
36
+ assert_raises ArgumentError do
37
+ numbering.level = :big
38
+ end
39
+ end
40
+ end
41
+
42
+ context "for the id property, it" do
43
+ setup do
44
+ @numbering = Numbering.new
45
+ end
46
+
47
+ should "allow positive integers" do
48
+ assert_nothing_raised do
49
+ numbering.id = 24
50
+ end
51
+ end
52
+
53
+ should "not allow anything else" do
54
+ assert_raises ArgumentError do
55
+ numbering.id = -24
56
+ end
57
+
58
+ assert_raises ArgumentError do
59
+ numbering.id = :big
60
+ end
61
+ end
62
+ end
63
+
64
+ context "with no attributes set, it" do
65
+ setup do
66
+ @numbering = Numbering.new
67
+ end
68
+
69
+ should "not output any XML" do
70
+ assert_equal "", xml(numbering)
71
+ end
72
+ end
73
+
74
+ context "with valid attributes set, it" do
75
+ setup do
76
+ @numbering = Numbering.new
77
+ numbering.level = 4
78
+ numbering.id = 0
79
+ end
80
+
81
+ should "return the correct XML" do
82
+ assert_equal "<w:numPr>\n <w:ilvl w:val=\"4\"/>\n <w:numId w:val=\"0\"/>\n </w:numPr>", xml(numbering)
83
+ end
84
+ end
85
+
86
+ end
@@ -5,7 +5,7 @@ class OutlineLevelTest < PropertyTest
5
5
 
6
6
  context "always" do
7
7
  setup do
8
- @outline_level = Rocx::Properties::OutlineLevel.new(0)
8
+ @outline_level = OutlineLevel.new(0)
9
9
  end
10
10
 
11
11
  should "have the right tag" do
@@ -20,7 +20,7 @@ class OutlineLevelTest < PropertyTest
20
20
  context "with non-integer values, it" do
21
21
  should "raise an error" do
22
22
  assert_raises ArgumentError do
23
- @outline_level = Rocx::Properties::OutlineLevel.new(:big)
23
+ @outline_level = OutlineLevel.new(:big)
24
24
  end
25
25
  end
26
26
  end
@@ -28,14 +28,14 @@ class OutlineLevelTest < PropertyTest
28
28
  context "with integers less than 0, it" do
29
29
  should "raise an error" do
30
30
  assert_raises ArgumentError do
31
- @outline_level = Rocx::Properties::OutlineLevel.new(-1)
31
+ @outline_level = OutlineLevel.new(-1)
32
32
  end
33
33
  end
34
34
  end
35
35
 
36
36
  context "with valid value, it" do
37
37
  setup do
38
- @outline_level = Rocx::Properties::OutlineLevel.new(2)
38
+ @outline_level = OutlineLevel.new(2)
39
39
  end
40
40
 
41
41
  should "return the proper XML" do
@@ -5,7 +5,7 @@ class OverflowPunctuationTest < PropertyTest
5
5
 
6
6
  context "always" do
7
7
  setup do
8
- @overflow_punctuation = Rocx::Properties::OverflowPunctuation.new(false)
8
+ @overflow_punctuation = OverflowPunctuation.new(false)
9
9
  end
10
10
 
11
11
  should "have the right tag" do
@@ -19,7 +19,7 @@ class OverflowPunctuationTest < PropertyTest
19
19
 
20
20
  context "when the value is true, it" do
21
21
  setup do
22
- @overflow_punctuation = Rocx::Properties::OverflowPunctuation.new(true)
22
+ @overflow_punctuation = OverflowPunctuation.new(true)
23
23
  end
24
24
 
25
25
  should "return XML" do
@@ -29,7 +29,7 @@ class OverflowPunctuationTest < PropertyTest
29
29
 
30
30
  context "when the value is false, it" do
31
31
  setup do
32
- @overflow_punctuation = Rocx::Properties::OverflowPunctuation.new(false)
32
+ @overflow_punctuation = OverflowPunctuation.new(false)
33
33
  end
34
34
 
35
35
  should "not return XML" do
@@ -39,7 +39,7 @@ class OverflowPunctuationTest < PropertyTest
39
39
 
40
40
  context "when the value is nil, it" do
41
41
  setup do
42
- @overflow_punctuation = Rocx::Properties::OverflowPunctuation.new(nil)
42
+ @overflow_punctuation = OverflowPunctuation.new(nil)
43
43
  end
44
44
 
45
45
  should "not return XML" do
@@ -5,7 +5,7 @@ class PageBreakBeforeTest < PropertyTest
5
5
 
6
6
  context "always" do
7
7
  setup do
8
- @page_break_before = Rocx::Properties::PageBreakBefore.new(false)
8
+ @page_break_before = PageBreakBefore.new(false)
9
9
  end
10
10
 
11
11
  should "have the right tag" do
@@ -19,7 +19,7 @@ class PageBreakBeforeTest < PropertyTest
19
19
 
20
20
  context "when the value is true, it" do
21
21
  setup do
22
- @page_break_before = Rocx::Properties::PageBreakBefore.new(true)
22
+ @page_break_before = PageBreakBefore.new(true)
23
23
  end
24
24
 
25
25
  should "return XML" do
@@ -29,7 +29,7 @@ class PageBreakBeforeTest < PropertyTest
29
29
 
30
30
  context "when the value is false, it" do
31
31
  setup do
32
- @page_break_before = Rocx::Properties::PageBreakBefore.new(false)
32
+ @page_break_before = PageBreakBefore.new(false)
33
33
  end
34
34
 
35
35
  should "not return XML" do
@@ -39,7 +39,7 @@ class PageBreakBeforeTest < PropertyTest
39
39
 
40
40
  context "when the value is nil, it" do
41
41
  setup do
42
- @page_break_before = Rocx::Properties::PageBreakBefore.new(nil)
42
+ @page_break_before = PageBreakBefore.new(nil)
43
43
  end
44
44
 
45
45
  should "not return XML" do
@@ -0,0 +1,225 @@
1
+ require "test_helper"
2
+
3
+ class ShadingTest < PropertyTest
4
+ attr_reader :shading
5
+
6
+ context "always" do
7
+ setup do
8
+ @shading = Shading.new
9
+ end
10
+
11
+ should "have the right name" do
12
+ assert_equal "shading", shading.name
13
+ end
14
+
15
+ should "have the right tag" do
16
+ assert_equal :shd, shading.tag
17
+ end
18
+ end
19
+
20
+ context "for the color attribute, it" do
21
+ setup do
22
+ @shading = Shading.new
23
+ end
24
+
25
+ should "allow hex color values" do
26
+ assert_nothing_raised do
27
+ shading.color = "4F81BD"
28
+ end
29
+ end
30
+
31
+ should "allow :auto" do
32
+ assert_nothing_raised do
33
+ shading.color = :auto
34
+ end
35
+ end
36
+
37
+ should "not allow anything else" do
38
+ assert_raises ArgumentError do
39
+ shading.color = "green"
40
+ end
41
+ end
42
+ end
43
+
44
+ context "for the fill attribute, it" do
45
+ setup do
46
+ @shading = Shading.new
47
+ end
48
+
49
+ should "allow hex color values" do
50
+ assert_nothing_raised do
51
+ shading.fill = "4F81BD"
52
+ end
53
+ end
54
+
55
+ should "allow :auto" do
56
+ assert_nothing_raised do
57
+ shading.fill = :auto
58
+ end
59
+ end
60
+
61
+ should "not allow anything else" do
62
+ assert_raises ArgumentError do
63
+ shading.fill = "green"
64
+ end
65
+ end
66
+ end
67
+
68
+ context "for the theme color attribute, it" do
69
+ setup do
70
+ @shading = Shading.new
71
+ end
72
+
73
+ should "only allow valid theme colors" do
74
+ assert_nothing_raised do
75
+ shading.theme_color = :hyperlink
76
+ end
77
+ end
78
+
79
+ should "not allow anything else" do
80
+ assert ArgumentError do
81
+ shading.theme_color = :lens_flare
82
+ end
83
+ end
84
+ end
85
+
86
+ context "for the theme fill attribute, it" do
87
+ setup do
88
+ @shading = Shading.new
89
+ end
90
+
91
+ should "only allow valid theme colors" do
92
+ assert_nothing_raised do
93
+ shading.theme_fill = :hyperlink
94
+ end
95
+ end
96
+
97
+ should "not allow anything else" do
98
+ assert ArgumentError do
99
+ shading.theme_fill = :lens_flare
100
+ end
101
+ end
102
+ end
103
+
104
+ context "for the theme fill shade attribute" do
105
+ setup do
106
+ @shading = Shading.new
107
+ end
108
+
109
+ should "only allow 2-digit hex colors" do
110
+ assert_nothing_raised do
111
+ shading.theme_fill_shade = "BF"
112
+ end
113
+ end
114
+
115
+ should "not allow anything else" do
116
+ assert ArgumentError do
117
+ shading.theme_fill_shade = :dark
118
+ end
119
+ end
120
+ end
121
+
122
+ context "for the theme fill tint attribute" do
123
+ setup do
124
+ @shading = Shading.new
125
+ end
126
+
127
+ should "only allow 2-digit hex colors" do
128
+ assert_nothing_raised do
129
+ shading.theme_fill_tint = "BF"
130
+ end
131
+ end
132
+
133
+ should "not allow anything else" do
134
+ assert ArgumentError do
135
+ shading.theme_fill_tint = :dark
136
+ end
137
+ end
138
+ end
139
+
140
+ context "for the theme shade attribute, it" do
141
+ setup do
142
+ @shading = Shading.new
143
+ end
144
+
145
+ should "only allow 2-digit hex colors" do
146
+ assert_nothing_raised do
147
+ shading.theme_shade = "BF"
148
+ end
149
+ end
150
+
151
+ should "not allow anything else" do
152
+ assert ArgumentError do
153
+ shading.theme_shade = :dark
154
+ end
155
+ end
156
+ end
157
+
158
+ context "for the theme tint attribute, it" do
159
+ setup do
160
+ @shading = Shading.new
161
+ end
162
+
163
+ should "only allow 2-digit hex colors" do
164
+ assert_nothing_raised do
165
+ shading.theme_tint = "BF"
166
+ end
167
+ end
168
+
169
+ should "not allow anything else" do
170
+ assert ArgumentError do
171
+ shading.theme_tint = :dark
172
+ end
173
+ end
174
+ end
175
+
176
+ context "for the pattern attribute, it" do
177
+ setup do
178
+ @shading = Shading.new
179
+ end
180
+
181
+ should "allow valid values" do
182
+ assert_nothing_raised do
183
+ shading.pattern = :pct90
184
+ end
185
+
186
+ assert_nothing_raised do
187
+ shading.pattern = :solid
188
+ end
189
+
190
+ assert_nothing_raised do
191
+ shading.pattern = :vertStripe
192
+ end
193
+ end
194
+
195
+ should "not allow non-valid values" do
196
+ assert_raises ArgumentError do
197
+ shading.pattern = :somethingIJustMadeUp
198
+ end
199
+ end
200
+ end
201
+
202
+ context "with no attributes set, it" do
203
+ setup do
204
+ @shading = Shading.new
205
+ end
206
+
207
+ should "not return any XML" do
208
+ assert_equal "", xml(shading)
209
+ end
210
+ end
211
+
212
+ context "with attributes set to valid values, it" do
213
+ setup do
214
+ @shading = Shading.new
215
+ shading.pattern = :pct20
216
+ shading.theme_color = :accent6
217
+ shading.theme_fill = :accent3
218
+ end
219
+
220
+ should "return the correct XML" do
221
+ assert_equal "<w:shd w:themeColor=\"accent6\" w:themeFill=\"accent3\" w:val=\"pct20\"/>", xml(shading)
222
+ end
223
+ end
224
+
225
+ end