thinreports 0.9.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/test.yml +39 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +59 -2
- data/Dockerfile +12 -0
- data/Gemfile +7 -4
- data/README.md +44 -22
- data/Rakefile +14 -31
- data/lib/thinreports.rb +16 -15
- data/lib/thinreports/config.rb +2 -24
- data/lib/thinreports/core/errors.rb +6 -17
- data/lib/thinreports/core/format/base.rb +62 -61
- data/lib/thinreports/core/shape.rb +10 -12
- data/lib/thinreports/core/shape/base.rb +3 -12
- data/lib/thinreports/core/shape/base/interface.rb +34 -32
- data/lib/thinreports/core/shape/base/internal.rb +45 -43
- data/lib/thinreports/core/shape/basic.rb +12 -12
- data/lib/thinreports/core/shape/basic/block_format.rb +8 -6
- data/lib/thinreports/core/shape/basic/block_interface.rb +24 -22
- data/lib/thinreports/core/shape/basic/block_internal.rb +28 -26
- data/lib/thinreports/core/shape/basic/format.rb +11 -9
- data/lib/thinreports/core/shape/basic/interface.rb +79 -77
- data/lib/thinreports/core/shape/basic/internal.rb +17 -14
- data/lib/thinreports/core/shape/image_block.rb +9 -9
- data/lib/thinreports/core/shape/image_block/format.rb +7 -5
- data/lib/thinreports/core/shape/image_block/interface.rb +15 -13
- data/lib/thinreports/core/shape/image_block/internal.rb +10 -8
- data/lib/thinreports/core/shape/list.rb +13 -13
- data/lib/thinreports/core/shape/list/format.rb +83 -77
- data/lib/thinreports/core/shape/list/manager.rb +179 -176
- data/lib/thinreports/core/shape/list/page.rb +91 -93
- data/lib/thinreports/core/shape/list/page_state.rb +42 -40
- data/lib/thinreports/core/shape/list/section_format.rb +28 -26
- data/lib/thinreports/core/shape/list/section_interface.rb +42 -40
- data/lib/thinreports/core/shape/list/section_internal.rb +21 -19
- data/lib/thinreports/core/shape/manager.rb +4 -13
- data/lib/thinreports/core/shape/manager/format.rb +21 -19
- data/lib/thinreports/core/shape/manager/internal.rb +87 -84
- data/lib/thinreports/core/shape/manager/target.rb +93 -95
- data/lib/thinreports/core/shape/page_number.rb +9 -9
- data/lib/thinreports/core/shape/page_number/format.rb +20 -18
- data/lib/thinreports/core/shape/page_number/interface.rb +20 -18
- data/lib/thinreports/core/shape/page_number/internal.rb +46 -44
- data/lib/thinreports/core/shape/style.rb +5 -14
- data/lib/thinreports/core/shape/style/base.rb +121 -120
- data/lib/thinreports/core/shape/style/basic.rb +12 -10
- data/lib/thinreports/core/shape/style/graphic.rb +35 -33
- data/lib/thinreports/core/shape/style/text.rb +113 -107
- data/lib/thinreports/core/shape/text.rb +9 -9
- data/lib/thinreports/core/shape/text/format.rb +10 -9
- data/lib/thinreports/core/shape/text/interface.rb +13 -11
- data/lib/thinreports/core/shape/text/internal.rb +14 -12
- data/lib/thinreports/core/shape/text_block.rb +10 -10
- data/lib/thinreports/core/shape/text_block/format.rb +35 -33
- data/lib/thinreports/core/shape/text_block/formatter.rb +26 -24
- data/lib/thinreports/core/shape/text_block/formatter/basic.rb +25 -25
- data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +15 -12
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +52 -34
- data/lib/thinreports/core/shape/text_block/formatter/padding.rb +17 -14
- data/lib/thinreports/core/shape/text_block/interface.rb +25 -23
- data/lib/thinreports/core/shape/text_block/internal.rb +66 -68
- data/lib/thinreports/core/utils.rb +7 -3
- data/lib/thinreports/generator/pdf.rb +24 -25
- data/lib/thinreports/generator/pdf/document.rb +109 -110
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +57 -51
- data/lib/thinreports/generator/pdf/document/draw_template_items.rb +50 -47
- data/lib/thinreports/generator/pdf/document/font.rb +67 -58
- data/lib/thinreports/generator/pdf/document/graphics.rb +32 -33
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +121 -121
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +112 -114
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +58 -150
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +149 -137
- data/lib/thinreports/generator/pdf/document/page.rb +60 -64
- data/lib/thinreports/generator/pdf/document/parse_color.rb +37 -37
- data/lib/thinreports/generator/pdf/drawer/base.rb +41 -41
- data/lib/thinreports/generator/pdf/drawer/list.rb +56 -54
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +42 -40
- data/lib/thinreports/generator/pdf/drawer/page.rb +101 -96
- data/lib/thinreports/generator/pdf/prawn_ext.rb +4 -30
- data/lib/thinreports/generator/pdf/prawn_ext/calc_image_dimensions.rb +32 -0
- data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +35 -0
- data/lib/thinreports/layout.rb +5 -7
- data/lib/thinreports/layout/base.rb +5 -9
- data/lib/thinreports/layout/format.rb +17 -13
- data/lib/thinreports/layout/legacy_schema.rb +17 -13
- data/lib/thinreports/layout/version.rb +22 -25
- data/lib/thinreports/report.rb +4 -6
- data/lib/thinreports/report/base.rb +24 -51
- data/lib/thinreports/report/internal.rb +13 -15
- data/lib/thinreports/report/page.rb +5 -11
- data/lib/thinreports/version.rb +2 -2
- data/thinreports.gemspec +10 -19
- metadata +13 -288
- data/.travis.yml +0 -19
- data/examples/character_spacing/character_spacing.rb +0 -8
- data/examples/character_spacing/character_spacing.tlf +0 -293
- data/examples/dynamic_image/dynamic_image.rb +0 -31
- data/examples/dynamic_image/dynamic_image.tlf +0 -661
- data/examples/dynamic_image/img200x100.png +0 -0
- data/examples/dynamic_image/img50x50.png +0 -0
- data/examples/dynamic_style/dynamic_style.rb +0 -150
- data/examples/dynamic_style/dynamic_style.tlf +0 -1835
- data/examples/dynamic_style/dynamic_style_in_list.tlf +0 -344
- data/examples/dynamic_style/image.png +0 -0
- data/examples/eudc/eudc.rb +0 -20
- data/examples/eudc/eudc.tlf +0 -180
- data/examples/eudc/eudc.ttf +0 -0
- data/examples/helper.rb +0 -50
- data/examples/hidden_shapes/hidden_shapes.rb +0 -9
- data/examples/hidden_shapes/hidden_shapes.tlf +0 -449
- data/examples/list_events/list_events.rb +0 -32
- data/examples/list_events/list_events.tlf +0 -361
- data/examples/list_manual_generation/list_manual_generation.rb +0 -22
- data/examples/list_manual_generation/list_manual_generation.tlf +0 -132
- data/examples/list_page_number/list_page_number.rb +0 -17
- data/examples/list_page_number/list_page_number.tlf +0 -254
- data/examples/page_number/page_number.rb +0 -33
- data/examples/page_number/page_number.tlf +0 -215
- data/examples/palleted_png/palleted_png.png +0 -0
- data/examples/palleted_png/palleted_png.rb +0 -11
- data/examples/palleted_png/palleted_png.tlf +0 -47
- data/examples/password_setting/password_setting.rb +0 -10
- data/examples/password_setting/password_setting.tlf +0 -45
- data/examples/report_callbacks/report_callbacks.rb +0 -14
- data/examples/report_callbacks/report_callbacks.tlf +0 -147
- data/examples/single_line_tblock/single_line_tblock.rb +0 -13
- data/examples/single_line_tblock/single_line_tblock.tlf +0 -170
- data/examples/tblock_overflow/tblock_overflow.rb +0 -20
- data/examples/tblock_overflow/tblock_overflow.tlf +0 -538
- data/examples/tblock_styles/font_size.tlf +0 -383
- data/examples/tblock_styles/tblock_styles.rb +0 -43
- data/examples/tblock_styles/tblock_styles.tlf +0 -889
- data/examples/text_align/text_align.rb +0 -8
- data/examples/text_align/text_align.tlf +0 -241
- data/examples/typeB_page_size/B4_ISO.tlf +0 -45
- data/examples/typeB_page_size/B4_JIS.tlf +0 -45
- data/examples/typeB_page_size/typeB_page_size.rb +0 -17
- data/examples/word_wrap/word_wrap.rb +0 -26
- data/examples/word_wrap/word_wrap.tlf +0 -297
- data/lib/thinreports/generator.rb +0 -29
- data/lib/thinreports/generator/base.rb +0 -40
- data/lib/thinreports/generator/configuration.rb +0 -31
- data/lib/thinreports/report/events.rb +0 -32
- data/test/data/font.ttf +0 -0
- data/test/data/image_normal.jpg +0 -0
- data/test/data/image_normal.png +0 -0
- data/test/data/image_normal_jpg_noext +0 -0
- data/test/data/image_normal_png_noext +0 -0
- data/test/data/image_pallete_based.png +0 -0
- data/test/data/legacy_layout/all-items.tlf +0 -1
- data/test/schema_helper.rb +0 -121
- data/test/test_helper.rb +0 -42
- data/test/tmp/.gitkeep +0 -0
- data/test/unit/core/format/test_base.rb +0 -152
- data/test/unit/core/shape/base/test_internal.rb +0 -87
- data/test/unit/core/shape/basic/test_block_format.rb +0 -23
- data/test/unit/core/shape/basic/test_block_interface.rb +0 -29
- data/test/unit/core/shape/basic/test_block_internal.rb +0 -55
- data/test/unit/core/shape/basic/test_format.rb +0 -37
- data/test/unit/core/shape/basic/test_interface.rb +0 -108
- data/test/unit/core/shape/basic/test_internal.rb +0 -55
- data/test/unit/core/shape/image_block/test_interface.rb +0 -24
- data/test/unit/core/shape/image_block/test_internal.rb +0 -31
- data/test/unit/core/shape/list/test_format.rb +0 -111
- data/test/unit/core/shape/list/test_manager.rb +0 -67
- data/test/unit/core/shape/list/test_page.rb +0 -82
- data/test/unit/core/shape/list/test_page_state.rb +0 -31
- data/test/unit/core/shape/list/test_section_format.rb +0 -36
- data/test/unit/core/shape/list/test_section_interface.rb +0 -75
- data/test/unit/core/shape/list/test_section_internal.rb +0 -50
- data/test/unit/core/shape/manager/test_format.rb +0 -38
- data/test/unit/core/shape/manager/test_internal.rb +0 -132
- data/test/unit/core/shape/manager/test_target.rb +0 -140
- data/test/unit/core/shape/page_number/test_format.rb +0 -55
- data/test/unit/core/shape/page_number/test_interface.rb +0 -33
- data/test/unit/core/shape/page_number/test_internal.rb +0 -81
- data/test/unit/core/shape/styles/test_base.rb +0 -191
- data/test/unit/core/shape/styles/test_basic.rb +0 -24
- data/test/unit/core/shape/styles/test_graphic.rb +0 -50
- data/test/unit/core/shape/styles/test_text.rb +0 -97
- data/test/unit/core/shape/text/test_format.rb +0 -44
- data/test/unit/core/shape/text/test_internal.rb +0 -20
- data/test/unit/core/shape/text_block/formatter/test_basic.rb +0 -24
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +0 -49
- data/test/unit/core/shape/text_block/formatter/test_number.rb +0 -76
- data/test/unit/core/shape/text_block/formatter/test_padding.rb +0 -77
- data/test/unit/core/shape/text_block/test_format.rb +0 -169
- data/test/unit/core/shape/text_block/test_formatter.rb +0 -28
- data/test/unit/core/shape/text_block/test_interface.rb +0 -63
- data/test/unit/core/shape/text_block/test_internal.rb +0 -128
- data/test/unit/core/test_shape.rb +0 -52
- data/test/unit/core/test_utils.rb +0 -68
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +0 -135
- data/test/unit/generator/pdf/document/graphics/test_basic.rb +0 -45
- data/test/unit/generator/pdf/document/graphics/test_image.rb +0 -150
- data/test/unit/generator/pdf/document/graphics/test_text.rb +0 -171
- data/test/unit/generator/pdf/document/test_font.rb +0 -84
- data/test/unit/generator/pdf/document/test_graphics.rb +0 -42
- data/test/unit/generator/pdf/document/test_page.rb +0 -122
- data/test/unit/generator/pdf/document/test_parse_color.rb +0 -30
- data/test/unit/generator/pdf/test_document.rb +0 -20
- data/test/unit/generator/test_base.rb +0 -40
- data/test/unit/generator/test_configuration.rb +0 -21
- data/test/unit/generator/test_pdf.rb +0 -24
- data/test/unit/layout/test_base.rb +0 -41
- data/test/unit/layout/test_format.rb +0 -100
- data/test/unit/layout/test_legacy_schema.rb +0 -574
- data/test/unit/layout/test_version.rb +0 -95
- data/test/unit/report/test_base.rb +0 -262
- data/test/unit/report/test_internal.rb +0 -206
- data/test/unit/test_config.rb +0 -51
- data/test/unit/test_layout.rb +0 -12
- data/test/unit/test_report.rb +0 -18
@@ -1,38 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::Manager::TestFormat < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
class TestFormat < Thinreports::Core::Shape::Manager::Format; end
|
9
|
-
|
10
|
-
def test_identifier_should_return_the_same_as_object_id_when_id_is_not_given
|
11
|
-
format = TestFormat.new({})
|
12
|
-
assert_equal format.identifier, format.object_id
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_identifier_should_return_the_specified_id_when_id_is_given
|
16
|
-
assert_equal TestFormat.new({}, :any_id).identifier, :any_id
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_has_shape
|
20
|
-
format = TestFormat.new({}) do |f|
|
21
|
-
f.shapes[:foo] = 1
|
22
|
-
end
|
23
|
-
assert format.has_shape?(:foo)
|
24
|
-
refute format.has_shape?(:unknown)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_find_shape_should_return_format_of_shape_when_shape_is_found
|
28
|
-
format = TestFormat.new({}) do |f|
|
29
|
-
f.shapes[:foo] = Thinreports::Core::Shape::TextBlock::Format.new('id' => 'foo',
|
30
|
-
'type' => 'text-block')
|
31
|
-
end
|
32
|
-
assert_equal format.find_shape(:foo).id, 'foo'
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_find_shape_should_return_nil_when_shape_is_not_found
|
36
|
-
assert_nil TestFormat.new({}).find_shape(:unknown)
|
37
|
-
end
|
38
|
-
end
|
@@ -1,132 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::Manager::TestInternal < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
# Alias
|
9
|
-
Shape = Thinreports::Core::Shape
|
10
|
-
|
11
|
-
def create_shape_format(type, id, other_config = {})
|
12
|
-
Shape::Format(type).new({'id' => id,
|
13
|
-
'type' => type,
|
14
|
-
'display' => true}.merge(other_config))
|
15
|
-
end
|
16
|
-
|
17
|
-
def create_internal(&block)
|
18
|
-
report = Thinreports::Report.new layout: layout_file.path
|
19
|
-
format = report.layout.format
|
20
|
-
|
21
|
-
block.call(format) if block_given?
|
22
|
-
|
23
|
-
report.start_new_page.manager
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_find_format_should_return_format_with_the_specified_Symbol_id
|
27
|
-
assert_equal create_internal.find_format(:text_block).id, 'text_block'
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_find_format_should_return_format_with_the_specified_String_id
|
31
|
-
assert_equal create_internal.find_format('text_block').id, 'text_block'
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_find_format_should_return_nil_when_format_with_specified_id_is_not_found
|
35
|
-
assert_nil create_internal.find_format(:unknown)
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_find_item_should_return_shape_with_the_specified_id
|
39
|
-
assert_instance_of Shape::TextBlock::Interface, create_internal.find_item(:text_block)
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_find_item_should_return_shape_in_shapes_registry_when_the_specified_shape_exists_in_registry
|
43
|
-
internal = create_internal
|
44
|
-
internal.find_item(:text_block)
|
45
|
-
|
46
|
-
assert_same internal.find_item(:text_block), internal.shapes[:text_block]
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_find_item_should_return_shape_when_passing_in_the_specified_only_filter
|
50
|
-
internal = create_internal
|
51
|
-
assert_equal internal.find_item(:text_block, only: 'text-block').id, 'text_block'
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_find_item_should_return_nil_when_not_passing_in_the_specified_only_filter
|
55
|
-
internal = create_internal
|
56
|
-
assert_nil internal.find_item(:text_block, only: 'list')
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_find_item_should_return_shape_when_passing_in_the_specified_except_filter
|
60
|
-
internal = create_internal
|
61
|
-
assert_equal internal.find_item(:default, except: 'text-block').id, 'default'
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_find_item_should_return_shape_when_not_passing_in_the_specified_except_filter
|
65
|
-
internal = create_internal
|
66
|
-
assert_nil internal.find_item(:default, except: 'list')
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_final_shape_should_return_nil_when_shape_is_not_found
|
70
|
-
internal = create_internal
|
71
|
-
assert_nil internal.final_shape(:unknown)
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_final_shape_should_return_nil_when_shape_is_stored_in_shapes_and_hidden
|
75
|
-
internal = create_internal
|
76
|
-
internal.find_item(:text_block).hide
|
77
|
-
|
78
|
-
assert_nil internal.final_shape(:text_block)
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_final_shape_should_return_shape_when_shape_is_stored_in_shapes_and_TextBlock_with_value
|
82
|
-
internal = create_internal
|
83
|
-
internal.find_item(:text_block).value('value')
|
84
|
-
|
85
|
-
assert_equal internal.final_shape(:text_block).id, 'text_block'
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_final_shape_should_return_nil_when_shape_is_stored_in_shapes_and_TextBlock_with_no_value
|
89
|
-
internal = create_internal
|
90
|
-
internal.find_item(:text_block)
|
91
|
-
|
92
|
-
assert_nil internal.final_shape(:text_block)
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_final_shape_should_return_shape_when_shape_is_stored_in_shapes_and_ImageBlock_with_src
|
96
|
-
internal = create_internal
|
97
|
-
internal.find_item(:image_block).src('/path/to/image.png')
|
98
|
-
|
99
|
-
assert_equal internal.final_shape(:image_block).id, 'image_block'
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_final_shape_should_return_nil_when_shape_is_stored_in_shapes_and_ImageBlock_with_no_src
|
103
|
-
internal = create_internal
|
104
|
-
assert_nil internal.final_shape(:image_block)
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_final_shape_should_return_nil_when_shape_isnot_stored_in_shapes_and_hidden
|
108
|
-
assert_nil create_internal.final_shape(:text_block_hidden)
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_final_shape_should_return_shape_when_shape_isnot_stored_in_shapes_and_not_Block
|
112
|
-
assert_equal create_internal.final_shape(:rect_with_id).id, 'rect_with_id'
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_final_shape_should_return_nil_when_shape_isnot_stored_in_shapes_and_ImageBlock
|
116
|
-
internal = create_internal do |f|
|
117
|
-
f.shapes[:iblock] = create_shape_format('image-block', 'iblock')
|
118
|
-
end
|
119
|
-
|
120
|
-
assert_nil internal.final_shape(:iblock)
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_final_shape_should_return_shape_when_shape_isnot_stored_in_shapes_and_TextBlock_with_reference
|
124
|
-
assert_equal create_internal.final_shape(:text_block_referenced).id, 'text_block_referenced'
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_final_shape_should_return_nil_when_shape_isnot_stored_in_shapes_and_TextBlock_with_no_value_no_reference
|
128
|
-
internal = create_internal
|
129
|
-
|
130
|
-
assert_nil internal.final_shape(:t1)
|
131
|
-
end
|
132
|
-
end
|
@@ -1,140 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::Manager::TestTarget < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
# Alias
|
9
|
-
Shape = Thinreports::Core::Shape
|
10
|
-
|
11
|
-
class TestManager
|
12
|
-
include Shape::Manager::Target
|
13
|
-
|
14
|
-
attr_reader :layout, :report
|
15
|
-
|
16
|
-
def initialize(report, layout)
|
17
|
-
@report = report
|
18
|
-
@layout = layout
|
19
|
-
|
20
|
-
initialize_manager(layout.format) do |f|
|
21
|
-
Shape::Interface(self, f)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def create_shape_format(type, id)
|
27
|
-
Shape::Format(type).new('id' => id, 'type' => type)
|
28
|
-
end
|
29
|
-
|
30
|
-
def create_manager
|
31
|
-
report = Thinreports::Report.new layout: layout_file.path
|
32
|
-
layout = report.layout
|
33
|
-
|
34
|
-
TestManager.new(report, layout)
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_shorthand_for_finding_item
|
38
|
-
manager = create_manager
|
39
|
-
|
40
|
-
text_block1 = manager[:text_block]
|
41
|
-
text_block1.value = 'block1'
|
42
|
-
|
43
|
-
assert_instance_of Shape::TextBlock::Interface, manager[:text_block]
|
44
|
-
assert_instance_of Shape::ImageBlock::Interface, manager[:image_block]
|
45
|
-
assert_instance_of Shape::Basic::Interface, manager[:rect_with_id]
|
46
|
-
|
47
|
-
assert_raises Thinreports::Errors::UnknownItemId do
|
48
|
-
manager[:unknown_id]
|
49
|
-
end
|
50
|
-
|
51
|
-
assert_raises Thinreports::Errors::UnknownItemId do
|
52
|
-
manager[:default]
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_shorthand_for_setting_value_to_block
|
57
|
-
manager = create_manager
|
58
|
-
|
59
|
-
manager[:text_block] = 'value of text block1'
|
60
|
-
assert_equal 'value of text block1', manager.item(:text_block).value
|
61
|
-
|
62
|
-
manager[:image_block] = '/path/to/image.png'
|
63
|
-
assert_equal '/path/to/image.png', manager.item(:image_block).src
|
64
|
-
|
65
|
-
assert_raises(NoMethodError) { manager[:rect_with_id] = 'value' }
|
66
|
-
assert_raises(Thinreports::Errors::UnknownItemId) { manager[:default] = 'value' }
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_manager_should_return_instance_of_ManagerInternal
|
70
|
-
assert_instance_of Shape::Manager::Internal, create_manager.manager
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_item_should_properly_return_shape_with_the_specified_Symbol_id
|
74
|
-
assert_equal create_manager.item(:text_block).id, 'text_block'
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_item_should_properly_return_shape_with_the_specified_String_id
|
78
|
-
assert_equal create_manager.item('text_block').id, 'text_block'
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_item_should_raise_when_the_shape_with_the_specified_id_is_not_found
|
82
|
-
assert_raises Thinreports::Errors::UnknownItemId do
|
83
|
-
create_manager.item(:unknown)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_item_should_set_an_shape_as_argument_when_a_block_is_given
|
88
|
-
id = nil
|
89
|
-
create_manager.item(:text_block) {|s| id = s.id }
|
90
|
-
assert_equal id, 'text_block'
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_item_should_raise_when_type_of_shape_with_the_specified_id_is_list
|
94
|
-
assert_raises Thinreports::Errors::UnknownItemId do
|
95
|
-
create_manager.item(:default)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
def test_list_should_properly_return_list_with_the_specified_Symbol_id
|
100
|
-
assert_equal create_manager.list(:default).id, 'default'
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_list_should_properly_return_list_with_the_specified_String_id
|
104
|
-
assert_equal create_manager.list('default').id, 'default'
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_list_should_raise_when_type_of_shape_with_the_specified_id_is_not_list
|
108
|
-
assert_raises Thinreports::Errors::UnknownItemId do
|
109
|
-
create_manager.list(:text_block)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_list_should_use_default_as_id_when_id_is_omitted
|
114
|
-
assert_equal create_manager.list.id, 'default'
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_values_should_properly_set_values_to_shapes_with_specified_id
|
118
|
-
manager = create_manager
|
119
|
-
manager.values(text_block: 1000)
|
120
|
-
|
121
|
-
assert_equal manager.item(:text_block).value, 1000
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_item_exists_asker_should_return_true_when_shape_with_specified_Symbol_id_is_found
|
125
|
-
assert_equal create_manager.item_exists?(:text_block), true
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_item_exists_asker_should_return_true_when_shape_with_specified_String_id_is_found
|
129
|
-
assert_equal create_manager.item_exists?('text_block'), true
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_item_exists_asker_should_return_false_when_shape_with_specified_id_not_found
|
133
|
-
assert_equal create_manager.item_exists?('unknown'), false
|
134
|
-
end
|
135
|
-
|
136
|
-
def test_exists_asker_should_operate_like_as_item_exists_asker
|
137
|
-
manager = create_manager
|
138
|
-
assert_equal manager.exists?(:unknown), manager.item_exists?(:unknown)
|
139
|
-
end
|
140
|
-
end
|
@@ -1,55 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::PageNumber::TestFormat < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
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'
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
PageNumber = Thinreports::Core::Shape::PageNumber
|
31
|
-
|
32
|
-
def test_attribute_readers
|
33
|
-
format = PageNumber::Format.new(PAGE_NUMBER_FORMAT)
|
34
|
-
|
35
|
-
assert_equal 'truncate', format.overflow
|
36
|
-
assert_equal '', format.target
|
37
|
-
assert_equal '{page} / {total}', format.default_format
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_id
|
41
|
-
format = PageNumber::Format.new(PAGE_NUMBER_FORMAT)
|
42
|
-
assert_match(/^__pageno\d+$/, format.id)
|
43
|
-
|
44
|
-
format = PageNumber::Format.new(PAGE_NUMBER_FORMAT.merge('id' => 'foo'))
|
45
|
-
assert_equal 'foo', format.id
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_for_report?
|
49
|
-
format_for_report = PageNumber::Format.new(PAGE_NUMBER_FORMAT)
|
50
|
-
assert_equal true, format_for_report.for_report?
|
51
|
-
|
52
|
-
format_for_list = PageNumber::Format.new(PAGE_NUMBER_FORMAT.merge('target' => 'target_list_id'))
|
53
|
-
assert_equal false, format_for_list.for_report?
|
54
|
-
end
|
55
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::PageNumber::TestInterface < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
PageNumber = Thinreports::Core::Shape::PageNumber
|
9
|
-
|
10
|
-
def create_pageno(format = {})
|
11
|
-
report = Thinreports::Report.new layout: layout_file.path
|
12
|
-
parent = report.start_new_page
|
13
|
-
|
14
|
-
PageNumber::Interface.new parent, PageNumber::Format.new(format)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_format
|
18
|
-
pageno = create_pageno 'format' => '{page}'
|
19
|
-
|
20
|
-
assert_equal pageno.format, '{page}'
|
21
|
-
pageno.format('{page} / {total}')
|
22
|
-
assert_equal pageno.format, '{page} / {total}'
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_reset_format
|
26
|
-
pageno = create_pageno 'format' => '{page}'
|
27
|
-
|
28
|
-
pageno.format('-- {page} --')
|
29
|
-
pageno.reset_format
|
30
|
-
|
31
|
-
assert_equal pageno.format, '{page}'
|
32
|
-
end
|
33
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::PageNumber::TestInternal < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
PageNumber = Thinreports::Core::Shape::PageNumber
|
9
|
-
|
10
|
-
def setup
|
11
|
-
@report = Thinreports::Report.new layout: layout_file.path
|
12
|
-
@report.start_new_page
|
13
|
-
end
|
14
|
-
|
15
|
-
def init_pageno(format = {})
|
16
|
-
PageNumber::Internal.new(@report.page, PageNumber::Format.new(format))
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_read_format
|
20
|
-
pageno = init_pageno('format' => 'Page {page}')
|
21
|
-
|
22
|
-
assert_equal pageno.read_format, 'Page {page}'
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_write_format
|
26
|
-
pageno = init_pageno('format' => 'Page {page}')
|
27
|
-
pageno.write_format('{page}')
|
28
|
-
|
29
|
-
assert_equal pageno.read_format, '{page}'
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_reset_format
|
33
|
-
pageno = init_pageno('format' => '{page}')
|
34
|
-
pageno.write_format('Page {page}')
|
35
|
-
pageno.reset_format
|
36
|
-
|
37
|
-
assert_equal pageno.read_format, '{page}'
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_build_format
|
41
|
-
pageno = init_pageno('format' => '{page} / {total}')
|
42
|
-
assert_equal pageno.build_format(1, 100), '1 / 100'
|
43
|
-
|
44
|
-
pageno.write_format('{page}')
|
45
|
-
assert_equal pageno.build_format(1, 100), '1'
|
46
|
-
|
47
|
-
@report.start_page_number_from 5
|
48
|
-
pageno = init_pageno('format' => '{page} / {total}')
|
49
|
-
assert_equal pageno.build_format(1, 100), '5 / 104'
|
50
|
-
|
51
|
-
# if counted target is a List shape
|
52
|
-
pageno = init_pageno('format' => '{page} / {total}',
|
53
|
-
'target' => 'list-id')
|
54
|
-
assert_equal pageno.build_format(1, 100), '1 / 100'
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_type_of
|
58
|
-
pageno = init_pageno
|
59
|
-
assert pageno.type_of?('page-number')
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_style
|
63
|
-
pageno = init_pageno
|
64
|
-
style = pageno.style
|
65
|
-
|
66
|
-
assert_instance_of PageNumber::Style, style
|
67
|
-
assert_same pageno.style, style
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_for_report
|
71
|
-
pageno = init_pageno('target' => '')
|
72
|
-
assert_equal pageno.for_report?, true
|
73
|
-
|
74
|
-
pageno = init_pageno('target' => 'list-id')
|
75
|
-
assert_equal pageno.for_report?, false
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_Style_class
|
79
|
-
refute_includes PageNumber::Style.accessible_styles, :valign
|
80
|
-
end
|
81
|
-
end
|