rocx 0.5.8 → 0.6.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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +55 -22
- data/Rakefile +1 -0
- data/lib/rocx.rb +1 -0
- data/lib/rocx/attribute_builder.rb +296 -0
- data/lib/rocx/elements.rb +3 -2
- data/lib/rocx/elements/absolute_position_tab.rb +29 -0
- data/lib/rocx/elements/bidi_embed.rb +17 -0
- data/lib/rocx/elements/bidi_override.rb +17 -0
- data/lib/rocx/elements/break.rb +19 -5
- data/lib/rocx/elements/carriage_return.rb +8 -0
- data/lib/rocx/elements/{base_container.rb → container.rb} +21 -16
- data/lib/rocx/elements/content_part.rb +8 -0
- data/lib/rocx/elements/control.rb +10 -0
- data/lib/rocx/elements/deleted_text.rb +8 -0
- data/lib/rocx/elements/dirty.rb +6 -0
- data/lib/rocx/elements/element.rb +62 -0
- data/lib/rocx/elements/last_rendered_page_break.rb +6 -0
- data/lib/rocx/elements/long_day.rb +8 -0
- data/lib/rocx/elements/long_month.rb +8 -0
- data/lib/rocx/elements/long_year.rb +8 -0
- data/lib/rocx/elements/nonbreaking_hyphen.rb +7 -0
- data/lib/rocx/elements/optional_hyphen.rb +8 -0
- data/lib/rocx/elements/page_number.rb +7 -0
- data/lib/rocx/elements/paragraph.rb +2 -4
- data/lib/rocx/elements/ruby.rb +46 -0
- data/lib/rocx/elements/run.rb +2 -4
- data/lib/rocx/elements/short_day.rb +8 -0
- data/lib/rocx/elements/short_month.rb +8 -0
- data/lib/rocx/elements/short_year.rb +8 -0
- data/lib/rocx/elements/symbol.rb +6 -5
- data/lib/rocx/elements/tab.rb +6 -0
- data/lib/rocx/elements/text.rb +14 -7
- data/lib/rocx/properties/border.rb +0 -2
- data/lib/rocx/properties/color.rb +0 -2
- data/lib/rocx/properties/complex_property.rb +1 -0
- data/lib/rocx/properties/conditional_formatting.rb +0 -2
- data/lib/rocx/properties/east_asian_layout.rb +2 -4
- data/lib/rocx/properties/font.rb +0 -2
- data/lib/rocx/properties/frame.rb +7 -9
- data/lib/rocx/properties/indentation.rb +0 -2
- data/lib/rocx/properties/language.rb +1 -2
- data/lib/rocx/properties/manual_width.rb +1 -2
- data/lib/rocx/properties/numbering.rb +0 -2
- data/lib/rocx/properties/phonetic_guide_alignment.rb +13 -0
- data/lib/rocx/properties/phonetic_guide_base_font_size.rb +8 -0
- data/lib/rocx/properties/phonetic_guide_font_size.rb +8 -0
- data/lib/rocx/properties/phonetic_guide_font_size_raise.rb +8 -0
- data/lib/rocx/properties/phonetic_guide_language.rb +17 -0
- data/lib/rocx/properties/shading.rb +0 -2
- data/lib/rocx/properties/spacing.rb +0 -2
- data/lib/rocx/properties/underline.rb +0 -2
- data/lib/rocx/properties/value_property.rb +1 -1
- data/lib/rocx/version.rb +1 -1
- data/spec/elements/absolute_position_tab_spec.rb +84 -0
- data/spec/elements/bidi_embed_spec.rb +31 -0
- data/spec/elements/bidi_override_spec.rb +31 -0
- data/spec/elements/break_spec.rb +32 -24
- data/spec/elements/carriage_return_spec.rb +12 -0
- data/spec/elements/content_part_spec.rb +18 -0
- data/spec/elements/control_spec.rb +41 -0
- data/spec/elements/deleted_text_spec.rb +24 -0
- data/spec/elements/dirty_spec.rb +12 -0
- data/spec/elements/last_rendered_page_break_spec.rb +12 -0
- data/spec/elements/long_day_spec.rb +12 -0
- data/spec/elements/long_month_spec.rb +12 -0
- data/spec/elements/long_year_spec.rb +12 -0
- data/spec/elements/nonbreaking_hyphen_spec.rb +12 -0
- data/spec/elements/optional_hyphen_spec.rb +12 -0
- data/spec/elements/page_number_spec.rb +12 -0
- data/spec/elements/paragraph_spec.rb +9 -7
- data/spec/elements/ruby_spec.rb +66 -0
- data/spec/elements/run_spec.rb +2 -2
- data/spec/elements/short_day_spec.rb +12 -0
- data/spec/elements/short_month_spec.rb +12 -0
- data/spec/elements/short_year_spec.rb +12 -0
- data/spec/elements/symbol_spec.rb +20 -10
- data/spec/elements/tab_spec.rb +12 -0
- data/spec/elements/text_spec.rb +12 -11
- data/spec/properties/phonetic_guide_alignment_spec.rb +42 -0
- data/spec/properties/phonetic_guide_base_font_size_spec.rb +25 -0
- data/spec/properties/phonetic_guide_font_size_raise_spec.rb +25 -0
- data/spec/properties/phonetic_guide_font_size_spec.rb +25 -0
- data/spec/properties/phonetic_guide_language_spec.rb +12 -0
- data/spec/support/element_test_macros.rb +135 -4
- metadata +55 -5
- data/lib/rocx/elements/base_element.rb +0 -91
- data/lib/rocx/properties/attribute_builder.rb +0 -289
data/spec/elements/break_spec.rb
CHANGED
@@ -3,45 +3,53 @@ require "spec_helper"
|
|
3
3
|
describe Rocx::Elements::Break do
|
4
4
|
include ElementTestMacros
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
it_should_use tag: :br, name: "break"
|
7
|
+
|
8
|
+
for_attribute(:clear) do
|
9
|
+
with_value(:all) do
|
10
|
+
it_should_assign_successfully
|
11
|
+
it_should_output "<w:br w:clear=\"all\"/>"
|
9
12
|
end
|
10
13
|
|
11
|
-
|
12
|
-
|
14
|
+
with_value(:left) do
|
15
|
+
it_should_assign_successfully
|
16
|
+
it_should_output "<w:br w:clear=\"left\"/>"
|
13
17
|
end
|
14
|
-
end
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
with_value(:none) do
|
20
|
+
it_should_assign_successfully
|
21
|
+
it_should_output "<w:br w:clear=\"none\"/>"
|
19
22
|
end
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
with_value(:right) do
|
25
|
+
it_should_assign_successfully
|
26
|
+
it_should_output "<w:br w:clear=\"right\"/>"
|
24
27
|
end
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
expect { node.break_type = :weird }.to raise_error(ArgumentError)
|
29
|
+
with_value(:somethingElse) do
|
30
|
+
it_should_raise_an_exception
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
for_attribute(:type) do
|
35
|
+
with_value(:column) do
|
36
|
+
it_should_assign_successfully
|
37
|
+
it_should_output "<w:br w:type=\"column\"/>"
|
35
38
|
end
|
36
39
|
|
37
|
-
|
38
|
-
|
40
|
+
with_value(:page) do
|
41
|
+
it_should_assign_successfully
|
42
|
+
it_should_output "<w:br w:type=\"page\"/>"
|
43
|
+
end
|
39
44
|
|
40
|
-
|
41
|
-
|
42
|
-
|
45
|
+
with_value(:textWrapping) do
|
46
|
+
it_should_assign_successfully
|
47
|
+
it_should_output "<w:br w:type=\"textWrapping\"/>"
|
43
48
|
end
|
44
49
|
|
45
|
-
|
50
|
+
with_value(:somethingElse) do
|
51
|
+
it_should_raise_an_exception
|
52
|
+
end
|
46
53
|
end
|
54
|
+
|
47
55
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Rocx::Elements::ContentPart do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :contentPart, name: "content_part"
|
7
|
+
|
8
|
+
for_attribute(:id) do
|
9
|
+
with_value("rId8") do
|
10
|
+
it_should_assign_successfully
|
11
|
+
it_should_output "<w:contentPart r:id=\"rId8\"/>"
|
12
|
+
end
|
13
|
+
|
14
|
+
with_value("") do
|
15
|
+
it_should_raise_an_exception
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Rocx::Elements::Control do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :control, name: "control"
|
7
|
+
|
8
|
+
for_attribute(:id) do
|
9
|
+
with_value("rId5") do
|
10
|
+
it_should_assign_successfully
|
11
|
+
it_should_output "<w:control r:id=\"rId5\"/>"
|
12
|
+
end
|
13
|
+
|
14
|
+
with_value("") do
|
15
|
+
it_should_raise_an_exception
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
for_attribute(:unique_name) do
|
20
|
+
with_value("CheckBox1") do
|
21
|
+
it_should_assign_successfully
|
22
|
+
it_should_output "<w:control w:name=\"CheckBox1\"/>"
|
23
|
+
end
|
24
|
+
|
25
|
+
with_value("") do
|
26
|
+
it_should_raise_an_exception
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
for_attribute(:shape_id) do
|
31
|
+
with_value("_x0000_s1027") do
|
32
|
+
it_should_assign_successfully
|
33
|
+
it_should_output "<w:control w:shapeid=\"_x0000_s1027\"/>"
|
34
|
+
end
|
35
|
+
|
36
|
+
with_value("") do
|
37
|
+
it_should_raise_an_exception
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Rocx::Elements::DeletedText do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :del, name: "deleted_text"
|
7
|
+
|
8
|
+
for_attribute(:space) do
|
9
|
+
with_value(nil) do
|
10
|
+
it_should_assign_successfully
|
11
|
+
it_should_output "<w:del/>"
|
12
|
+
end
|
13
|
+
|
14
|
+
with_value(:preserve) do
|
15
|
+
it_should_assign_successfully
|
16
|
+
it_should_output "<w:del xml:space=\"preserve\"/>"
|
17
|
+
end
|
18
|
+
|
19
|
+
with_value(:the_final_frontier) do
|
20
|
+
it_should_raise_an_exception
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Rocx::Elements::LastRenderedPageBreak do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :lastRenderedPageBreak, name: "last_rendered_page_break"
|
7
|
+
|
8
|
+
with_no_attributes_set do
|
9
|
+
it_should_output "<w:lastRenderedPageBreak/>", assign: false
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Rocx::Elements::NonbreakingHyphen do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :noBreakHyphen, name: "nonbreaking_hyphen"
|
7
|
+
|
8
|
+
with_no_attributes_set do
|
9
|
+
it_should_output "<w:noBreakHyphen/>", assign: false
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -3,17 +3,19 @@ require "spec_helper"
|
|
3
3
|
describe Rocx::Elements::Paragraph do
|
4
4
|
include ElementTestMacros
|
5
5
|
|
6
|
+
it_should_use tag: :p, name: "paragraph"
|
7
|
+
|
6
8
|
context "with runs" do
|
7
9
|
before(:each) do
|
8
|
-
@
|
9
|
-
|
10
|
-
|
10
|
+
@instance = described_class.new
|
11
|
+
instance.indentation.start = 720
|
12
|
+
instance.indentation.end = -1440
|
11
13
|
run = Rocx::Elements::Run.new
|
12
14
|
run << Rocx::Elements::Text.new("Hey Run 1")
|
13
|
-
|
15
|
+
instance << run
|
14
16
|
run = Rocx::Elements::Run.new
|
15
17
|
run << Rocx::Elements::Text.new("Hey Run 2")
|
16
|
-
|
18
|
+
instance << run
|
17
19
|
end
|
18
20
|
|
19
21
|
it_should_output_correct_xml node_xml: "paragraph_with_runs"
|
@@ -21,8 +23,8 @@ describe Rocx::Elements::Paragraph do
|
|
21
23
|
|
22
24
|
context "without runs" do
|
23
25
|
before(:each) do
|
24
|
-
@
|
25
|
-
|
26
|
+
@instance = described_class.new
|
27
|
+
instance.alignment = :center
|
26
28
|
end
|
27
29
|
|
28
30
|
it_should_output_correct_xml
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Rocx::Elements::Ruby do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :ruby, name: "ruby"
|
7
|
+
|
8
|
+
it_should_have_property :font_size, as_instance_of: :phonetic_guide_font_size, with_value: 1
|
9
|
+
it_should_have_property :base_font_size, as_instance_of: :phonetic_guide_base_font_size, with_value: 1
|
10
|
+
it_should_have_property :font_size_raise, as_instance_of: :phonetic_guide_font_size_raise, with_value: 1
|
11
|
+
it_should_have_property :language, as_instance_of: :phonetic_guide_language, with_value: "ja-JP"
|
12
|
+
it_should_have_property :alignment, as_instance_of: :phonetic_guide_alignment, with_value: :left
|
13
|
+
|
14
|
+
context "for base text" do
|
15
|
+
before(:each) do
|
16
|
+
@instance = described_class.new
|
17
|
+
text = Rocx::Elements::Text.new("Howdy Partner")
|
18
|
+
run = Rocx::Elements::Run.new
|
19
|
+
run << text
|
20
|
+
instance.base = run
|
21
|
+
end
|
22
|
+
|
23
|
+
it_should_output "<w:ruby>\n <w:rt/>\n <w:rubyBase>\n <w:r>\n <w:t>Howdy Partner</w:t>\n </w:r>\n </w:rubyBase>\n </w:ruby>", assign: false
|
24
|
+
end
|
25
|
+
|
26
|
+
context "for base text and ruby text" do
|
27
|
+
before(:each) do
|
28
|
+
@instance = described_class.new
|
29
|
+
text = Rocx::Elements::Text.new("東̄")
|
30
|
+
run = Rocx::Elements::Run.new
|
31
|
+
run.bold = true
|
32
|
+
run << text
|
33
|
+
instance.base = run
|
34
|
+
|
35
|
+
text = Rocx::Elements::Text.new("tō")
|
36
|
+
run = Rocx::Elements::Run.new
|
37
|
+
run.bold = true
|
38
|
+
run << text
|
39
|
+
instance.ruby = run
|
40
|
+
end
|
41
|
+
|
42
|
+
it_should_output "<w:ruby>\n <w:rt>\n <w:r>\n <w:rPr>\n <w:b/>\n </w:rPr>\n <w:t>tō</w:t>\n </w:r>\n </w:rt>\n <w:rubyBase>\n <w:r>\n <w:rPr>\n <w:b/>\n </w:rPr>\n <w:t>東̄</w:t>\n </w:r>\n </w:rubyBase>\n </w:ruby>", assign: false
|
43
|
+
end
|
44
|
+
|
45
|
+
context "with base text, ruby text and properties set" do
|
46
|
+
before(:each) do
|
47
|
+
@instance = described_class.new
|
48
|
+
text = Rocx::Elements::Text.new("東̄")
|
49
|
+
run = Rocx::Elements::Run.new
|
50
|
+
run.bold = true
|
51
|
+
run << text
|
52
|
+
instance.base = run
|
53
|
+
|
54
|
+
text = Rocx::Elements::Text.new("tō")
|
55
|
+
run = Rocx::Elements::Run.new
|
56
|
+
run.bold = true
|
57
|
+
run << text
|
58
|
+
instance.ruby = run
|
59
|
+
|
60
|
+
instance.alignment = :left
|
61
|
+
end
|
62
|
+
|
63
|
+
it_should_output "<w:ruby>\n <w:rubyPr>\n <w:rubyAlign w:val=\"left\"/>\n </w:rubyPr>\n <w:rt>\n <w:r>\n <w:rPr>\n <w:b/>\n </w:rPr>\n <w:t>tō</w:t>\n </w:r>\n </w:rt>\n <w:rubyBase>\n <w:r>\n <w:rPr>\n <w:b/>\n </w:rPr>\n <w:t>東̄</w:t>\n </w:r>\n </w:rubyBase>\n </w:ruby>", assign: false
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
data/spec/elements/run_spec.rb
CHANGED