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.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +39 -0
  3. data/CHANGELOG.md +20 -0
  4. data/Dockerfile +12 -0
  5. data/Gemfile +5 -0
  6. data/README.md +37 -13
  7. data/Rakefile +1 -0
  8. data/lib/thinreports/core/shape/image_block.rb +1 -1
  9. data/lib/thinreports/core/shape/list.rb +1 -1
  10. data/lib/thinreports/core/shape/page_number.rb +1 -1
  11. data/lib/thinreports/core/shape/text.rb +1 -1
  12. data/lib/thinreports/core/shape/text_block.rb +1 -1
  13. data/lib/thinreports/core/shape/text_block/formatter/number.rb +6 -1
  14. data/lib/thinreports/core/shape/text_block/internal.rb +0 -2
  15. data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +6 -0
  16. data/lib/thinreports/layout/base.rb +1 -1
  17. data/lib/thinreports/layout/version.rb +1 -1
  18. data/lib/thinreports/report/internal.rb +2 -0
  19. data/lib/thinreports/version.rb +1 -1
  20. data/thinreports.gemspec +5 -9
  21. metadata +6 -204
  22. data/.travis.yml +0 -32
  23. data/test/data/font.ttf +0 -0
  24. data/test/data/image_normal.jpg +0 -0
  25. data/test/data/image_normal.png +0 -0
  26. data/test/data/image_normal_jpg_noext +0 -0
  27. data/test/data/image_normal_png_noext +0 -0
  28. data/test/data/image_pallete_based.png +0 -0
  29. data/test/data/legacy_layout/all-items.tlf +0 -1
  30. data/test/features/dynamic_style/expect.pdf +0 -3714
  31. data/test/features/dynamic_style/image.png +0 -0
  32. data/test/features/dynamic_style/templates/styles.tlf +0 -1835
  33. data/test/features/dynamic_style/templates/styles_in_list.tlf +0 -344
  34. data/test/features/dynamic_style/test_dynamic_style.rb +0 -152
  35. data/test/features/eudc/eudc.ttf +0 -0
  36. data/test/features/eudc/expect.pdf +0 -0
  37. data/test/features/eudc/template.tlf +0 -180
  38. data/test/features/eudc/test_eudc.rb +0 -27
  39. data/test/features/feature_test.rb +0 -58
  40. data/test/features/graphics/expect.pdf +0 -475
  41. data/test/features/graphics/template.tlf +0 -309
  42. data/test/features/graphics/test_graphics.rb +0 -12
  43. data/test/features/hidden_item/expect.pdf +0 -0
  44. data/test/features/hidden_item/template.tlf +0 -449
  45. data/test/features/hidden_item/test_hidden_item.rb +0 -12
  46. data/test/features/image_block/expect.pdf +0 -0
  47. data/test/features/image_block/img200x100.png +0 -0
  48. data/test/features/image_block/img50x50.png +0 -0
  49. data/test/features/image_block/template.tlf +0 -661
  50. data/test/features/image_block/test_image_block.rb +0 -35
  51. data/test/features/list_events/expect.pdf +0 -659
  52. data/test/features/list_events/template.tlf +0 -361
  53. data/test/features/list_events/test_list_events.rb +0 -36
  54. data/test/features/list_manually/expect.pdf +0 -599
  55. data/test/features/list_manually/template.tlf +0 -132
  56. data/test/features/list_manually/test_list_manually.rb +0 -25
  57. data/test/features/page_number/expect.pdf +0 -400
  58. data/test/features/page_number/template.tlf +0 -215
  59. data/test/features/page_number/test_page_number.rb +0 -24
  60. data/test/features/page_number_with_list/expect.pdf +0 -721
  61. data/test/features/page_number_with_list/template.tlf +0 -254
  62. data/test/features/page_number_with_list/test_page_number_with_list.rb +0 -21
  63. data/test/features/palleted_png/expect.pdf +0 -0
  64. data/test/features/palleted_png/palleted_png.png +0 -0
  65. data/test/features/palleted_png/template.tlf +0 -47
  66. data/test/features/palleted_png/test_palleted_png.rb +0 -14
  67. data/test/features/report_callbacks/expect.pdf +0 -169
  68. data/test/features/report_callbacks/template.tlf +0 -147
  69. data/test/features/report_callbacks/test_report_callbacks.rb +0 -18
  70. data/test/features/text_align/expect.pdf +0 -0
  71. data/test/features/text_align/template.tlf +0 -241
  72. data/test/features/text_align/test_text_align.rb +0 -12
  73. data/test/features/text_block_overflow/expect.pdf +0 -0
  74. data/test/features/text_block_overflow/template.tlf +0 -538
  75. data/test/features/text_block_overflow/test_text_block_overflow.rb +0 -25
  76. data/test/features/text_block_singleline/expect.pdf +0 -0
  77. data/test/features/text_block_singleline/template.tlf +0 -170
  78. data/test/features/text_block_singleline/test_text_block_singleline.rb +0 -15
  79. data/test/features/text_block_style/expect.pdf +0 -1391
  80. data/test/features/text_block_style/templates/basic_styles.tlf +0 -889
  81. data/test/features/text_block_style/templates/font_size.tlf +0 -383
  82. data/test/features/text_block_style/test_text_block_style.rb +0 -47
  83. data/test/features/text_character_spacing/expect.pdf +0 -0
  84. data/test/features/text_character_spacing/template.tlf +0 -293
  85. data/test/features/text_character_spacing/test_text_character_spacing.rb +0 -12
  86. data/test/features/text_word_wrap/expect.pdf +0 -0
  87. data/test/features/text_word_wrap/template.tlf +0 -297
  88. data/test/features/text_word_wrap/test_text_word_wrap.rb +0 -30
  89. data/test/schema_helper.rb +0 -122
  90. data/test/test_helper.rb +0 -39
  91. data/test/units/core/format/test_base.rb +0 -152
  92. data/test/units/core/shape/base/test_internal.rb +0 -87
  93. data/test/units/core/shape/basic/test_block_format.rb +0 -23
  94. data/test/units/core/shape/basic/test_block_interface.rb +0 -29
  95. data/test/units/core/shape/basic/test_block_internal.rb +0 -55
  96. data/test/units/core/shape/basic/test_format.rb +0 -37
  97. data/test/units/core/shape/basic/test_interface.rb +0 -108
  98. data/test/units/core/shape/basic/test_internal.rb +0 -55
  99. data/test/units/core/shape/image_block/test_interface.rb +0 -24
  100. data/test/units/core/shape/image_block/test_internal.rb +0 -31
  101. data/test/units/core/shape/list/test_format.rb +0 -111
  102. data/test/units/core/shape/list/test_manager.rb +0 -67
  103. data/test/units/core/shape/list/test_page.rb +0 -156
  104. data/test/units/core/shape/list/test_page_state.rb +0 -31
  105. data/test/units/core/shape/list/test_section_format.rb +0 -36
  106. data/test/units/core/shape/list/test_section_interface.rb +0 -75
  107. data/test/units/core/shape/list/test_section_internal.rb +0 -50
  108. data/test/units/core/shape/manager/test_format.rb +0 -38
  109. data/test/units/core/shape/manager/test_internal.rb +0 -132
  110. data/test/units/core/shape/manager/test_target.rb +0 -140
  111. data/test/units/core/shape/page_number/test_format.rb +0 -55
  112. data/test/units/core/shape/page_number/test_interface.rb +0 -33
  113. data/test/units/core/shape/page_number/test_internal.rb +0 -81
  114. data/test/units/core/shape/styles/test_base.rb +0 -191
  115. data/test/units/core/shape/styles/test_basic.rb +0 -24
  116. data/test/units/core/shape/styles/test_graphic.rb +0 -50
  117. data/test/units/core/shape/styles/test_text.rb +0 -97
  118. data/test/units/core/shape/text/test_format.rb +0 -44
  119. data/test/units/core/shape/text/test_internal.rb +0 -20
  120. data/test/units/core/shape/text_block/formatter/test_basic.rb +0 -24
  121. data/test/units/core/shape/text_block/formatter/test_datetime.rb +0 -49
  122. data/test/units/core/shape/text_block/formatter/test_number.rb +0 -76
  123. data/test/units/core/shape/text_block/formatter/test_padding.rb +0 -77
  124. data/test/units/core/shape/text_block/test_format.rb +0 -169
  125. data/test/units/core/shape/text_block/test_formatter.rb +0 -28
  126. data/test/units/core/shape/text_block/test_interface.rb +0 -63
  127. data/test/units/core/shape/text_block/test_internal.rb +0 -128
  128. data/test/units/core/test_shape.rb +0 -52
  129. data/test/units/core/test_utils.rb +0 -68
  130. data/test/units/generator/pdf/document/graphics/test_attributes.rb +0 -135
  131. data/test/units/generator/pdf/document/graphics/test_basic.rb +0 -46
  132. data/test/units/generator/pdf/document/graphics/test_image.rb +0 -46
  133. data/test/units/generator/pdf/document/graphics/test_text.rb +0 -171
  134. data/test/units/generator/pdf/document/test_font.rb +0 -110
  135. data/test/units/generator/pdf/document/test_graphics.rb +0 -42
  136. data/test/units/generator/pdf/document/test_page.rb +0 -122
  137. data/test/units/generator/pdf/document/test_parse_color.rb +0 -30
  138. data/test/units/generator/pdf/prawn_ext/test_calc_image_dimensions.rb +0 -41
  139. data/test/units/generator/pdf/prawn_ext/test_width_of.rb +0 -22
  140. data/test/units/generator/pdf/test_document.rb +0 -22
  141. data/test/units/generator/test_pdf.rb +0 -26
  142. data/test/units/layout/test_base.rb +0 -41
  143. data/test/units/layout/test_format.rb +0 -100
  144. data/test/units/layout/test_legacy_schema.rb +0 -576
  145. data/test/units/layout/test_version.rb +0 -26
  146. data/test/units/report/test_base.rb +0 -248
  147. data/test/units/report/test_internal.rb +0 -206
  148. data/test/units/test_config.rb +0 -36
  149. data/test/units/test_layout.rb +0 -12
  150. 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