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
|
@@ -6,7 +6,7 @@ class Thinreports::Core::Shape::Base::TestInternal < Minitest::Test
|
|
|
6
6
|
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
8
|
def setup
|
|
9
|
-
@report = Thinreports::Report.new layout:
|
|
9
|
+
@report = Thinreports::Report.new layout: layout_file.path
|
|
10
10
|
@report.start_new_page
|
|
11
11
|
end
|
|
12
12
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::Basic::TestBlockFormat < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
|
+
|
|
8
|
+
BLOCK_FORMAT = {
|
|
9
|
+
'value' => 'default value',
|
|
10
|
+
'x' => 100.0,
|
|
11
|
+
'y' => 200.0,
|
|
12
|
+
'width' => 300.0,
|
|
13
|
+
'height' => 400.0
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Basic = Thinreports::Core::Shape::Basic
|
|
17
|
+
|
|
18
|
+
def test_attribute_readers
|
|
19
|
+
format = Basic::BlockFormat.new(BLOCK_FORMAT)
|
|
20
|
+
|
|
21
|
+
assert_equal 'default value', format.value
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -8,7 +8,7 @@ class Thinreports::Core::Shape::Basic::TestBlockInterface < Minitest::Test
|
|
|
8
8
|
Basic = Thinreports::Core::Shape::Basic
|
|
9
9
|
|
|
10
10
|
def setup
|
|
11
|
-
report = Thinreports::Report.new layout:
|
|
11
|
+
report = Thinreports::Report.new layout: layout_file.path
|
|
12
12
|
parent = report.start_new_page
|
|
13
13
|
|
|
14
14
|
format = Basic::BlockFormat.new({})
|
|
@@ -7,11 +7,6 @@ class Thinreports::Core::Shape::Basic::TestBlockInternal < Minitest::Test
|
|
|
7
7
|
|
|
8
8
|
Basic = Thinreports::Core::Shape::Basic
|
|
9
9
|
|
|
10
|
-
def test_box_should_return_value_of_format
|
|
11
|
-
internal = init_internal('box' => 'box of format')
|
|
12
|
-
assert_equal internal.box, 'box of format'
|
|
13
|
-
end
|
|
14
|
-
|
|
15
10
|
def test_read_value_should_return_value_from_format
|
|
16
11
|
internal = init_internal('value' => 'default value')
|
|
17
12
|
assert_equal internal.read_value, 'default value'
|
|
@@ -46,11 +41,13 @@ class Thinreports::Core::Shape::Basic::TestBlockInternal < Minitest::Test
|
|
|
46
41
|
end
|
|
47
42
|
|
|
48
43
|
def test_type_of_asker_should_return_false_otherwise
|
|
49
|
-
assert_equal
|
|
44
|
+
assert_equal %w( image-block text-block text list ).all? {|t| !init_internal.type_of?(t)}, true
|
|
50
45
|
end
|
|
51
46
|
|
|
47
|
+
private
|
|
48
|
+
|
|
52
49
|
def init_internal(format = {})
|
|
53
|
-
report = Thinreports::Report.new layout:
|
|
50
|
+
report = Thinreports::Report.new layout: layout_file.path
|
|
54
51
|
parent = report.start_new_page
|
|
55
52
|
|
|
56
53
|
Basic::BlockInternal.new(parent, Basic::BlockFormat.new(format))
|
|
@@ -5,55 +5,33 @@ require 'test_helper'
|
|
|
5
5
|
class Thinreports::Core::Shape::Basic::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
|
-
"x" => "85",
|
|
25
|
-
"y" => "82"
|
|
26
|
-
}
|
|
8
|
+
RECT_FORMAT = {
|
|
9
|
+
"id" => "",
|
|
10
|
+
"type" => "rect",
|
|
11
|
+
"x" => 100.0,
|
|
12
|
+
"y" => 200.0,
|
|
13
|
+
"width" => 300.0,
|
|
14
|
+
"height" => 400.0,
|
|
15
|
+
"description" => "Description for rect",
|
|
16
|
+
"display" => true,
|
|
17
|
+
"rx" => 1.0,
|
|
18
|
+
"ry" => 1.0,
|
|
19
|
+
"style" => {
|
|
20
|
+
"border-width" => 1,
|
|
21
|
+
"border-color" => "#000000",
|
|
22
|
+
"border-style" => "dashed",
|
|
23
|
+
"fill-color" => "#ff0000"
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
Format = Thinreports::Core::Shape::Basic::Format
|
|
27
|
+
Basic = Thinreports::Core::Shape::Basic
|
|
32
28
|
|
|
33
|
-
def
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
format = Format.new(TEST_BASIC_FORMAT)
|
|
41
|
-
|
|
42
|
-
assert_equal format.id, 'rect_1'
|
|
43
|
-
assert_equal format.type, 's-rect'
|
|
44
|
-
assert_equal format.svg_tag, 'rect'
|
|
45
|
-
assert_equal format.display?, true
|
|
46
|
-
assert_equal format.svg_attrs['stroke'], '#000000'
|
|
47
|
-
assert_equal format.svg_attrs['stroke-dasharray'], 'none'
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def test_display?
|
|
51
|
-
format = Format.new('display' => 'false')
|
|
52
|
-
|
|
53
|
-
assert_equal format.display?, false
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def build_basic_format
|
|
57
|
-
Format.build(TEST_BASIC_FORMAT)
|
|
29
|
+
def test_attribute_readers
|
|
30
|
+
format = Basic::Format.new(RECT_FORMAT)
|
|
31
|
+
|
|
32
|
+
assert_equal '', format.id
|
|
33
|
+
assert_equal 'rect', format.type
|
|
34
|
+
assert_equal RECT_FORMAT['style'], format.style
|
|
35
|
+
assert_equal true, format.display?
|
|
58
36
|
end
|
|
59
|
-
end
|
|
37
|
+
end
|
|
@@ -9,7 +9,7 @@ class Thinreports::Core::Shape::Basic::TestInterface < Minitest::Test
|
|
|
9
9
|
Basic = Thinreports::Core::Shape::Basic
|
|
10
10
|
|
|
11
11
|
def create_interface(format_config = {})
|
|
12
|
-
report = Thinreports::Report.new layout:
|
|
12
|
+
report = Thinreports::Report.new layout: layout_file.path
|
|
13
13
|
parent = report.start_new_page
|
|
14
14
|
|
|
15
15
|
Basic::Interface.new parent, Basic::Format.new(format_config)
|
|
@@ -26,24 +26,24 @@ class Thinreports::Core::Shape::Basic::TestInterface < Minitest::Test
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def test_type_should_operate_as_delegator_of_internal
|
|
29
|
-
basic = create_interface('type' => '
|
|
29
|
+
basic = create_interface('type' => 'rect')
|
|
30
30
|
assert_same basic.type, basic.internal.type
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def test_visible_asker_should_return_result_with_reference_to_style_of_internal
|
|
34
|
-
basic = create_interface('display' =>
|
|
34
|
+
basic = create_interface('display' => false)
|
|
35
35
|
assert_equal basic.visible?, basic.internal.style.visible
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def test_visible_should_properly_set_visibility_to_style_of_internal
|
|
39
|
-
basic = create_interface('display' =>
|
|
39
|
+
basic = create_interface('display' => false)
|
|
40
40
|
basic.visible(true)
|
|
41
41
|
|
|
42
42
|
assert_equal basic.internal.style.visible, true
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def test_style_should_operate_as_reader_when_one_argument_is_given
|
|
46
|
-
basic = create_interface('
|
|
46
|
+
basic = create_interface('style' => { 'fill-color' => '#ff0000' })
|
|
47
47
|
|
|
48
48
|
assert_equal basic.style(:fill_color), '#ff0000'
|
|
49
49
|
end
|
|
@@ -9,7 +9,7 @@ class Thinreports::Core::Shape::Basic::TestInternal < Minitest::Test
|
|
|
9
9
|
Basic = Thinreports::Core::Shape::Basic
|
|
10
10
|
|
|
11
11
|
def create_internal(format_config = {})
|
|
12
|
-
report = Thinreports::Report.new layout:
|
|
12
|
+
report = Thinreports::Report.new layout: layout_file.path
|
|
13
13
|
|
|
14
14
|
Basic::Internal.new report.page, Basic::Format.new(format_config)
|
|
15
15
|
end
|
|
@@ -19,13 +19,8 @@ class Thinreports::Core::Shape::Basic::TestInternal < Minitest::Test
|
|
|
19
19
|
assert_same basic.id, basic.format.id
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def test_svg_tag_should_operate_as_delegator_of_format
|
|
23
|
-
basic = create_internal('svg' => {'tag' => 'rect'})
|
|
24
|
-
assert_same basic.svg_tag, basic.format.svg_tag
|
|
25
|
-
end
|
|
26
|
-
|
|
27
22
|
def test_type_should_operate_as_delegator_of_format
|
|
28
|
-
basic = create_internal('type' => '
|
|
23
|
+
basic = create_internal('type' => 'ellipse')
|
|
29
24
|
assert_same basic.type, basic.format.type
|
|
30
25
|
end
|
|
31
26
|
|
|
@@ -41,10 +36,10 @@ class Thinreports::Core::Shape::Basic::TestInternal < Minitest::Test
|
|
|
41
36
|
def test_type_of_asker_should_return_true_when_the_specified_type_equal_self_type_name
|
|
42
37
|
result = []
|
|
43
38
|
|
|
44
|
-
result << create_internal('type' => '
|
|
45
|
-
result << create_internal('type' => '
|
|
46
|
-
result << create_internal('type' => '
|
|
47
|
-
result << create_internal('type' => '
|
|
39
|
+
result << create_internal('type' => 'rect').type_of?('rect')
|
|
40
|
+
result << create_internal('type' => 'ellipse').type_of?('ellipse')
|
|
41
|
+
result << create_internal('type' => 'line').type_of?('line')
|
|
42
|
+
result << create_internal('type' => 'image').type_of?('image')
|
|
48
43
|
|
|
49
44
|
assert_equal result.all?, true
|
|
50
45
|
end
|
|
@@ -8,17 +8,17 @@ class Thinreports::Core::Shape::ImageBlock::TestInterface < Minitest::Test
|
|
|
8
8
|
ImageBlock = Thinreports::Core::Shape::ImageBlock
|
|
9
9
|
|
|
10
10
|
def setup
|
|
11
|
-
@report =
|
|
11
|
+
@report = Thinreports::Report.new layout: layout_file.path
|
|
12
12
|
@page = @report.start_new_page
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def test_src
|
|
16
|
-
@page.item(:
|
|
17
|
-
assert_equal '/path/to/image.png', @page.item(:
|
|
16
|
+
@page.item(:image_block).src('/path/to/image.png')
|
|
17
|
+
assert_equal '/path/to/image.png', @page.item(:image_block).src
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def test_src=
|
|
21
|
-
@page.item(:
|
|
22
|
-
assert_equal '/path/to/image.png', @page.item(:
|
|
21
|
+
@page.item(:image_block).src = '/path/to/image.png'
|
|
22
|
+
assert_equal '/path/to/image.png', @page.item(:image_block).src
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -15,7 +15,7 @@ class Thinreports::Core::Shape::ImageBlock::TestInternal < Minitest::Test
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def test_type_of_asker_should_return_true_when_iblock_value_is_given
|
|
18
|
-
assert_equal create_internal.type_of?(
|
|
18
|
+
assert_equal create_internal.type_of?('image-block'), true
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def test_type_of_asker_should_return_true_when_block_value_is_given
|
|
@@ -23,7 +23,7 @@ class Thinreports::Core::Shape::ImageBlock::TestInternal < Minitest::Test
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def create_internal
|
|
26
|
-
report =
|
|
26
|
+
report = Thinreports::Report.new layout: layout_file.path
|
|
27
27
|
parent = report.start_new_page
|
|
28
28
|
|
|
29
29
|
ImageBlock::Internal.new parent, ImageBlock::Format.new({})
|
|
@@ -5,65 +5,107 @@ require 'test_helper'
|
|
|
5
5
|
class Thinreports::Core::Shape::List::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
|
-
|
|
8
|
+
LIST_FORMAT = {
|
|
9
|
+
'type' => 'list',
|
|
10
|
+
'id' => 'list',
|
|
11
|
+
'display' => true,
|
|
12
|
+
'x' => 10.0,
|
|
13
|
+
'y' => 20.0,
|
|
14
|
+
'width' => 30.0,
|
|
15
|
+
'height' => 40.0,
|
|
16
|
+
'content-height' => 255,
|
|
17
|
+
'auto-page-break' => true,
|
|
18
|
+
'header' => {
|
|
19
|
+
'enabled' => true,
|
|
20
|
+
'height' => 10.0,
|
|
21
|
+
'translate' => { 'x' => 210.0, 'y' => 310.0 },
|
|
22
|
+
'items' => []
|
|
23
|
+
},
|
|
24
|
+
'detail' => {
|
|
25
|
+
'height' => 20.0,
|
|
26
|
+
'translate' => { 'x' => 220.0, 'y' => 320.0 },
|
|
27
|
+
'items' => []
|
|
28
|
+
},
|
|
29
|
+
'page-footer' => {
|
|
30
|
+
'enabled' => true,
|
|
31
|
+
'height' => 30.0,
|
|
32
|
+
'translate' => { 'x' => 230.0, 'y' => 330.0 },
|
|
33
|
+
'items' => []
|
|
34
|
+
},
|
|
35
|
+
'footer' => {
|
|
36
|
+
'enabled' => false,
|
|
37
|
+
'height' => 40.0,
|
|
38
|
+
'translate' => { 'x' => 240.0, 'y' => 340.0 },
|
|
39
|
+
'items' => []
|
|
24
40
|
}
|
|
25
41
|
}
|
|
26
42
|
|
|
27
43
|
List = Thinreports::Core::Shape::List
|
|
28
44
|
|
|
29
|
-
def
|
|
30
|
-
List::
|
|
45
|
+
def test_has_section?
|
|
46
|
+
format = List::Format.new(LIST_FORMAT)
|
|
31
47
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
48
|
+
assert_equal true, format.has_section?(:detail)
|
|
49
|
+
assert_equal true, format.has_section?(:page_footer)
|
|
50
|
+
assert_equal false, format.has_section?(:footer)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_section_height
|
|
54
|
+
format = List::Format.new(LIST_FORMAT)
|
|
55
|
+
|
|
56
|
+
assert_equal 10.0, format.section_height(:header)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_attribute_readers
|
|
60
|
+
format = List::Format.new(LIST_FORMAT)
|
|
37
61
|
|
|
38
|
-
assert_equal format.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
62
|
+
assert_equal 255, format.height
|
|
63
|
+
assert_equal true, format.auto_page_break?
|
|
64
|
+
assert_equal true, format.has_header?
|
|
65
|
+
assert_equal true, format.has_page_footer?
|
|
66
|
+
assert_equal false, format.has_footer?
|
|
67
|
+
assert_equal 20.0, format.detail_height
|
|
68
|
+
assert_equal 30.0, format.page_footer_height
|
|
69
|
+
assert_equal 40.0, format.footer_height
|
|
70
|
+
assert_equal 10.0, format.header_height
|
|
42
71
|
end
|
|
43
72
|
|
|
44
|
-
def
|
|
45
|
-
|
|
73
|
+
def test_section_base_position_top
|
|
74
|
+
page_footer_disabled = LIST_FORMAT
|
|
75
|
+
|
|
76
|
+
format = List::Format.new(page_footer_disabled)
|
|
77
|
+
assert_equal 310.0, format.section_base_position_top(:header)
|
|
78
|
+
assert_equal 320.0, format.section_base_position_top(:detail)
|
|
79
|
+
assert_equal 310.0, format.section_base_position_top(:page_footer)
|
|
80
|
+
assert_equal 0, format.section_base_position_top(:footer)
|
|
46
81
|
|
|
47
|
-
|
|
48
|
-
'footer-enabled' => 'false')
|
|
82
|
+
format_footer_enabled = format_section_enabled(true, 'footer', LIST_FORMAT)
|
|
49
83
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
84
|
+
format = List::Format.new(format_footer_enabled)
|
|
85
|
+
assert_equal 290.0, format.section_base_position_top(:footer)
|
|
86
|
+
|
|
87
|
+
format_footer_enabld_and_page_footer_disabled = format_section_enabled(false, 'page-footer', format_footer_enabled)
|
|
88
|
+
|
|
89
|
+
format = List::Format.new(format_footer_enabld_and_page_footer_disabled)
|
|
90
|
+
assert_equal 320.0, format.section_base_position_top(:footer)
|
|
54
91
|
end
|
|
55
92
|
|
|
56
|
-
def
|
|
57
|
-
format = List::Format.new(
|
|
93
|
+
def test_initialize_sections
|
|
94
|
+
format = List::Format.new(LIST_FORMAT)
|
|
95
|
+
|
|
96
|
+
assert_instance_of List::SectionFormat, format.sections[:header]
|
|
97
|
+
assert_instance_of List::SectionFormat, format.sections[:detail]
|
|
98
|
+
assert_instance_of List::SectionFormat, format.sections[:page_footer]
|
|
58
99
|
|
|
59
|
-
|
|
60
|
-
assert_equal format.auto_page_break?, true
|
|
61
|
-
assert_equal format.has_header?, true
|
|
62
|
-
assert_equal format.has_footer?, true
|
|
63
|
-
assert_equal format.has_page_footer?, true
|
|
100
|
+
assert_nil format.sections[:footer]
|
|
64
101
|
end
|
|
65
102
|
|
|
66
|
-
|
|
67
|
-
|
|
103
|
+
private
|
|
104
|
+
|
|
105
|
+
def format_section_enabled(enable, section, list_format)
|
|
106
|
+
section_format = list_format[section].dup
|
|
107
|
+
section_format['enabled'] = enable
|
|
108
|
+
|
|
109
|
+
list_format.merge(section => section_format)
|
|
68
110
|
end
|
|
69
111
|
end
|
|
@@ -9,16 +9,14 @@ class Thinreports::Core::Shape::List::TestManager < Minitest::Test
|
|
|
9
9
|
List = Thinreports::Core::Shape::List
|
|
10
10
|
|
|
11
11
|
def create_report(&block)
|
|
12
|
-
|
|
12
|
+
report = Thinreports::Report.new layout: layout_file.path
|
|
13
|
+
block.call(report) if block_given?
|
|
14
|
+
report
|
|
13
15
|
end
|
|
14
16
|
|
|
15
17
|
def list_manager
|
|
16
18
|
report = create_report {|r| r.start_new_page }
|
|
17
|
-
report.page.list
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def test_config_should_return_the_instance_of_ListConfiguration
|
|
21
|
-
assert_same list_manager.config.class, List::Configuration
|
|
19
|
+
report.page.list.manager
|
|
22
20
|
end
|
|
23
21
|
|
|
24
22
|
def test_current_page_should_return_the_instance_of_ListPage
|
|
@@ -31,7 +29,7 @@ class Thinreports::Core::Shape::List::TestManager < Minitest::Test
|
|
|
31
29
|
|
|
32
30
|
def test_switch_current_should_replace_own_current_page_property_by_the_given_page
|
|
33
31
|
report = create_report {|r| r.start_new_page }
|
|
34
|
-
list = report.page.list
|
|
32
|
+
list = report.page.list
|
|
35
33
|
new_page = List::Page.new(report.page, list.internal.format)
|
|
36
34
|
|
|
37
35
|
list.manager.switch_current!(new_page)
|
|
@@ -41,7 +39,7 @@ class Thinreports::Core::Shape::List::TestManager < Minitest::Test
|
|
|
41
39
|
|
|
42
40
|
def test_switch_current_should_replace_own_current_page_state_property_by_internal_property_of_the_given_page
|
|
43
41
|
report = create_report {|r| r.start_new_page }
|
|
44
|
-
list = report.page.list
|
|
42
|
+
list = report.page.list
|
|
45
43
|
new_page = List::Page.new(report.page, list.internal.format)
|
|
46
44
|
|
|
47
45
|
list.manager.switch_current!(new_page)
|
|
@@ -51,72 +49,19 @@ class Thinreports::Core::Shape::List::TestManager < Minitest::Test
|
|
|
51
49
|
|
|
52
50
|
def test_switch_current_should_return_the_self
|
|
53
51
|
report = create_report {|r| r.start_new_page }
|
|
54
|
-
list = report.page.list
|
|
52
|
+
list = report.page.list
|
|
55
53
|
new_page = List::Page.new(report.page, list.internal.format)
|
|
56
54
|
|
|
57
55
|
assert_same list.manager.switch_current!(new_page), list.manager
|
|
58
56
|
end
|
|
59
57
|
|
|
60
|
-
def test_finalize_page_should_dispatch_page_finalize_event
|
|
61
|
-
flag = false
|
|
62
|
-
|
|
63
|
-
report = create_report do |r|
|
|
64
|
-
r.layout.config.list(:list) do
|
|
65
|
-
events.on :page_finalize do
|
|
66
|
-
flag = true
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
report.start_new_page do |page|
|
|
72
|
-
page.list(:list).manager.finalize_page
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
assert flag, 'The :page_finalize event was not dispatched.'
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def test_page_property_which_dispatcher_of_finalize_page_event_should_return_the_current_page
|
|
79
|
-
page_used_in_event = nil
|
|
80
|
-
|
|
81
|
-
report = create_report do |r|
|
|
82
|
-
r.layout.config.list(:list) do
|
|
83
|
-
events.on :page_finalize do |e|
|
|
84
|
-
page_used_in_event = e.page
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
current_page = report.start_new_page
|
|
90
|
-
current_page.list(:list).manager.finalize_page
|
|
91
|
-
|
|
92
|
-
assert_same page_used_in_event, current_page
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def test_list_property_which_dispatcher_of_finalize_event_should_return_the_current_page_of_list
|
|
96
|
-
list_used_in_event = nil
|
|
97
|
-
|
|
98
|
-
report = create_report do |r|
|
|
99
|
-
r.layout.config.list(:list) do
|
|
100
|
-
events.on :page_finalize do |e|
|
|
101
|
-
list_used_in_event = e.list
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
report.start_new_page
|
|
107
|
-
current_list = report.page.list(:list)
|
|
108
|
-
current_list.manager.finalize_page
|
|
109
|
-
|
|
110
|
-
assert_same list_used_in_event, current_list
|
|
111
|
-
end
|
|
112
|
-
|
|
113
58
|
def test_page_count
|
|
114
59
|
report = create_report
|
|
115
60
|
assert_equal report.page_count, 0
|
|
116
61
|
|
|
117
|
-
report.list
|
|
118
|
-
report.list
|
|
62
|
+
report.list.page_break
|
|
63
|
+
report.list.page_break
|
|
119
64
|
|
|
120
|
-
assert_equal report.list
|
|
65
|
+
assert_equal report.list.manager.page_count, 2
|
|
121
66
|
end
|
|
122
67
|
end
|