thinreports 0.8.2 → 0.9.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/.github/CONTRIBUTING.md +2 -0
- data/.travis.yml +3 -3
- data/CHANGELOG.md +98 -1
- data/README.md +0 -9
- data/Rakefile +1 -2
- data/examples/character_spacing/character_spacing.tlf +293 -1
- data/examples/dynamic_image/dynamic_image.tlf +661 -1
- data/examples/dynamic_style/dynamic_style.rb +4 -4
- data/examples/dynamic_style/dynamic_style.tlf +1835 -1
- data/examples/dynamic_style/dynamic_style_in_list.tlf +344 -1
- data/examples/eudc/eudc.tlf +180 -1
- data/examples/hidden_shapes/hidden_shapes.tlf +449 -1
- data/examples/list_events/list_events.rb +1 -28
- data/examples/list_events/list_events.tlf +361 -0
- data/examples/list_manual_generation/list_manual_generation.tlf +132 -1
- data/examples/list_page_number/list_page_number.tlf +254 -1
- data/examples/page_number/page_number.tlf +215 -1
- data/examples/palleted_png/palleted_png.rb +2 -0
- data/examples/palleted_png/palleted_png.tlf +47 -1
- data/examples/password_setting/password_setting.tlf +45 -1
- data/examples/report_callbacks/report_callbacks.rb +1 -18
- data/examples/report_callbacks/report_callbacks.tlf +147 -1
- data/examples/single_line_tblock/single_line_tblock.tlf +170 -1
- data/examples/tblock_overflow/tblock_overflow.tlf +538 -1
- data/examples/tblock_styles/font_size.tlf +383 -1
- data/examples/tblock_styles/tblock_styles.tlf +889 -1
- data/examples/text_align/text_align.tlf +241 -1
- data/examples/typeB_page_size/B4_ISO.tlf +45 -1
- data/examples/typeB_page_size/B4_JIS.tlf +45 -1
- data/examples/word_wrap/word_wrap.tlf +297 -1
- data/lib/thinreports.rb +0 -1
- data/lib/thinreports/config.rb +3 -0
- data/lib/thinreports/core/errors.rb +0 -3
- data/lib/thinreports/core/format/base.rb +4 -4
- data/lib/thinreports/core/shape.rb +1 -9
- data/lib/thinreports/core/shape/basic.rb +3 -3
- data/lib/thinreports/core/shape/basic/block_format.rb +1 -1
- data/lib/thinreports/core/shape/basic/format.rb +2 -14
- data/lib/thinreports/core/shape/basic/internal.rb +2 -2
- data/lib/thinreports/core/shape/image_block.rb +3 -3
- data/lib/thinreports/core/shape/image_block/format.rb +0 -2
- data/lib/thinreports/core/shape/image_block/internal.rb +1 -1
- data/lib/thinreports/core/shape/list.rb +3 -7
- data/lib/thinreports/core/shape/list/format.rb +37 -24
- data/lib/thinreports/core/shape/list/manager.rb +1 -36
- data/lib/thinreports/core/shape/list/page.rb +0 -15
- data/lib/thinreports/core/shape/list/page_state.rb +1 -1
- data/lib/thinreports/core/shape/list/section_format.rb +14 -12
- data/lib/thinreports/core/shape/list/section_internal.rb +4 -7
- data/lib/thinreports/core/shape/manager/format.rb +0 -2
- data/lib/thinreports/core/shape/manager/internal.rb +1 -1
- data/lib/thinreports/core/shape/page_number.rb +1 -1
- data/lib/thinreports/core/shape/page_number/format.rb +9 -6
- data/lib/thinreports/core/shape/page_number/interface.rb +1 -1
- data/lib/thinreports/core/shape/page_number/internal.rb +2 -6
- data/lib/thinreports/core/shape/style/base.rb +11 -13
- data/lib/thinreports/core/shape/style/basic.rb +4 -4
- data/lib/thinreports/core/shape/style/graphic.rb +4 -10
- data/lib/thinreports/core/shape/style/text.rb +36 -69
- data/lib/thinreports/core/shape/text.rb +3 -3
- data/lib/thinreports/core/shape/text/format.rb +3 -13
- data/lib/thinreports/core/shape/text/internal.rb +2 -2
- data/lib/thinreports/core/shape/text_block.rb +3 -3
- data/lib/thinreports/core/shape/text_block/format.rb +9 -6
- data/lib/thinreports/core/shape/text_block/interface.rb +7 -7
- data/lib/thinreports/core/shape/text_block/internal.rb +1 -1
- data/lib/thinreports/generator/pdf.rb +0 -1
- data/lib/thinreports/generator/pdf/document.rb +2 -2
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +25 -51
- data/lib/thinreports/generator/pdf/document/draw_template_items.rb +66 -0
- data/lib/thinreports/generator/pdf/document/font.rb +3 -8
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +97 -77
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +18 -13
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +17 -12
- data/lib/thinreports/generator/pdf/document/page.rb +1 -1
- data/lib/thinreports/generator/pdf/drawer/list.rb +5 -1
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +1 -4
- data/lib/thinreports/generator/pdf/drawer/page.rb +9 -9
- data/lib/thinreports/layout.rb +3 -3
- data/lib/thinreports/layout/base.rb +0 -16
- data/lib/thinreports/layout/format.rb +38 -57
- data/lib/thinreports/layout/legacy_schema.rb +354 -0
- data/lib/thinreports/layout/version.rb +1 -1
- data/lib/thinreports/report.rb +0 -1
- data/lib/thinreports/report/base.rb +3 -17
- data/lib/thinreports/report/internal.rb +13 -55
- data/lib/thinreports/report/page.rb +1 -1
- data/lib/thinreports/version.rb +1 -1
- data/test/data/legacy_layout/all-items.tlf +1 -0
- data/test/schema_helper.rb +121 -0
- data/test/test_helper.rb +13 -50
- data/test/unit/core/format/test_base.rb +35 -31
- data/test/unit/core/shape/base/test_internal.rb +1 -1
- data/test/unit/core/shape/basic/test_block_format.rb +23 -0
- data/test/unit/core/shape/basic/{test_basic_interface.rb → test_block_interface.rb} +1 -1
- data/test/unit/core/shape/basic/{test_basic_internal.rb → test_block_internal.rb} +4 -7
- data/test/unit/core/shape/basic/test_format.rb +25 -47
- data/test/unit/core/shape/basic/test_interface.rb +5 -5
- data/test/unit/core/shape/basic/test_internal.rb +6 -11
- data/test/unit/core/shape/image_block/test_interface.rb +5 -5
- data/test/unit/core/shape/image_block/test_internal.rb +2 -2
- data/test/unit/core/shape/list/test_format.rb +86 -44
- data/test/unit/core/shape/list/test_manager.rb +10 -65
- data/test/unit/core/shape/list/test_page.rb +10 -61
- data/test/unit/core/shape/list/test_page_state.rb +1 -1
- data/test/unit/core/shape/list/test_section_format.rb +19 -28
- data/test/unit/core/shape/list/test_section_interface.rb +14 -6
- data/test/unit/core/shape/list/test_section_internal.rb +17 -23
- data/test/unit/core/shape/manager/test_format.rb +1 -1
- data/test/unit/core/shape/manager/test_internal.rb +59 -98
- data/test/unit/core/shape/manager/test_target.rb +21 -30
- data/test/unit/core/shape/page_number/test_format.rb +34 -52
- data/test/unit/core/shape/page_number/test_interface.rb +1 -1
- data/test/unit/core/shape/page_number/test_internal.rb +2 -2
- data/test/unit/core/shape/styles/test_base.rb +16 -41
- data/test/unit/core/shape/styles/test_basic.rb +7 -7
- data/test/unit/core/shape/styles/test_graphic.rb +27 -32
- data/test/unit/core/shape/styles/test_text.rb +68 -311
- data/test/unit/core/shape/text/test_format.rb +30 -59
- data/test/unit/core/shape/text/test_internal.rb +5 -5
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +13 -13
- data/test/unit/core/shape/text_block/test_format.rb +145 -146
- data/test/unit/core/shape/text_block/test_interface.rb +9 -9
- data/test/unit/core/shape/text_block/test_internal.rb +9 -9
- data/test/unit/core/test_shape.rb +19 -31
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +112 -122
- data/test/unit/generator/pdf/document/graphics/test_basic.rb +45 -0
- data/test/unit/generator/pdf/document/graphics/test_image.rb +5 -5
- data/test/unit/generator/pdf/document/test_font.rb +4 -10
- data/test/unit/generator/pdf/document/test_page.rb +13 -11
- data/test/unit/generator/pdf/document/test_parse_color.rb +5 -5
- data/test/unit/generator/test_base.rb +5 -5
- data/test/unit/generator/test_configuration.rb +4 -8
- data/test/unit/generator/test_pdf.rb +3 -2
- data/test/unit/layout/test_base.rb +16 -22
- data/test/unit/layout/test_format.rb +66 -86
- data/test/unit/layout/test_legacy_schema.rb +587 -0
- data/test/unit/layout/test_version.rb +20 -20
- data/test/unit/report/test_base.rb +32 -45
- data/test/unit/report/test_internal.rb +43 -99
- data/test/unit/test_config.rb +4 -2
- data/test/unit/test_layout.rb +1 -1
- metadata +20 -48
- data/examples/list_events/list_events_0_7_7.tlf +0 -1
- data/examples/list_events/list_events_0_8.tlf +0 -1
- data/lib/thinreports/core/events.rb +0 -69
- data/lib/thinreports/core/format/builder.rb +0 -62
- data/lib/thinreports/core/shape/list/configuration.rb +0 -54
- data/lib/thinreports/core/shape/list/events.rb +0 -47
- data/lib/thinreports/core/shape/list/store.rb +0 -33
- data/lib/thinreports/generator/pdf/configuration.rb +0 -33
- data/lib/thinreports/generator/pdf/document/parse_svg.rb +0 -104
- data/lib/thinreports/layout/configuration.rb +0 -29
- data/test/data/layout_block.tlf +0 -1
- data/test/data/layout_list.tlf +0 -1
- data/test/data/layout_list_noheader.tlf +0 -1
- data/test/data/layout_text1.tlf +0 -1
- data/test/data/layout_text2.tlf +0 -1
- data/test/unit/core/format/test_builder.rb +0 -109
- data/test/unit/core/shape/basic/test_basic_format.rb +0 -30
- data/test/unit/core/shape/image_block/test_format.rb +0 -58
- data/test/unit/core/shape/list/test_configuration.rb +0 -69
- data/test/unit/core/shape/list/test_events.rb +0 -36
- data/test/unit/core/shape/list/test_store.rb +0 -41
- data/test/unit/core/test_events.rb +0 -93
- data/test/unit/generator/pdf/document/test_draw_shape.rb +0 -44
- data/test/unit/generator/pdf/test_configuration.rb +0 -31
- data/test/unit/layout/test_configuration.rb +0 -21
- data/test/unit/report/test_events.rb +0 -22
|
@@ -28,51 +28,42 @@ class Thinreports::Core::Shape::Manager::TestTarget < Minitest::Test
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def create_manager
|
|
31
|
-
report =
|
|
31
|
+
report = Thinreports::Report.new layout: layout_file.path
|
|
32
32
|
layout = report.layout
|
|
33
33
|
|
|
34
|
-
layout.format.shapes[:text_block1] = create_shape_format('s-tblock', 'text_block1')
|
|
35
|
-
layout.format.shapes[:text_block2] = create_shape_format('s-tblock', 'text_block2')
|
|
36
|
-
layout.format.shapes[:image_block] = create_shape_format('s-iblock', 'image_block')
|
|
37
|
-
layout.format.shapes[:rectangle] = create_shape_format('s-rect', 'rectangle')
|
|
38
|
-
layout.format.shapes[:line] = create_shape_format('s-line', 'line')
|
|
39
|
-
layout.format.shapes[:list1] = create_shape_format('s-list', 'list1')
|
|
40
|
-
layout.format.shapes[:list2] = create_shape_format('s-list', 'list2')
|
|
41
|
-
layout.format.shapes[:default] = create_shape_format('s-list', 'default')
|
|
42
|
-
|
|
43
34
|
TestManager.new(report, layout)
|
|
44
35
|
end
|
|
45
36
|
|
|
46
37
|
def test_shorthand_for_finding_item
|
|
47
38
|
manager = create_manager
|
|
48
39
|
|
|
49
|
-
text_block1 = manager[:
|
|
40
|
+
text_block1 = manager[:text_block]
|
|
50
41
|
text_block1.value = 'block1'
|
|
51
42
|
|
|
52
|
-
assert_instance_of Shape::TextBlock::Interface, manager[:
|
|
43
|
+
assert_instance_of Shape::TextBlock::Interface, manager[:text_block]
|
|
53
44
|
assert_instance_of Shape::ImageBlock::Interface, manager[:image_block]
|
|
54
|
-
assert_instance_of Shape::Basic::Interface, manager[:
|
|
45
|
+
assert_instance_of Shape::Basic::Interface, manager[:rect_with_id]
|
|
55
46
|
|
|
56
47
|
assert_raises Thinreports::Errors::UnknownItemId do
|
|
57
48
|
manager[:unknown_id]
|
|
58
49
|
end
|
|
59
50
|
|
|
60
51
|
assert_raises Thinreports::Errors::UnknownItemId do
|
|
61
|
-
manager[:
|
|
52
|
+
manager[:default]
|
|
62
53
|
end
|
|
63
54
|
end
|
|
64
55
|
|
|
65
56
|
def test_shorthand_for_setting_value_to_block
|
|
66
57
|
manager = create_manager
|
|
67
58
|
|
|
68
|
-
manager[:
|
|
69
|
-
assert_equal 'value of text block1', manager.item(:
|
|
59
|
+
manager[:text_block] = 'value of text block1'
|
|
60
|
+
assert_equal 'value of text block1', manager.item(:text_block).value
|
|
70
61
|
|
|
71
62
|
manager[:image_block] = '/path/to/image.png'
|
|
72
63
|
assert_equal '/path/to/image.png', manager.item(:image_block).src
|
|
73
64
|
|
|
74
|
-
assert_raises(NoMethodError) { manager[:
|
|
75
|
-
assert_raises(Thinreports::Errors::UnknownItemId) { manager[:
|
|
65
|
+
assert_raises(NoMethodError) { manager[:rect_with_id] = 'value' }
|
|
66
|
+
assert_raises(Thinreports::Errors::UnknownItemId) { manager[:default] = 'value' }
|
|
76
67
|
end
|
|
77
68
|
|
|
78
69
|
def test_manager_should_return_instance_of_ManagerInternal
|
|
@@ -80,11 +71,11 @@ class Thinreports::Core::Shape::Manager::TestTarget < Minitest::Test
|
|
|
80
71
|
end
|
|
81
72
|
|
|
82
73
|
def test_item_should_properly_return_shape_with_the_specified_Symbol_id
|
|
83
|
-
assert_equal create_manager.item(:
|
|
74
|
+
assert_equal create_manager.item(:text_block).id, 'text_block'
|
|
84
75
|
end
|
|
85
76
|
|
|
86
77
|
def test_item_should_properly_return_shape_with_the_specified_String_id
|
|
87
|
-
assert_equal create_manager.item('
|
|
78
|
+
assert_equal create_manager.item('text_block').id, 'text_block'
|
|
88
79
|
end
|
|
89
80
|
|
|
90
81
|
def test_item_should_raise_when_the_shape_with_the_specified_id_is_not_found
|
|
@@ -95,27 +86,27 @@ class Thinreports::Core::Shape::Manager::TestTarget < Minitest::Test
|
|
|
95
86
|
|
|
96
87
|
def test_item_should_set_an_shape_as_argument_when_a_block_is_given
|
|
97
88
|
id = nil
|
|
98
|
-
create_manager.item(:
|
|
99
|
-
assert_equal id, '
|
|
89
|
+
create_manager.item(:text_block) {|s| id = s.id }
|
|
90
|
+
assert_equal id, 'text_block'
|
|
100
91
|
end
|
|
101
92
|
|
|
102
93
|
def test_item_should_raise_when_type_of_shape_with_the_specified_id_is_list
|
|
103
94
|
assert_raises Thinreports::Errors::UnknownItemId do
|
|
104
|
-
create_manager.item(:
|
|
95
|
+
create_manager.item(:default)
|
|
105
96
|
end
|
|
106
97
|
end
|
|
107
98
|
|
|
108
99
|
def test_list_should_properly_return_list_with_the_specified_Symbol_id
|
|
109
|
-
assert_equal create_manager.list(:
|
|
100
|
+
assert_equal create_manager.list(:default).id, 'default'
|
|
110
101
|
end
|
|
111
102
|
|
|
112
103
|
def test_list_should_properly_return_list_with_the_specified_String_id
|
|
113
|
-
assert_equal create_manager.list('
|
|
104
|
+
assert_equal create_manager.list('default').id, 'default'
|
|
114
105
|
end
|
|
115
106
|
|
|
116
107
|
def test_list_should_raise_when_type_of_shape_with_the_specified_id_is_not_list
|
|
117
108
|
assert_raises Thinreports::Errors::UnknownItemId do
|
|
118
|
-
create_manager.list(:
|
|
109
|
+
create_manager.list(:text_block)
|
|
119
110
|
end
|
|
120
111
|
end
|
|
121
112
|
|
|
@@ -125,17 +116,17 @@ class Thinreports::Core::Shape::Manager::TestTarget < Minitest::Test
|
|
|
125
116
|
|
|
126
117
|
def test_values_should_properly_set_values_to_shapes_with_specified_id
|
|
127
118
|
manager = create_manager
|
|
128
|
-
manager.values(
|
|
119
|
+
manager.values(text_block: 1000)
|
|
129
120
|
|
|
130
|
-
assert_equal
|
|
121
|
+
assert_equal manager.item(:text_block).value, 1000
|
|
131
122
|
end
|
|
132
123
|
|
|
133
124
|
def test_item_exists_asker_should_return_true_when_shape_with_specified_Symbol_id_is_found
|
|
134
|
-
assert_equal create_manager.item_exists?(:
|
|
125
|
+
assert_equal create_manager.item_exists?(:text_block), true
|
|
135
126
|
end
|
|
136
127
|
|
|
137
128
|
def test_item_exists_asker_should_return_true_when_shape_with_specified_String_id_is_found
|
|
138
|
-
assert_equal create_manager.item_exists?('
|
|
129
|
+
assert_equal create_manager.item_exists?('text_block'), true
|
|
139
130
|
end
|
|
140
131
|
|
|
141
132
|
def test_item_exists_asker_should_return_false_when_shape_with_specified_id_not_found
|
|
@@ -5,69 +5,51 @@ require 'test_helper'
|
|
|
5
5
|
class Thinreports::Core::Shape::PageNumber::TestFormat < Minitest::Test
|
|
6
6
|
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"id" => "goog_939685354",
|
|
28
|
-
"fill" => "#000000",
|
|
29
|
-
"fill-opacity" => "1",
|
|
30
|
-
"font-size" => "18",
|
|
31
|
-
"font-family" => "Helvetica",
|
|
32
|
-
"font-weight" => "normal",
|
|
33
|
-
"font-style" => "normal",
|
|
34
|
-
"text-anchor" => "middle",
|
|
35
|
-
"text-decoration" => "none"
|
|
36
|
-
}
|
|
8
|
+
PAGE_NUMBER_FORMAT = {
|
|
9
|
+
'id' => '',
|
|
10
|
+
'type' => 'page-number',
|
|
11
|
+
'display' => true,
|
|
12
|
+
'x' => 100.0,
|
|
13
|
+
'y' => 200.0,
|
|
14
|
+
'width' => 300.0,
|
|
15
|
+
'height' => 400.0,
|
|
16
|
+
'format' => '{page} / {total}',
|
|
17
|
+
'target' => '',
|
|
18
|
+
'style' => {
|
|
19
|
+
'overflow' => 'truncate',
|
|
20
|
+
'letter-spacing' => 'normal',
|
|
21
|
+
'color' => '#000000',
|
|
22
|
+
'font-size' => 18,
|
|
23
|
+
'font-family' => ['Helvetica'],
|
|
24
|
+
'line-height' => 60,
|
|
25
|
+
'line-height-ratio' => 1.5,
|
|
26
|
+
'text-align' => 'left'
|
|
37
27
|
}
|
|
38
28
|
}
|
|
39
29
|
|
|
40
|
-
|
|
30
|
+
PageNumber = Thinreports::Core::Shape::PageNumber
|
|
41
31
|
|
|
42
|
-
def
|
|
43
|
-
Format.new(
|
|
44
|
-
end
|
|
32
|
+
def test_attribute_readers
|
|
33
|
+
format = PageNumber::Format.new(PAGE_NUMBER_FORMAT)
|
|
45
34
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
flunk exception_details(e, 'Failed to build')
|
|
35
|
+
assert_equal 'truncate', format.overflow
|
|
36
|
+
assert_equal '', format.target
|
|
37
|
+
assert_equal '{page} / {total}', format.default_format
|
|
50
38
|
end
|
|
51
39
|
|
|
52
40
|
def test_id
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
pageno = format('id' => '')
|
|
57
|
-
assert_equal pageno.id, '__pageno1'
|
|
58
|
-
assert_same pageno.id, pageno.id
|
|
59
|
-
end
|
|
41
|
+
format = PageNumber::Format.new(PAGE_NUMBER_FORMAT)
|
|
42
|
+
assert_match(/^__pageno\d+$/, format.id)
|
|
60
43
|
|
|
61
|
-
|
|
62
|
-
assert_equal format.
|
|
44
|
+
format = PageNumber::Format.new(PAGE_NUMBER_FORMAT.merge('id' => 'foo'))
|
|
45
|
+
assert_equal 'foo', format.id
|
|
63
46
|
end
|
|
64
47
|
|
|
65
|
-
def
|
|
66
|
-
|
|
67
|
-
assert_equal
|
|
68
|
-
end
|
|
48
|
+
def test_for_report?
|
|
49
|
+
format_for_report = PageNumber::Format.new(PAGE_NUMBER_FORMAT)
|
|
50
|
+
assert_equal true, format_for_report.for_report?
|
|
69
51
|
|
|
70
|
-
|
|
71
|
-
assert_equal
|
|
52
|
+
format_for_list = PageNumber::Format.new(PAGE_NUMBER_FORMAT.merge('target' => 'target_list_id'))
|
|
53
|
+
assert_equal false, format_for_list.for_report?
|
|
72
54
|
end
|
|
73
55
|
end
|
|
@@ -8,7 +8,7 @@ class Thinreports::Core::Shape::PageNumber::TestInterface < Minitest::Test
|
|
|
8
8
|
PageNumber = Thinreports::Core::Shape::PageNumber
|
|
9
9
|
|
|
10
10
|
def create_pageno(format = {})
|
|
11
|
-
report =
|
|
11
|
+
report = Thinreports::Report.new layout: layout_file.path
|
|
12
12
|
parent = report.start_new_page
|
|
13
13
|
|
|
14
14
|
PageNumber::Interface.new parent, PageNumber::Format.new(format)
|
|
@@ -8,7 +8,7 @@ class Thinreports::Core::Shape::PageNumber::TestInternal < Minitest::Test
|
|
|
8
8
|
PageNumber = Thinreports::Core::Shape::PageNumber
|
|
9
9
|
|
|
10
10
|
def setup
|
|
11
|
-
@report =
|
|
11
|
+
@report = Thinreports::Report.new layout: layout_file.path
|
|
12
12
|
@report.start_new_page
|
|
13
13
|
end
|
|
14
14
|
|
|
@@ -56,7 +56,7 @@ class Thinreports::Core::Shape::PageNumber::TestInternal < Minitest::Test
|
|
|
56
56
|
|
|
57
57
|
def test_type_of
|
|
58
58
|
pageno = init_pageno
|
|
59
|
-
assert pageno.type_of?(
|
|
59
|
+
assert pageno.type_of?('page-number')
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def test_style
|
|
@@ -8,17 +8,17 @@ class Thinreports::Core::Shape::Style::TestBase < Minitest::Test
|
|
|
8
8
|
# Alias
|
|
9
9
|
Style = Thinreports::Core::Shape::Style::Base
|
|
10
10
|
|
|
11
|
-
def create_basic_format(
|
|
12
|
-
Thinreports::Core::Shape::Basic::Format.new('
|
|
11
|
+
def create_basic_format(base_style = {})
|
|
12
|
+
Thinreports::Core::Shape::Basic::Format.new('style' => base_style)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
def create_style(
|
|
16
|
-
Style.new(create_basic_format(
|
|
15
|
+
def create_style(base_style = {})
|
|
16
|
+
Style.new(create_basic_format(base_style))
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
def create_new_style(
|
|
19
|
+
def create_new_style(base_style = {}, &block)
|
|
20
20
|
klass = ::Class.new(Style, &block)
|
|
21
|
-
klass.new(create_basic_format(
|
|
21
|
+
klass.new(create_basic_format(base_style))
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def test_self_style_reader_should_properly_define_a_reading_method
|
|
@@ -96,41 +96,6 @@ class Thinreports::Core::Shape::Style::TestBase < Minitest::Test
|
|
|
96
96
|
assert_equal style.styles['hoge'], 'hoge_style'
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
-
def test_finalized_svg_attributes_should_return_the_Hash_of_having_combined_styles_and_base
|
|
100
|
-
style = create_style('hoge' => 'base_hoge_style',
|
|
101
|
-
'foo' => 'base_foo_style')
|
|
102
|
-
style.write_internal_style('hoge', 'modified_hoge_style')
|
|
103
|
-
|
|
104
|
-
assert_equal style.finalized_svg_attributes.values_at('hoge', 'foo'),
|
|
105
|
-
['modified_hoge_style', 'base_foo_style']
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def test_finalized_svg_attributes_should_return_a_base_when_styles_is_empty
|
|
109
|
-
style = create_style
|
|
110
|
-
assert_equal style.finalized_svg_attributes, style.instance_variable_get(:@base_styles)
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def test_finalized_svg_attributes_should_return_a_cloned_base_when_styles_is_empty
|
|
114
|
-
style = create_style
|
|
115
|
-
refute_same style.finalized_svg_attributes, style.instance_variable_get(:@base_styles)
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
def test_finalized_svg_attributes_should_return_same_value_constantly
|
|
119
|
-
style = create_style('hoge' => 'hoge_style')
|
|
120
|
-
style.write_internal_style('foo', 'foo_style')
|
|
121
|
-
|
|
122
|
-
assert_same style.finalized_svg_attributes,
|
|
123
|
-
style.finalized_svg_attributes
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def test_svg_attrs_should_operate_like_a_finalized_svg_attributes
|
|
127
|
-
style = create_style('hoge' => 'hoge_style',
|
|
128
|
-
'foo' => 'foo_style')
|
|
129
|
-
style.write_internal_style('foo', 'overwrite_foo_style')
|
|
130
|
-
|
|
131
|
-
assert_same style.finalized_svg_attributes, style.svg_attrs
|
|
132
|
-
end
|
|
133
|
-
|
|
134
99
|
def test_has_style_asker_should_return_true_when_specified_style_method_is_accessible
|
|
135
100
|
style = create_new_style {
|
|
136
101
|
style_accessible :hoge, :foo
|
|
@@ -213,4 +178,14 @@ class Thinreports::Core::Shape::Style::TestBase < Minitest::Test
|
|
|
213
178
|
|
|
214
179
|
assert_equal style.identifier, style.styles.hash.to_s
|
|
215
180
|
end
|
|
181
|
+
|
|
182
|
+
def test_finalized_styles
|
|
183
|
+
base_styles = { 'foo' => 'default foo', 'bar' => 'default bar' }
|
|
184
|
+
|
|
185
|
+
style = create_style(base_styles)
|
|
186
|
+
style.write_internal_style('foo', 'new foo')
|
|
187
|
+
|
|
188
|
+
assert_equal({ 'foo' => 'new foo', 'bar' => 'default bar' }, style.finalized_styles)
|
|
189
|
+
assert_same style.finalized_styles, style.finalized_styles
|
|
190
|
+
end
|
|
216
191
|
end
|
|
@@ -4,21 +4,21 @@ require 'test_helper'
|
|
|
4
4
|
|
|
5
5
|
class Thinreports::Core::Shape::Style::TestBasic < Minitest::Test
|
|
6
6
|
include Thinreports::TestHelper
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
def create_basic_style(format_config = {})
|
|
9
9
|
format = Thinreports::Core::Shape::Basic::Format.new(format_config)
|
|
10
10
|
Thinreports::Core::Shape::Style::Basic.new(format)
|
|
11
11
|
end
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
def test_visible_should_return_visibility_of_format_as_default
|
|
14
|
-
style = create_basic_style('display' =>
|
|
14
|
+
style = create_basic_style('display' => false)
|
|
15
15
|
assert_equal style.visible, false
|
|
16
16
|
end
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
def test_visible_should_properly_set_visibility
|
|
19
|
-
style = create_basic_style('display' =>
|
|
19
|
+
style = create_basic_style('display' => false)
|
|
20
20
|
style.visible = true
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
assert_equal style.visible, true
|
|
23
23
|
end
|
|
24
|
-
end
|
|
24
|
+
end
|
|
@@ -5,51 +5,46 @@ require 'test_helper'
|
|
|
5
5
|
class Thinreports::Core::Shape::Style::TestGraphic < Minitest::Test
|
|
6
6
|
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
|
-
def
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
end
|
|
8
|
+
def test_border_color
|
|
9
|
+
style = create_graphic_style('border-color' => 'red')
|
|
10
|
+
assert_equal 'red', style.border_color
|
|
12
11
|
|
|
13
|
-
def test_border_color_should_properly_set_to_internal_styles_as_stroke_style
|
|
14
|
-
style = create_graphic_style
|
|
15
12
|
style.border_color = '#ff0000'
|
|
16
|
-
|
|
17
|
-
assert_equal
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def test_border_width_should_properly_set_to_internal_styles_as_stroke_width_style
|
|
21
|
-
style = create_graphic_style
|
|
22
|
-
style.border_width = 1
|
|
23
|
-
|
|
24
|
-
assert_equal style.styles['stroke-width'], 1
|
|
13
|
+
assert_equal '#ff0000', style.styles['border-color']
|
|
14
|
+
assert_equal '#ff0000', style.border_color
|
|
25
15
|
end
|
|
26
16
|
|
|
27
|
-
def
|
|
28
|
-
style = create_graphic_style
|
|
29
|
-
style.border_width
|
|
17
|
+
def test_border_width
|
|
18
|
+
style = create_graphic_style('border-width' => 2.0)
|
|
19
|
+
assert_equal 2.0, style.border_width
|
|
30
20
|
|
|
31
|
-
|
|
21
|
+
style.border_width = 10.9
|
|
22
|
+
assert_equal 10.9, style.styles['border-width']
|
|
23
|
+
assert_equal 10.9, style.border_width
|
|
32
24
|
end
|
|
33
25
|
|
|
34
|
-
def
|
|
35
|
-
style = create_graphic_style
|
|
36
|
-
|
|
26
|
+
def test_fill_color
|
|
27
|
+
style = create_graphic_style('fill-color' => '#0000ff')
|
|
28
|
+
assert_equal '#0000ff', style.fill_color
|
|
37
29
|
|
|
38
|
-
|
|
30
|
+
style.fill_color = 'blue'
|
|
31
|
+
assert_equal 'blue', style.styles['fill-color']
|
|
32
|
+
assert_equal 'blue', style.fill_color
|
|
39
33
|
end
|
|
40
34
|
|
|
41
|
-
def
|
|
42
|
-
style = create_graphic_style
|
|
43
|
-
style.
|
|
44
|
-
style.border_color = '#ff0000'
|
|
35
|
+
def test_border
|
|
36
|
+
style = create_graphic_style('border-color' => 'red', 'border-width' => 1)
|
|
37
|
+
assert_equal [1, 'red'], style.border
|
|
45
38
|
|
|
46
|
-
|
|
39
|
+
style.border = [2.0, '#ff0000']
|
|
40
|
+
assert_equal 2.0, style.styles['border-width']
|
|
41
|
+
assert_equal '#ff0000', style.styles['border-color']
|
|
47
42
|
end
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
style = create_graphic_style
|
|
51
|
-
style.border = [5, '#000000']
|
|
44
|
+
private
|
|
52
45
|
|
|
53
|
-
|
|
46
|
+
def create_graphic_style(default_style = {})
|
|
47
|
+
format = Thinreports::Core::Shape::Basic::Format.new('style' => default_style)
|
|
48
|
+
Thinreports::Core::Shape::Style::Graphic.new(format)
|
|
54
49
|
end
|
|
55
50
|
end
|