thinreports 0.10.3 → 0.11.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/workflows/test.yml +39 -0
- data/CHANGELOG.md +20 -0
- data/Dockerfile +12 -0
- data/Gemfile +5 -0
- data/README.md +37 -13
- data/Rakefile +1 -0
- data/lib/thinreports/core/shape/image_block.rb +1 -1
- data/lib/thinreports/core/shape/list.rb +1 -1
- data/lib/thinreports/core/shape/page_number.rb +1 -1
- data/lib/thinreports/core/shape/text.rb +1 -1
- data/lib/thinreports/core/shape/text_block.rb +1 -1
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +6 -1
- data/lib/thinreports/core/shape/text_block/internal.rb +0 -2
- data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +6 -0
- data/lib/thinreports/layout/base.rb +1 -1
- data/lib/thinreports/layout/version.rb +1 -1
- data/lib/thinreports/report/internal.rb +2 -0
- data/lib/thinreports/version.rb +1 -1
- data/thinreports.gemspec +5 -9
- metadata +6 -204
- data/.travis.yml +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/features/dynamic_style/expect.pdf +0 -3714
- data/test/features/dynamic_style/image.png +0 -0
- data/test/features/dynamic_style/templates/styles.tlf +0 -1835
- data/test/features/dynamic_style/templates/styles_in_list.tlf +0 -344
- data/test/features/dynamic_style/test_dynamic_style.rb +0 -152
- data/test/features/eudc/eudc.ttf +0 -0
- data/test/features/eudc/expect.pdf +0 -0
- data/test/features/eudc/template.tlf +0 -180
- data/test/features/eudc/test_eudc.rb +0 -27
- data/test/features/feature_test.rb +0 -58
- data/test/features/graphics/expect.pdf +0 -475
- data/test/features/graphics/template.tlf +0 -309
- data/test/features/graphics/test_graphics.rb +0 -12
- data/test/features/hidden_item/expect.pdf +0 -0
- data/test/features/hidden_item/template.tlf +0 -449
- data/test/features/hidden_item/test_hidden_item.rb +0 -12
- data/test/features/image_block/expect.pdf +0 -0
- data/test/features/image_block/img200x100.png +0 -0
- data/test/features/image_block/img50x50.png +0 -0
- data/test/features/image_block/template.tlf +0 -661
- data/test/features/image_block/test_image_block.rb +0 -35
- data/test/features/list_events/expect.pdf +0 -659
- data/test/features/list_events/template.tlf +0 -361
- data/test/features/list_events/test_list_events.rb +0 -36
- data/test/features/list_manually/expect.pdf +0 -599
- data/test/features/list_manually/template.tlf +0 -132
- data/test/features/list_manually/test_list_manually.rb +0 -25
- data/test/features/page_number/expect.pdf +0 -400
- data/test/features/page_number/template.tlf +0 -215
- data/test/features/page_number/test_page_number.rb +0 -24
- data/test/features/page_number_with_list/expect.pdf +0 -721
- data/test/features/page_number_with_list/template.tlf +0 -254
- data/test/features/page_number_with_list/test_page_number_with_list.rb +0 -21
- data/test/features/palleted_png/expect.pdf +0 -0
- data/test/features/palleted_png/palleted_png.png +0 -0
- data/test/features/palleted_png/template.tlf +0 -47
- data/test/features/palleted_png/test_palleted_png.rb +0 -14
- data/test/features/report_callbacks/expect.pdf +0 -169
- data/test/features/report_callbacks/template.tlf +0 -147
- data/test/features/report_callbacks/test_report_callbacks.rb +0 -18
- data/test/features/text_align/expect.pdf +0 -0
- data/test/features/text_align/template.tlf +0 -241
- data/test/features/text_align/test_text_align.rb +0 -12
- data/test/features/text_block_overflow/expect.pdf +0 -0
- data/test/features/text_block_overflow/template.tlf +0 -538
- data/test/features/text_block_overflow/test_text_block_overflow.rb +0 -25
- data/test/features/text_block_singleline/expect.pdf +0 -0
- data/test/features/text_block_singleline/template.tlf +0 -170
- data/test/features/text_block_singleline/test_text_block_singleline.rb +0 -15
- data/test/features/text_block_style/expect.pdf +0 -1391
- data/test/features/text_block_style/templates/basic_styles.tlf +0 -889
- data/test/features/text_block_style/templates/font_size.tlf +0 -383
- data/test/features/text_block_style/test_text_block_style.rb +0 -47
- data/test/features/text_character_spacing/expect.pdf +0 -0
- data/test/features/text_character_spacing/template.tlf +0 -293
- data/test/features/text_character_spacing/test_text_character_spacing.rb +0 -12
- data/test/features/text_word_wrap/expect.pdf +0 -0
- data/test/features/text_word_wrap/template.tlf +0 -297
- data/test/features/text_word_wrap/test_text_word_wrap.rb +0 -30
- data/test/schema_helper.rb +0 -122
- data/test/test_helper.rb +0 -39
- data/test/units/core/format/test_base.rb +0 -152
- data/test/units/core/shape/base/test_internal.rb +0 -87
- data/test/units/core/shape/basic/test_block_format.rb +0 -23
- data/test/units/core/shape/basic/test_block_interface.rb +0 -29
- data/test/units/core/shape/basic/test_block_internal.rb +0 -55
- data/test/units/core/shape/basic/test_format.rb +0 -37
- data/test/units/core/shape/basic/test_interface.rb +0 -108
- data/test/units/core/shape/basic/test_internal.rb +0 -55
- data/test/units/core/shape/image_block/test_interface.rb +0 -24
- data/test/units/core/shape/image_block/test_internal.rb +0 -31
- data/test/units/core/shape/list/test_format.rb +0 -111
- data/test/units/core/shape/list/test_manager.rb +0 -67
- data/test/units/core/shape/list/test_page.rb +0 -156
- data/test/units/core/shape/list/test_page_state.rb +0 -31
- data/test/units/core/shape/list/test_section_format.rb +0 -36
- data/test/units/core/shape/list/test_section_interface.rb +0 -75
- data/test/units/core/shape/list/test_section_internal.rb +0 -50
- data/test/units/core/shape/manager/test_format.rb +0 -38
- data/test/units/core/shape/manager/test_internal.rb +0 -132
- data/test/units/core/shape/manager/test_target.rb +0 -140
- data/test/units/core/shape/page_number/test_format.rb +0 -55
- data/test/units/core/shape/page_number/test_interface.rb +0 -33
- data/test/units/core/shape/page_number/test_internal.rb +0 -81
- data/test/units/core/shape/styles/test_base.rb +0 -191
- data/test/units/core/shape/styles/test_basic.rb +0 -24
- data/test/units/core/shape/styles/test_graphic.rb +0 -50
- data/test/units/core/shape/styles/test_text.rb +0 -97
- data/test/units/core/shape/text/test_format.rb +0 -44
- data/test/units/core/shape/text/test_internal.rb +0 -20
- data/test/units/core/shape/text_block/formatter/test_basic.rb +0 -24
- data/test/units/core/shape/text_block/formatter/test_datetime.rb +0 -49
- data/test/units/core/shape/text_block/formatter/test_number.rb +0 -76
- data/test/units/core/shape/text_block/formatter/test_padding.rb +0 -77
- data/test/units/core/shape/text_block/test_format.rb +0 -169
- data/test/units/core/shape/text_block/test_formatter.rb +0 -28
- data/test/units/core/shape/text_block/test_interface.rb +0 -63
- data/test/units/core/shape/text_block/test_internal.rb +0 -128
- data/test/units/core/test_shape.rb +0 -52
- data/test/units/core/test_utils.rb +0 -68
- data/test/units/generator/pdf/document/graphics/test_attributes.rb +0 -135
- data/test/units/generator/pdf/document/graphics/test_basic.rb +0 -46
- data/test/units/generator/pdf/document/graphics/test_image.rb +0 -46
- data/test/units/generator/pdf/document/graphics/test_text.rb +0 -171
- data/test/units/generator/pdf/document/test_font.rb +0 -110
- data/test/units/generator/pdf/document/test_graphics.rb +0 -42
- data/test/units/generator/pdf/document/test_page.rb +0 -122
- data/test/units/generator/pdf/document/test_parse_color.rb +0 -30
- data/test/units/generator/pdf/prawn_ext/test_calc_image_dimensions.rb +0 -41
- data/test/units/generator/pdf/prawn_ext/test_width_of.rb +0 -22
- data/test/units/generator/pdf/test_document.rb +0 -22
- data/test/units/generator/test_pdf.rb +0 -26
- data/test/units/layout/test_base.rb +0 -41
- data/test/units/layout/test_format.rb +0 -100
- data/test/units/layout/test_legacy_schema.rb +0 -576
- data/test/units/layout/test_version.rb +0 -26
- data/test/units/report/test_base.rb +0 -248
- data/test/units/report/test_internal.rb +0 -206
- data/test/units/test_config.rb +0 -36
- data/test/units/test_layout.rb +0 -12
- data/test/units/test_report.rb +0 -18
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'test_helper'
|
|
4
|
-
|
|
5
|
-
class Thinreports::Core::Shape::Text::TestFormat < Minitest::Test
|
|
6
|
-
include Thinreports::TestHelper
|
|
7
|
-
|
|
8
|
-
TEXT_FORMAT = {
|
|
9
|
-
'id' => 'text_1',
|
|
10
|
-
'type' => 'text',
|
|
11
|
-
'x' => 100.0,
|
|
12
|
-
'y' => 200.0,
|
|
13
|
-
'width' => 300.0,
|
|
14
|
-
'height' => 400.0,
|
|
15
|
-
'description' => 'Description for item',
|
|
16
|
-
'display' => true,
|
|
17
|
-
'texts' => [
|
|
18
|
-
'1st text line',
|
|
19
|
-
'2nd text line'
|
|
20
|
-
],
|
|
21
|
-
'valign' => 'top',
|
|
22
|
-
'style' => {
|
|
23
|
-
'font-family' => ['Arial'],
|
|
24
|
-
'font-size' => 12,
|
|
25
|
-
'color' => '#000000',
|
|
26
|
-
'font-style' => ['bold', 'italic', 'linethrough', 'underline'],
|
|
27
|
-
'text-align' => 'left',
|
|
28
|
-
'vertical-align' => 'top',
|
|
29
|
-
'line-height' => 60,
|
|
30
|
-
'line-height-ratio' => 1.5,
|
|
31
|
-
'letter-spacing' => 'normal'
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
Text = Thinreports::Core::Shape::Text
|
|
36
|
-
|
|
37
|
-
def test_attribute_readers
|
|
38
|
-
format = Text::Format.new(TEXT_FORMAT)
|
|
39
|
-
|
|
40
|
-
assert_equal TEXT_FORMAT['texts'], format.texts
|
|
41
|
-
assert_equal 'top', format.valign
|
|
42
|
-
assert_equal 60, format.line_height
|
|
43
|
-
end
|
|
44
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'test_helper'
|
|
4
|
-
|
|
5
|
-
class Thinreports::Core::Shape::Text::TestInternal < Minitest::Test
|
|
6
|
-
include Thinreports::TestHelper
|
|
7
|
-
|
|
8
|
-
Text = Thinreports::Core::Shape::Text
|
|
9
|
-
|
|
10
|
-
def create_internal(format_config = {})
|
|
11
|
-
report = Thinreports::Report.new layout: layout_file.path
|
|
12
|
-
Text::Internal.new(report.start_new_page, Text::Format.new(format_config))
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def test_type_of?
|
|
16
|
-
assert create_internal.type_of?('text'), true
|
|
17
|
-
refute create_internal.type_of?(:basic), false
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'test_helper'
|
|
4
|
-
|
|
5
|
-
class Thinreports::Core::Shape::TextBlock::Formatter::TestBasic < Minitest::Test
|
|
6
|
-
include Thinreports::TestHelper
|
|
7
|
-
|
|
8
|
-
# Alias
|
|
9
|
-
Formatter = Thinreports::Core::Shape::TextBlock::Formatter::Basic
|
|
10
|
-
|
|
11
|
-
def test_apply_simple_format
|
|
12
|
-
format = stub(format_base: 'Hello {value}!')
|
|
13
|
-
|
|
14
|
-
assert_equal Formatter.new(format).apply('Thinreports'),
|
|
15
|
-
'Hello Thinreports!'
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def test_apply_multiple_format
|
|
19
|
-
format = stub(format_base: 'Hello {value}! And good bye {value}.')
|
|
20
|
-
|
|
21
|
-
assert_equal Formatter.new(format).apply('Thinreports'),
|
|
22
|
-
'Hello Thinreports! And good bye Thinreports.'
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'test_helper'
|
|
4
|
-
|
|
5
|
-
class Thinreports::Core::Shape::TextBlock::Formatter::TestDatetime < Minitest::Test
|
|
6
|
-
include Thinreports::TestHelper
|
|
7
|
-
|
|
8
|
-
# Aliases
|
|
9
|
-
TextBlock = Thinreports::Core::Shape::TextBlock
|
|
10
|
-
Formatter = TextBlock::Formatter::Datetime
|
|
11
|
-
|
|
12
|
-
def setup
|
|
13
|
-
@datetime_format = '%Y/%m/%d %H:%M:%S'
|
|
14
|
-
@time = Time.now
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def text_block_format(format = {})
|
|
18
|
-
default = {'base' => '', 'datetime' => {'format' => '%Y/%m/%d %H:%M:%S'}}
|
|
19
|
-
TextBlock::Format.new('format' => default.merge(format))
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def test_apply_datetime_format_without_basic_format
|
|
23
|
-
formatter = Formatter.new(text_block_format)
|
|
24
|
-
|
|
25
|
-
assert_equal @time.strftime(@datetime_format),
|
|
26
|
-
formatter.apply(@time)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def test_apply_datetime_format_with_basic_format
|
|
30
|
-
formatter = Formatter.new(text_block_format('base' => 'Now: {value}'))
|
|
31
|
-
|
|
32
|
-
assert_equal "Now: #{@time.strftime(@datetime_format)}",
|
|
33
|
-
formatter.apply(@time)
|
|
34
|
-
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def test_not_apply_datetime_format_and_return_raw_value
|
|
38
|
-
# When value is invalid
|
|
39
|
-
formatter = Formatter.new(text_block_format)
|
|
40
|
-
|
|
41
|
-
assert_same formatter.apply(val = 'invalid value'), val
|
|
42
|
-
assert_same formatter.apply(val = 123456), val
|
|
43
|
-
|
|
44
|
-
# When format is empty
|
|
45
|
-
formatter = Formatter.new(text_block_format('datetime' => {'format' => ''}))
|
|
46
|
-
|
|
47
|
-
assert_same formatter.apply(@time), @time
|
|
48
|
-
end
|
|
49
|
-
end
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'test_helper'
|
|
4
|
-
|
|
5
|
-
class Thinreports::Core::Shape::TextBlock::Formatter::TestNumber < Minitest::Test
|
|
6
|
-
include Thinreports::TestHelper
|
|
7
|
-
|
|
8
|
-
# Alias
|
|
9
|
-
Formatter = Thinreports::Core::Shape::TextBlock::Formatter::Number
|
|
10
|
-
|
|
11
|
-
def init_formatter(expect_formats)
|
|
12
|
-
format = stub({ format_base: '',
|
|
13
|
-
format_number_precision: nil,
|
|
14
|
-
format_number_delimiter: nil }.merge(expect_formats))
|
|
15
|
-
Formatter.new(format)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def test_apply_precision_formats
|
|
19
|
-
# When precision is 2
|
|
20
|
-
formatter = init_formatter(format_number_precision: 2)
|
|
21
|
-
|
|
22
|
-
assert_equal formatter.apply(1.005), '1.01'
|
|
23
|
-
assert_equal formatter.apply(1.004), '1.00'
|
|
24
|
-
assert_equal formatter.apply(1), '1.00'
|
|
25
|
-
# With String value
|
|
26
|
-
assert_equal formatter.apply('999.999'), '1000.00'
|
|
27
|
-
assert_equal formatter.apply('-999.999'), '-1000.00'
|
|
28
|
-
assert_equal formatter.apply('9'), '9.00'
|
|
29
|
-
# Cannot apply, Return the raw value
|
|
30
|
-
assert_equal formatter.apply('invalid value'), 'invalid value'
|
|
31
|
-
|
|
32
|
-
# When precision is 0
|
|
33
|
-
formatter = init_formatter(format_number_precision: 0)
|
|
34
|
-
|
|
35
|
-
assert_equal formatter.apply(1.5), '2'
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def test_apply_precision_format_with_basic_format
|
|
39
|
-
formatter = init_formatter(format_base: '$ {value}',
|
|
40
|
-
format_number_precision: 0)
|
|
41
|
-
|
|
42
|
-
assert_equal formatter.apply(199.5), '$ 200'
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def test_apply_delimiter_formats
|
|
46
|
-
# When delimiter is ','
|
|
47
|
-
formatter = init_formatter(format_number_delimiter: ',')
|
|
48
|
-
|
|
49
|
-
assert_equal formatter.apply(1000000), '1,000,000'
|
|
50
|
-
assert_equal formatter.apply(-1000000), '-1,000,000'
|
|
51
|
-
assert_equal formatter.apply('1000.0'), '1,000.0'
|
|
52
|
-
assert_equal formatter.apply('-1000.0'), '-1,000.0'
|
|
53
|
-
# Cannot apply, Return the raw value
|
|
54
|
-
assert_equal formatter.apply('invalid value'), 'invalid value'
|
|
55
|
-
|
|
56
|
-
# When delimiter is whitespace
|
|
57
|
-
formatter = init_formatter(format_number_delimiter: ' ')
|
|
58
|
-
|
|
59
|
-
assert_equal formatter.apply(99999), '99 999'
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def test_apply_delimiter_format_with_basic_format
|
|
63
|
-
formatter = init_formatter(format_base: '¥{value}',
|
|
64
|
-
format_number_delimiter: ',')
|
|
65
|
-
|
|
66
|
-
assert_equal formatter.apply(199800), '¥199,800'
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def test_apply_all_format
|
|
70
|
-
formatter = init_formatter(format_base: '-- {value} --',
|
|
71
|
-
format_number_delimiter: ',',
|
|
72
|
-
format_number_precision: 2)
|
|
73
|
-
|
|
74
|
-
assert_equal formatter.apply(95618.88567), '-- 95,618.89 --'
|
|
75
|
-
end
|
|
76
|
-
end
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'test_helper'
|
|
4
|
-
|
|
5
|
-
class Thinreports::Core::Shape::TextBlock::Formatter::TestPadding < Minitest::Test
|
|
6
|
-
include Thinreports::TestHelper
|
|
7
|
-
|
|
8
|
-
# Alias
|
|
9
|
-
Formatter = Thinreports::Core::Shape::TextBlock::Formatter::Padding
|
|
10
|
-
|
|
11
|
-
def init_formatter(expect_formats)
|
|
12
|
-
format = stub({ format_base: nil,
|
|
13
|
-
format_padding_length: 0,
|
|
14
|
-
format_padding_char: nil,
|
|
15
|
-
format_padding_rdir?: false }.merge(expect_formats))
|
|
16
|
-
Formatter.new(format)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_apply_padding_formats_with_left_direction
|
|
20
|
-
formatter = init_formatter(format_padding_length: 5,
|
|
21
|
-
format_padding_char: '0')
|
|
22
|
-
|
|
23
|
-
assert_equal formatter.apply(1), '00001'
|
|
24
|
-
assert_equal formatter.apply('日本語'), '00日本語'
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def test_apply_padding_formats_should_not_apply_when_character_length_is_short
|
|
28
|
-
formatter = init_formatter(format_padding_length: 5,
|
|
29
|
-
format_padding_char: '0')
|
|
30
|
-
|
|
31
|
-
assert_equal formatter.apply('1234567'), '1234567'
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def test_apply_padding_formats_with_right_direction
|
|
35
|
-
formatter = init_formatter(format_padding_length: 5,
|
|
36
|
-
format_padding_char: '0',
|
|
37
|
-
:format_padding_rdir? => true)
|
|
38
|
-
|
|
39
|
-
assert_equal formatter.apply(123), '12300'
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def test_apply_padding_format_with_basic_format
|
|
43
|
-
formatter = init_formatter(format_base: '[{value}]',
|
|
44
|
-
format_padding_length: 10,
|
|
45
|
-
format_padding_char: ' ')
|
|
46
|
-
|
|
47
|
-
assert_equal formatter.apply('ABC'), '[ ABC]'
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def test_return_raw_value_when_length_is_0
|
|
51
|
-
formatter = init_formatter(format_padding_length: 0,
|
|
52
|
-
format_padding_char: '0')
|
|
53
|
-
|
|
54
|
-
assert_same formatter.apply(v = 123), v
|
|
55
|
-
|
|
56
|
-
# But apply only basic format if have basic-format.
|
|
57
|
-
formatter = init_formatter(format_base: '<{value}>',
|
|
58
|
-
format_padding_length: 0,
|
|
59
|
-
format_padding_char: '0')
|
|
60
|
-
|
|
61
|
-
assert_equal formatter.apply(123), '<123>'
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def test_return_raw_value_when_char_is_empty
|
|
65
|
-
formatter = init_formatter(format_padding_length: 10,
|
|
66
|
-
format_padding_char: '')
|
|
67
|
-
|
|
68
|
-
assert_same formatter.apply(v = '1'), v
|
|
69
|
-
|
|
70
|
-
# But apply only basic format if have basic-format.
|
|
71
|
-
formatter = init_formatter(format_base: '<{value}>',
|
|
72
|
-
format_padding_length: 0,
|
|
73
|
-
format_padding_char: '0')
|
|
74
|
-
|
|
75
|
-
assert_equal formatter.apply('1'), '<1>'
|
|
76
|
-
end
|
|
77
|
-
end
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'test_helper'
|
|
4
|
-
|
|
5
|
-
class Thinreports::Core::Shape::TextBlock::TestFormat < Minitest::Test
|
|
6
|
-
include Thinreports::TestHelper
|
|
7
|
-
|
|
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
|
|
25
|
-
}
|
|
26
|
-
},
|
|
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
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
TextBlock = Thinreports::Core::Shape::TextBlock
|
|
44
|
-
|
|
45
|
-
def test_attribute_readers
|
|
46
|
-
format = TextBlock::Format.new(TEXT_BLOCK_FORMAT)
|
|
47
|
-
|
|
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
|
|
55
|
-
end
|
|
56
|
-
|
|
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?
|
|
63
|
-
end
|
|
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?
|
|
75
|
-
end
|
|
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
|
|
89
|
-
end
|
|
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
|
|
101
|
-
end
|
|
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
|
|
116
|
-
end
|
|
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
|
|
142
|
-
end
|
|
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?
|
|
168
|
-
end
|
|
169
|
-
end
|