thinreports 0.8.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -4,16 +4,16 @@ require 'test_helper'
|
|
4
4
|
|
5
5
|
class Thinreports::Core::Shape::Text::TestInternal < Minitest::Test
|
6
6
|
include Thinreports::TestHelper
|
7
|
-
|
7
|
+
|
8
8
|
Text = Thinreports::Core::Shape::Text
|
9
|
-
|
9
|
+
|
10
10
|
def create_internal(format_config = {})
|
11
|
-
report =
|
11
|
+
report = Thinreports::Report.new layout: layout_file.path
|
12
12
|
Text::Internal.new(report.start_new_page, Text::Format.new(format_config))
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def test_type_of?
|
16
|
-
assert create_internal.type_of?(
|
16
|
+
assert create_internal.type_of?('text'), true
|
17
17
|
refute create_internal.type_of?(:basic), false
|
18
18
|
end
|
19
19
|
|
@@ -4,16 +4,16 @@ require 'test_helper'
|
|
4
4
|
|
5
5
|
class Thinreports::Core::Shape::TextBlock::Formatter::TestDatetime < Minitest::Test
|
6
6
|
include Thinreports::TestHelper
|
7
|
-
|
7
|
+
|
8
8
|
# Aliases
|
9
9
|
TextBlock = Thinreports::Core::Shape::TextBlock
|
10
10
|
Formatter = TextBlock::Formatter::Datetime
|
11
|
-
|
11
|
+
|
12
12
|
def setup
|
13
13
|
@datetime_format = '%Y/%m/%d %H:%M:%S'
|
14
14
|
@time = Time.now
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def text_block_format(format = {})
|
18
18
|
default = {'base' => '', 'datetime' => {'format' => '%Y/%m/%d %H:%M:%S'}}
|
19
19
|
TextBlock::Format.new('format' => default.merge(format))
|
@@ -21,29 +21,29 @@ class Thinreports::Core::Shape::TextBlock::Formatter::TestDatetime < Minitest::T
|
|
21
21
|
|
22
22
|
def test_apply_datetime_format_without_basic_format
|
23
23
|
formatter = Formatter.new(text_block_format)
|
24
|
-
|
25
|
-
assert_equal @time.strftime(@datetime_format),
|
24
|
+
|
25
|
+
assert_equal @time.strftime(@datetime_format),
|
26
26
|
formatter.apply(@time)
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def test_apply_datetime_format_with_basic_format
|
30
30
|
formatter = Formatter.new(text_block_format('base' => 'Now: {value}'))
|
31
|
-
|
32
|
-
assert_equal "Now: #{@time.strftime(@datetime_format)}",
|
31
|
+
|
32
|
+
assert_equal "Now: #{@time.strftime(@datetime_format)}",
|
33
33
|
formatter.apply(@time)
|
34
|
-
|
34
|
+
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def test_not_apply_datetime_format_and_return_raw_value
|
38
38
|
# When value is invalid
|
39
39
|
formatter = Formatter.new(text_block_format)
|
40
|
-
|
40
|
+
|
41
41
|
assert_same formatter.apply(val = 'invalid value'), val
|
42
42
|
assert_same formatter.apply(val = 123456), val
|
43
|
-
|
43
|
+
|
44
44
|
# When format is empty
|
45
45
|
formatter = Formatter.new(text_block_format('datetime' => {'format' => ''}))
|
46
|
-
|
46
|
+
|
47
47
|
assert_same formatter.apply(@time), @time
|
48
48
|
end
|
49
49
|
end
|
@@ -5,166 +5,165 @@ require 'test_helper'
|
|
5
5
|
class Thinreports::Core::Shape::TextBlock::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
|
-
"delimiter" => ",",
|
26
|
-
"precision" => 1
|
8
|
+
TEXT_BLOCK_FORMAT = {
|
9
|
+
'id' => 'text_block',
|
10
|
+
'reference-id' => 'referenced_text_block',
|
11
|
+
'type' => 'text-block',
|
12
|
+
'display' => true,
|
13
|
+
'multiple-line' => false,
|
14
|
+
'x' => 100.0,
|
15
|
+
'y' => 200.0,
|
16
|
+
'width' => 300.0,
|
17
|
+
'height' => 400.0,
|
18
|
+
'value' => 'default value',
|
19
|
+
'format' => {
|
20
|
+
'base' => 'Price: {value}',
|
21
|
+
'type' => 'number',
|
22
|
+
'number' => {
|
23
|
+
'delimiter' => ',',
|
24
|
+
'precision' => 1
|
27
25
|
}
|
28
26
|
},
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
"font-weight" => "bold",
|
43
|
-
"font-style" => "normal",
|
44
|
-
"text-decoration" => "none",
|
45
|
-
"clip-path" => "url(#_svgdef_0)"
|
46
|
-
}
|
27
|
+
'description' => 'Description for item',
|
28
|
+
'style' => {
|
29
|
+
'word-wrap' => 'break-word',
|
30
|
+
'overflow' => 'truncate',
|
31
|
+
'text-align' => 'right',
|
32
|
+
'vertical-align' => 'middle',
|
33
|
+
'color' => '#000000',
|
34
|
+
'font-size' => 12,
|
35
|
+
'font-family' => ['Helvetica'],
|
36
|
+
'font-style' => ['bold', 'italic', 'linethrough', 'underline'],
|
37
|
+
'letter-spacing' => 'normal',
|
38
|
+
'line-height' => 30,
|
39
|
+
'line-height-ratio' => 1.5
|
47
40
|
}
|
48
41
|
}
|
49
42
|
|
50
|
-
|
51
|
-
build_format
|
52
|
-
rescue => e
|
53
|
-
flunk exception_details(e, 'Building failed.')
|
54
|
-
end
|
43
|
+
TextBlock = Thinreports::Core::Shape::TextBlock
|
55
44
|
|
56
|
-
def
|
57
|
-
|
58
|
-
end
|
45
|
+
def test_attribute_readers
|
46
|
+
format = TextBlock::Format.new(TEXT_BLOCK_FORMAT)
|
59
47
|
|
60
|
-
|
61
|
-
assert_equal format
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
assert_equal format
|
66
|
-
|
67
|
-
|
68
|
-
def test_format_base_reader_via_TEST_TBLOCK_FORMAT
|
69
|
-
assert_equal format(TEST_TBLOCK_FORMAT).format_base, '¥{value}'
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_format_type_reader_via_TEST_TBLOCK_FORMAT
|
73
|
-
assert_equal format(TEST_TBLOCK_FORMAT).format_type, 'number'
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_box_reader_via_TEST_TBLOCK_FORMAT
|
77
|
-
assert_equal format(TEST_TBLOCK_FORMAT).box.values_at('x', 'y', 'width', 'height'),
|
78
|
-
[100.0, 100.0, 100.0, 100.0]
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_format_datetime_format_reader_via_TEST_TBLOCK_FORMAT
|
82
|
-
assert_nil format(TEST_TBLOCK_FORMAT).format_datetime_format
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_format_padding_char_reader_via_TEST_TBLOCK_FORMAT
|
86
|
-
assert_nil format(TEST_TBLOCK_FORMAT).format_padding_char
|
87
|
-
end
|
88
|
-
|
89
|
-
def test_format_padding_dir_reader_via_TEST_TBLOCK_FORMAT
|
90
|
-
assert_nil format(TEST_TBLOCK_FORMAT).format_padding_dir
|
91
|
-
end
|
92
|
-
|
93
|
-
def test_format_padding_length_via_TEST_TBLOCK_FORMAT
|
94
|
-
assert_equal format(TEST_TBLOCK_FORMAT).format_padding_length, 0
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_format_padding_rdir_checker_via_TEST_TBLOCK_FORMAT
|
98
|
-
assert_equal format(TEST_TBLOCK_FORMAT).format_padding_rdir?, false
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_format_has_format_asker_via_TEST_TBLOCK_FORMAT
|
102
|
-
assert_equal format(TEST_TBLOCK_FORMAT).has_format?, true
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_format_has_reference_asker_via_TEST_TBLOCK_FORMAT
|
106
|
-
assert_equal format(TEST_TBLOCK_FORMAT).has_reference?, false
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_format_multiple_checker_via_TEST_TBLOCK_FORMAT
|
110
|
-
assert_equal format(TEST_TBLOCK_FORMAT).multiple?, false
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_overflow_via_TEST_TBLOCK_FORMAT
|
114
|
-
assert_equal format(TEST_TBLOCK_FORMAT).overflow, 'truncate'
|
115
|
-
end
|
116
|
-
|
117
|
-
def test_multiple_checker_should_return_true
|
118
|
-
assert format('multiple' => 'true').multiple?
|
119
|
-
end
|
120
|
-
|
121
|
-
def test_multiple_checker_should_return_false
|
122
|
-
refute format('multiple' => 'false').multiple?
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_format_padding_rdir_checker_should_return_false
|
126
|
-
data = {'format' => {'padding' => {'direction' => 'L'}}}
|
127
|
-
refute format(data).format_padding_rdir?
|
128
|
-
end
|
129
|
-
|
130
|
-
def test_format_padding_rdir_checker_should_return_true
|
131
|
-
data = {'format' => {'padding' => {'direction' => 'R'}}}
|
132
|
-
assert format(data).format_padding_rdir?
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_format_padding_length_should_return_Numeric
|
136
|
-
data = {'format' => {'padding' => {'length' => '999'}}}
|
137
|
-
assert_kind_of ::Numeric, format(data).format_padding_length
|
48
|
+
assert_equal 'referenced_text_block', format.ref_id
|
49
|
+
assert_equal 'middle', format.valign
|
50
|
+
assert_equal 'truncate', format.overflow
|
51
|
+
assert_equal 30, format.line_height
|
52
|
+
assert_equal false, format.multiple?
|
53
|
+
assert_equal 'Price: {value}', format.format_base
|
54
|
+
assert_equal 'number', format.format_type
|
138
55
|
end
|
139
56
|
|
140
|
-
def
|
141
|
-
|
142
|
-
|
57
|
+
def test_has_reference?
|
58
|
+
format_has_reference = TextBlock::Format.new(TEXT_BLOCK_FORMAT.merge('reference-id' => 'other'))
|
59
|
+
assert_equal true, format_has_reference.has_reference?
|
60
|
+
|
61
|
+
format_has_no_reference = TextBlock::Format.new(TEXT_BLOCK_FORMAT.merge('reference-id' => ''))
|
62
|
+
assert_equal false, format_has_no_reference.has_reference?
|
143
63
|
end
|
144
|
-
|
145
|
-
def
|
146
|
-
|
147
|
-
|
64
|
+
|
65
|
+
def test_has_format?
|
66
|
+
format_has_text_format = TextBlock::Format.new(TEXT_BLOCK_FORMAT.merge(
|
67
|
+
'format' => { 'type' => 'datetime' }
|
68
|
+
))
|
69
|
+
assert_equal true, format_has_text_format.has_format?
|
70
|
+
|
71
|
+
format_has_no_text_format = TextBlock::Format.new(TEXT_BLOCK_FORMAT.merge(
|
72
|
+
'format' => { 'type' => '' }
|
73
|
+
))
|
74
|
+
assert_equal false, format_has_no_text_format.has_format?
|
148
75
|
end
|
149
|
-
|
150
|
-
def
|
151
|
-
|
152
|
-
|
76
|
+
|
77
|
+
def test_number_format_attribute_readers
|
78
|
+
format = TextBlock::Format.new(TEXT_BLOCK_FORMAT.merge(
|
79
|
+
'format' => {
|
80
|
+
'type' => 'number',
|
81
|
+
'number' => {
|
82
|
+
'delimiter' => ',',
|
83
|
+
'precision' => 1
|
84
|
+
}
|
85
|
+
}
|
86
|
+
))
|
87
|
+
assert_equal ',', format.format_number_delimiter
|
88
|
+
assert_equal 1, format.format_number_precision
|
153
89
|
end
|
154
|
-
|
155
|
-
def
|
156
|
-
|
90
|
+
|
91
|
+
def test_datetime_format_attribute_readers
|
92
|
+
format = TextBlock::Format.new(TEXT_BLOCK_FORMAT.merge(
|
93
|
+
'format' => {
|
94
|
+
'type' => 'datetime',
|
95
|
+
'datetime' => {
|
96
|
+
'format' => '%Y-%m-%d'
|
97
|
+
}
|
98
|
+
}
|
99
|
+
))
|
100
|
+
assert_equal '%Y-%m-%d', format.format_datetime_format
|
157
101
|
end
|
158
|
-
|
159
|
-
def
|
160
|
-
|
102
|
+
|
103
|
+
def test_padding_format_attribute_readers
|
104
|
+
format = TextBlock::Format.new(TEXT_BLOCK_FORMAT.merge(
|
105
|
+
'format' => {
|
106
|
+
'type' => 'padding',
|
107
|
+
'padding' => {
|
108
|
+
'char' => '0',
|
109
|
+
'length' => 10,
|
110
|
+
'direction' => 'L'
|
111
|
+
}
|
112
|
+
}
|
113
|
+
))
|
114
|
+
assert_equal '0', format.format_padding_char
|
115
|
+
assert_equal 'L', format.format_padding_dir
|
161
116
|
end
|
162
|
-
|
163
|
-
def
|
164
|
-
|
117
|
+
|
118
|
+
def test_format_padding_length
|
119
|
+
format = TextBlock::Format.new(TEXT_BLOCK_FORMAT.merge(
|
120
|
+
'format' => {
|
121
|
+
'type' => 'padding',
|
122
|
+
'padding' => {
|
123
|
+
'char' => '0',
|
124
|
+
'length' => 10,
|
125
|
+
'direction' => 'L'
|
126
|
+
}
|
127
|
+
}
|
128
|
+
))
|
129
|
+
assert_equal 10, format.format_padding_length
|
130
|
+
|
131
|
+
format = TextBlock::Format.new(TEXT_BLOCK_FORMAT.merge(
|
132
|
+
'format' => {
|
133
|
+
'type' => 'padding',
|
134
|
+
'padding' => {
|
135
|
+
'char' => '0',
|
136
|
+
'length' => '',
|
137
|
+
'direction' => 'L'
|
138
|
+
}
|
139
|
+
}
|
140
|
+
))
|
141
|
+
assert_equal 0, format.format_padding_length
|
165
142
|
end
|
166
|
-
|
167
|
-
def
|
168
|
-
|
143
|
+
|
144
|
+
def test_format_padding_rdir?
|
145
|
+
format_direction_left = TextBlock::Format.new(TEXT_BLOCK_FORMAT.merge(
|
146
|
+
'format' => {
|
147
|
+
'type' => 'padding',
|
148
|
+
'padding' => {
|
149
|
+
'char' => '0',
|
150
|
+
'length' => 10,
|
151
|
+
'direction' => 'L'
|
152
|
+
}
|
153
|
+
}
|
154
|
+
))
|
155
|
+
assert_equal false, format_direction_left.format_padding_rdir?
|
156
|
+
|
157
|
+
format_direction_right = TextBlock::Format.new(TEXT_BLOCK_FORMAT.merge(
|
158
|
+
'format' => {
|
159
|
+
'type' => 'padding',
|
160
|
+
'padding' => {
|
161
|
+
'char' => '0',
|
162
|
+
'length' => 10,
|
163
|
+
'direction' => 'R'
|
164
|
+
}
|
165
|
+
}
|
166
|
+
))
|
167
|
+
assert_equal true, format_direction_right.format_padding_rdir?
|
169
168
|
end
|
170
169
|
end
|
@@ -9,7 +9,7 @@ class Thinreports::Core::Shape::TextBlock::TestInterface < Minitest::Test
|
|
9
9
|
TextBlock = Thinreports::Core::Shape::TextBlock
|
10
10
|
|
11
11
|
def create_interface(format_config = {})
|
12
|
-
report =
|
12
|
+
report = Thinreports::Report.new layout: layout_file.path
|
13
13
|
parent = report.start_new_page
|
14
14
|
|
15
15
|
TextBlock::Interface.new parent, TextBlock::Format.new(format_config)
|
@@ -47,17 +47,17 @@ class Thinreports::Core::Shape::TextBlock::TestInterface < Minitest::Test
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_value=
|
50
|
-
report =
|
50
|
+
report = Thinreports::Report.new layout: layout_file.path
|
51
51
|
page = report.start_new_page
|
52
52
|
|
53
|
-
page.item(:
|
54
|
-
assert_equal 'foo', page.item(:
|
53
|
+
page.item(:text_block).value = 'foo'
|
54
|
+
assert_equal 'foo', page.item(:text_block).value
|
55
55
|
|
56
|
-
page.item(:
|
57
|
-
assert_equal 'foobar', page.item(:
|
56
|
+
page.item(:text_block).value += 'bar'
|
57
|
+
assert_equal 'foobar', page.item(:text_block).value
|
58
58
|
|
59
|
-
page.item(:
|
60
|
-
page.item(:
|
61
|
-
assert_equal 1999, page.item(:
|
59
|
+
page.item(:text_block).value = 1000
|
60
|
+
page.item(:text_block).value += 999
|
61
|
+
assert_equal 1999, page.item(:text_block).value
|
62
62
|
end
|
63
63
|
end
|
@@ -9,10 +9,10 @@ class Thinreports::Core::Shape::TextBlock::TestInternal < Minitest::Test
|
|
9
9
|
TextBlock = Thinreports::Core::Shape::TextBlock
|
10
10
|
|
11
11
|
def create_parent
|
12
|
-
report =
|
12
|
+
report = Thinreports::Report.new layout: layout_file.path
|
13
13
|
report.start_new_page do |page|
|
14
14
|
# Add to force TextBlock shape.
|
15
|
-
page.manager.format.shapes[:foo] = TextBlock::Format.new('type' => '
|
15
|
+
page.manager.format.shapes[:foo] = TextBlock::Format.new('type' => 'text-block',
|
16
16
|
'id' => 'foo')
|
17
17
|
# Set value to TextBlock.
|
18
18
|
page.item(:foo).value('foo value')
|
@@ -24,7 +24,7 @@ class Thinreports::Core::Shape::TextBlock::TestInternal < Minitest::Test
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_multiple_asker_should_operate_as_delegator_of_format
|
27
|
-
tblock = create_internal('multiple' =>
|
27
|
+
tblock = create_internal('multiple-line' => true)
|
28
28
|
assert_equal tblock.multiple?, tblock.format.multiple?
|
29
29
|
end
|
30
30
|
|
@@ -38,7 +38,7 @@ class Thinreports::Core::Shape::TextBlock::TestInternal < Minitest::Test
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_read_value_should_return_the_value_of_referenced_shape
|
41
|
-
tblock = create_internal('
|
41
|
+
tblock = create_internal('reference-id' => 'foo', 'value' => '')
|
42
42
|
assert_equal tblock.read_value, 'foo value'
|
43
43
|
end
|
44
44
|
|
@@ -57,7 +57,7 @@ class Thinreports::Core::Shape::TextBlock::TestInternal < Minitest::Test
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_write_value_should_show_warnings_when_tblock_has_reference
|
60
|
-
tblock = create_internal('id' => 'bar', '
|
60
|
+
tblock = create_internal('id' => 'bar', 'reference-id' => 'foo')
|
61
61
|
_out, err = capture_io do
|
62
62
|
tblock.write_value('value')
|
63
63
|
end
|
@@ -104,16 +104,16 @@ class Thinreports::Core::Shape::TextBlock::TestInternal < Minitest::Test
|
|
104
104
|
end
|
105
105
|
|
106
106
|
def test_format_enabled_asker_should_return_false_constantly_when_tblock_is_multiple_mode
|
107
|
-
tblock = create_internal('multiple' =>
|
108
|
-
'format'
|
109
|
-
|
107
|
+
tblock = create_internal('multiple-line' => true,
|
108
|
+
'format' => {'base' => '{value}',
|
109
|
+
'type' => 'number'})
|
110
110
|
tblock.format_enabled(true)
|
111
111
|
|
112
112
|
assert_equal tblock.format_enabled?, false
|
113
113
|
end
|
114
114
|
|
115
115
|
def test_type_of_asker_should_return_true_when_value_is_tblock
|
116
|
-
assert_equal create_internal.type_of?(
|
116
|
+
assert_equal create_internal.type_of?('text-block'), true
|
117
117
|
end
|
118
118
|
|
119
119
|
def test_type_of_asker_should_return_true_when_value_is_block
|