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/lib/rocx/elements/symbol.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module Rocx
|
2
2
|
module Elements
|
3
|
-
class Symbol <
|
4
|
-
|
5
|
-
|
6
|
-
attribute :font,
|
7
|
-
attribute :
|
3
|
+
class Symbol < Element
|
4
|
+
tag :sym
|
5
|
+
|
6
|
+
attribute :font, expects: :string
|
7
|
+
attribute :character, expects: :hex_digit_4, displays_as: :char
|
8
|
+
|
8
9
|
end
|
9
10
|
end
|
10
11
|
end
|
data/lib/rocx/elements/text.rb
CHANGED
@@ -1,19 +1,26 @@
|
|
1
1
|
module Rocx
|
2
2
|
module Elements
|
3
|
-
class Text <
|
3
|
+
class Text < Element
|
4
4
|
attr_reader :text
|
5
5
|
|
6
|
-
|
7
|
-
namespace :w
|
8
|
-
attribute :space, xml_name: "xml:space", limit_to: [nil, :preserve]
|
6
|
+
tag :t
|
9
7
|
|
10
|
-
|
8
|
+
attribute :space, expects: :valid_space_preserve, namespace: :xml
|
9
|
+
|
10
|
+
VALID_SPACE_PRESERVES = [:preserve, nil]
|
11
|
+
|
12
|
+
def initialize(text=nil)
|
11
13
|
@text = text
|
12
|
-
super args
|
13
14
|
end
|
14
15
|
|
15
16
|
def to_xml(xml)
|
16
|
-
xml[
|
17
|
+
xml["w"].public_send(tag, text, xml_attributes)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def valid_space_preserve(value)
|
23
|
+
valid_in? value, VALID_SPACE_PRESERVES
|
17
24
|
end
|
18
25
|
|
19
26
|
end
|
@@ -1,16 +1,14 @@
|
|
1
1
|
module Rocx
|
2
2
|
module Properties
|
3
3
|
class EastAsianLayout < ComplexProperty
|
4
|
-
include AttributeBuilder
|
5
|
-
|
6
|
-
VALID_BRACKETS = %i(angle curly none round square)
|
7
|
-
|
8
4
|
attribute :combine, expects: :on_or_off
|
9
5
|
attribute :combine_brackets, expects: :valid_bracket
|
10
6
|
attribute :id, expects: :integer
|
11
7
|
attribute :vertical, expects: :on_or_off, displays_as: :vert
|
12
8
|
attribute :vertical_compress, expects: :on_or_off, displays_as: :vertCompress
|
13
9
|
|
10
|
+
VALID_BRACKETS = %i(angle curly none round square)
|
11
|
+
|
14
12
|
private
|
15
13
|
|
16
14
|
def valid_bracket(value)
|
data/lib/rocx/properties/font.rb
CHANGED
@@ -1,17 +1,8 @@
|
|
1
1
|
module Rocx
|
2
2
|
module Properties
|
3
3
|
class Frame < ComplexProperty
|
4
|
-
include AttributeBuilder
|
5
|
-
|
6
4
|
tag :framePr
|
7
5
|
|
8
|
-
VALID_ANCHORS = %i(margin page text)
|
9
|
-
VALID_DROP_CAPS = %i(drop margin none)
|
10
|
-
VALID_HEIGHT_RULES = %i(atLeast auto exact)
|
11
|
-
VALID_RELATIVE_HORIZONTAL_POSITIONS = %i(center inside left outside right)
|
12
|
-
VALID_RELATIVE_VERTICAL_POSITIONS = %i(bottom center inline inside outside top)
|
13
|
-
VALID_WRAPS = %i(around auto none notBeside through tight)
|
14
|
-
|
15
6
|
attribute :anchor_lock, expects: :true_or_false
|
16
7
|
attribute :drop_cap, expects: :valid_drop_cap
|
17
8
|
attribute :height, expects: :positive_integer, displays_as: :h
|
@@ -28,6 +19,13 @@ module Rocx
|
|
28
19
|
attribute :width, expects: :positive_integer, displays_as: :w
|
29
20
|
attribute :wrap, expects: :valid_wrap
|
30
21
|
|
22
|
+
VALID_ANCHORS = %i(margin page text)
|
23
|
+
VALID_DROP_CAPS = %i(drop margin none)
|
24
|
+
VALID_HEIGHT_RULES = %i(atLeast auto exact)
|
25
|
+
VALID_RELATIVE_HORIZONTAL_POSITIONS = %i(center inside left outside right)
|
26
|
+
VALID_RELATIVE_VERTICAL_POSITIONS = %i(bottom center inline inside outside top)
|
27
|
+
VALID_WRAPS = %i(around auto none notBeside through tight)
|
28
|
+
|
31
29
|
private
|
32
30
|
|
33
31
|
def valid_drop_cap(value)
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module Rocx
|
2
2
|
module Properties
|
3
3
|
class Language < ComplexProperty
|
4
|
-
include AttributeBuilder
|
5
|
-
|
6
4
|
tag :lang
|
5
|
+
|
7
6
|
attribute :bidi, expects: :valid_language
|
8
7
|
attribute :east_asia, expects: :valid_language
|
9
8
|
attribute :latin, expects: :valid_language, displays_as: :val
|
@@ -1,12 +1,11 @@
|
|
1
1
|
module Rocx
|
2
2
|
module Properties
|
3
3
|
class ManualWidth < ComplexProperty
|
4
|
-
|
4
|
+
tag :fitText
|
5
5
|
|
6
6
|
attribute :id, expects: :integer
|
7
7
|
attribute :width, expects: :positive_integer, displays_as: :val
|
8
8
|
|
9
|
-
tag :fitText
|
10
9
|
end
|
11
10
|
end
|
12
11
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Rocx
|
2
|
+
module Properties
|
3
|
+
class PhoneticGuideLanguage < ValueProperty
|
4
|
+
tag :lid
|
5
|
+
name "language"
|
6
|
+
|
7
|
+
def valid?
|
8
|
+
value =~ /[a-z]{2}-[A-Z]{2}/
|
9
|
+
end
|
10
|
+
|
11
|
+
def invalid_message
|
12
|
+
"Invalid #{name}: must be a language code (RFC 4646)"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module Rocx
|
2
2
|
module Properties
|
3
3
|
class Underline < ComplexProperty
|
4
|
-
include AttributeBuilder
|
5
|
-
|
6
4
|
tag :u
|
7
5
|
|
8
6
|
VALID_UNDERLINE_TYPES = %i(dash dashDotDotHeavy dashDotHeavy dashedHeavy dashLong dashLongHeavy dotDash dotDotDash dotted dottedHeavy double none single thick wave wavyDouble wavyHeavy words)
|
data/lib/rocx/version.rb
CHANGED
@@ -0,0 +1,84 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Rocx::Elements::AbsolutePositionTab do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :ptab, name: "absolute_position_tab"
|
7
|
+
|
8
|
+
for_attribute(:alignment) do
|
9
|
+
with_value(:center) do
|
10
|
+
it_should_assign_successfully
|
11
|
+
it_should_output "<w:ptab w:alignment=\"center\"/>"
|
12
|
+
end
|
13
|
+
|
14
|
+
with_value(:left) do
|
15
|
+
it_should_assign_successfully
|
16
|
+
it_should_output "<w:ptab w:alignment=\"left\"/>"
|
17
|
+
end
|
18
|
+
|
19
|
+
with_value(:right) do
|
20
|
+
it_should_assign_successfully
|
21
|
+
it_should_output "<w:ptab w:alignment=\"right\"/>"
|
22
|
+
end
|
23
|
+
|
24
|
+
with_value(:somethingElse) do
|
25
|
+
it_should_raise_an_exception
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
for_attribute(:leader) do
|
30
|
+
with_value(:dot) do
|
31
|
+
it_should_assign_successfully
|
32
|
+
it_should_output "<w:ptab w:leader=\"dot\"/>"
|
33
|
+
end
|
34
|
+
|
35
|
+
with_value(:hyphen) do
|
36
|
+
it_should_assign_successfully
|
37
|
+
it_should_output "<w:ptab w:leader=\"hyphen\"/>"
|
38
|
+
end
|
39
|
+
|
40
|
+
with_value(:middleDot) do
|
41
|
+
it_should_assign_successfully
|
42
|
+
it_should_output "<w:ptab w:leader=\"middleDot\"/>"
|
43
|
+
end
|
44
|
+
|
45
|
+
with_value(:none) do
|
46
|
+
it_should_assign_successfully
|
47
|
+
it_should_output "<w:ptab w:leader=\"none\"/>"
|
48
|
+
end
|
49
|
+
|
50
|
+
with_value(:underscore) do
|
51
|
+
it_should_assign_successfully
|
52
|
+
it_should_output "<w:ptab w:leader=\"underscore\"/>"
|
53
|
+
end
|
54
|
+
|
55
|
+
with_value(:somethingElse) do
|
56
|
+
it_should_raise_an_exception
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
for_attribute(:relativeTo) do
|
61
|
+
with_value(:indent) do
|
62
|
+
it_should_assign_successfully
|
63
|
+
it_should_output "<w:ptab w:relativeTo=\"indent\"/>"
|
64
|
+
end
|
65
|
+
|
66
|
+
with_value(:margin) do
|
67
|
+
it_should_assign_successfully
|
68
|
+
it_should_output "<w:ptab w:relativeTo=\"margin\"/>"
|
69
|
+
end
|
70
|
+
|
71
|
+
with_value(:somethingElse) do
|
72
|
+
it_should_raise_an_exception
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
with_no_attributes_set do
|
77
|
+
it_should_output "<w:ptab/>", assign: false
|
78
|
+
end
|
79
|
+
|
80
|
+
with_these_attributes_set(alignment: :center, relativeTo: :margin) do
|
81
|
+
it_should_output "<w:ptab w:alignment=\"center\" w:relativeTo=\"margin\"/>", assign: false
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Rocx::Elements::BidiEmbed do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :dir, name: "bidi_embed"
|
7
|
+
|
8
|
+
for_attribute(:direction) do
|
9
|
+
with_value(:rtl) do
|
10
|
+
it_should_assign_successfully
|
11
|
+
it_should_output "<w:dir w:val=\"rtl\"/>"
|
12
|
+
end
|
13
|
+
|
14
|
+
with_value(:ltr) do
|
15
|
+
it_should_assign_successfully
|
16
|
+
it_should_output "<w:dir w:val=\"ltr\"/>"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "with children" do
|
21
|
+
before(:each) do
|
22
|
+
@instance = described_class.new
|
23
|
+
text = Rocx::Elements::Text.new("Smucker's Preserves")
|
24
|
+
run = Rocx::Elements::Run.new
|
25
|
+
run << text
|
26
|
+
instance << run
|
27
|
+
end
|
28
|
+
|
29
|
+
it_should_output "<w:dir>\n <w:r>\n <w:t>Smucker's Preserves</w:t>\n </w:r>\n </w:dir>", assign: false
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Rocx::Elements::BidiOverride do
|
4
|
+
include ElementTestMacros
|
5
|
+
|
6
|
+
it_should_use tag: :bdo, name: "bidi_override"
|
7
|
+
|
8
|
+
for_attribute(:direction) do
|
9
|
+
with_value(:rtl) do
|
10
|
+
it_should_assign_successfully
|
11
|
+
it_should_output "<w:bdo w:val=\"rtl\"/>"
|
12
|
+
end
|
13
|
+
|
14
|
+
with_value(:ltr) do
|
15
|
+
it_should_assign_successfully
|
16
|
+
it_should_output "<w:bdo w:val=\"ltr\"/>"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context "with children" do
|
21
|
+
before(:each) do
|
22
|
+
@instance = described_class.new
|
23
|
+
text = Rocx::Elements::Text.new("Smucker's Preserves")
|
24
|
+
run = Rocx::Elements::Run.new
|
25
|
+
run << text
|
26
|
+
instance << run
|
27
|
+
end
|
28
|
+
|
29
|
+
it_should_output "<w:bdo>\n <w:r>\n <w:t>Smucker's Preserves</w:t>\n </w:r>\n </w:bdo>", assign: false
|
30
|
+
end
|
31
|
+
end
|