thinreports 0.7.7 → 0.8.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/.gitignore +3 -6
- data/.travis.yml +4 -10
- data/CHANGELOG.md +220 -0
- data/Gemfile +3 -3
- data/MIT-LICENSE +1 -1
- data/README.md +286 -0
- data/Rakefile +38 -8
- data/examples/character_spacing/character_spacing.rb +8 -0
- data/examples/character_spacing/character_spacing.tlf +1 -0
- data/examples/dynamic_image/dynamic_image.rb +31 -0
- data/examples/dynamic_image/dynamic_image.tlf +1 -0
- data/{test/case → examples}/dynamic_image/img200x100.png +0 -0
- data/{test/case → examples}/dynamic_image/img50x50.png +0 -0
- data/examples/dynamic_style/dynamic_style.rb +150 -0
- data/examples/dynamic_style/dynamic_style.tlf +1 -0
- data/examples/dynamic_style/dynamic_style_in_list.tlf +1 -0
- data/{test/case → examples}/dynamic_style/image.png +0 -0
- data/examples/eudc/eudc.rb +20 -0
- data/examples/eudc/eudc.tlf +1 -0
- data/{test/case → examples}/eudc/eudc.ttf +0 -0
- data/{test/case → examples}/helper.rb +14 -12
- data/examples/hidden_shapes/hidden_shapes.rb +9 -0
- data/examples/hidden_shapes/hidden_shapes.tlf +1 -0
- data/examples/list_events/list_events.rb +59 -0
- data/examples/list_events/list_events_0_7_7.tlf +1 -0
- data/examples/list_events/list_events_0_8.tlf +1 -0
- data/{test/case → examples}/list_manual_generation/list_manual_generation.rb +4 -4
- data/examples/list_manual_generation/list_manual_generation.tlf +1 -0
- data/{test/case → examples}/list_page_number/list_page_number.rb +3 -3
- data/examples/list_page_number/list_page_number.tlf +1 -0
- data/examples/page_number/page_number.rb +33 -0
- data/examples/page_number/page_number.tlf +1 -0
- data/examples/password_setting/password_setting.rb +10 -0
- data/examples/password_setting/password_setting.tlf +1 -0
- data/examples/report_callbacks/report_callbacks.rb +31 -0
- data/examples/report_callbacks/report_callbacks.tlf +1 -0
- data/{test/case → examples}/single_line_tblock/single_line_tblock.rb +2 -2
- data/examples/single_line_tblock/single_line_tblock.tlf +1 -0
- data/examples/tblock_overflow/tblock_overflow.rb +20 -0
- data/examples/tblock_overflow/tblock_overflow.tlf +1 -0
- data/examples/tblock_styles/font_size.tlf +1 -0
- data/examples/tblock_styles/tblock_styles.rb +43 -0
- data/examples/tblock_styles/tblock_styles.tlf +1 -0
- data/examples/text_align/text_align.rb +8 -0
- data/examples/text_align/text_align.tlf +1 -0
- data/examples/typeB_page_size/B4_ISO.tlf +1 -0
- data/examples/typeB_page_size/B4_JIS.tlf +1 -0
- data/{test/case → examples}/typeB_page_size/typeB_page_size.rb +3 -3
- data/examples/word_wrap/word_wrap.rb +26 -0
- data/examples/word_wrap/word_wrap.tlf +1 -0
- data/{resources/fonts → fonts}/IPA_Font_License_Agreement_v1.0.txt +0 -0
- data/{resources/fonts → fonts}/ipag.ttf +0 -0
- data/{resources/fonts → fonts}/ipagp.ttf +0 -0
- data/{resources/fonts → fonts}/ipam.ttf +0 -0
- data/{resources/fonts → fonts}/ipamp.ttf +0 -0
- data/lib/thinreports.rb +14 -2
- data/lib/thinreports/config.rb +30 -10
- data/lib/thinreports/core/errors.rb +23 -20
- data/lib/thinreports/core/events.rb +18 -19
- data/lib/thinreports/core/format/base.rb +20 -20
- data/lib/thinreports/core/format/builder.rb +14 -22
- data/lib/thinreports/core/shape.rb +9 -13
- data/lib/thinreports/core/shape/base.rb +4 -5
- data/lib/thinreports/core/shape/base/interface.rb +15 -15
- data/lib/thinreports/core/shape/base/internal.rb +15 -20
- data/lib/thinreports/core/shape/basic.rb +1 -1
- data/lib/thinreports/core/shape/basic/block_format.rb +3 -4
- data/lib/thinreports/core/shape/basic/block_interface.rb +9 -4
- data/lib/thinreports/core/shape/basic/block_internal.rb +9 -10
- data/lib/thinreports/core/shape/basic/format.rb +11 -10
- data/lib/thinreports/core/shape/basic/interface.rb +3 -3
- data/lib/thinreports/core/shape/basic/internal.rb +4 -5
- data/lib/thinreports/core/shape/image_block.rb +1 -1
- data/lib/thinreports/core/shape/image_block/format.rb +5 -6
- data/lib/thinreports/core/shape/image_block/interface.rb +9 -7
- data/lib/thinreports/core/shape/image_block/internal.rb +5 -6
- data/lib/thinreports/core/shape/list.rb +1 -1
- data/lib/thinreports/core/shape/list/configuration.rb +30 -15
- data/lib/thinreports/core/shape/list/events.rb +11 -11
- data/lib/thinreports/core/shape/list/format.rb +27 -28
- data/lib/thinreports/core/shape/list/manager.rb +128 -95
- data/lib/thinreports/core/shape/list/page.rb +54 -50
- data/lib/thinreports/core/shape/list/page_state.rb +15 -16
- data/lib/thinreports/core/shape/list/section_format.rb +14 -15
- data/lib/thinreports/core/shape/list/section_interface.rb +15 -16
- data/lib/thinreports/core/shape/list/section_internal.rb +7 -8
- data/lib/thinreports/core/shape/list/store.rb +10 -11
- data/lib/thinreports/core/shape/manager.rb +1 -1
- data/lib/thinreports/core/shape/manager/format.rb +10 -11
- data/lib/thinreports/core/shape/manager/internal.rb +21 -20
- data/lib/thinreports/core/shape/manager/target.rb +63 -34
- data/lib/thinreports/core/shape/page_number.rb +1 -1
- data/lib/thinreports/core/shape/page_number/format.rb +3 -3
- data/lib/thinreports/core/shape/page_number/interface.rb +2 -2
- data/lib/thinreports/core/shape/page_number/internal.rb +3 -3
- data/lib/thinreports/core/shape/style.rb +1 -1
- data/lib/thinreports/core/shape/style/base.rb +29 -29
- data/lib/thinreports/core/shape/style/basic.rb +1 -1
- data/lib/thinreports/core/shape/style/graphic.rb +10 -25
- data/lib/thinreports/core/shape/style/text.rb +36 -30
- data/lib/thinreports/core/shape/text.rb +1 -1
- data/lib/thinreports/core/shape/text/format.rb +8 -9
- data/lib/thinreports/core/shape/text/interface.rb +2 -2
- data/lib/thinreports/core/shape/text/internal.rb +6 -7
- data/lib/thinreports/core/shape/text_block.rb +1 -1
- data/lib/thinreports/core/shape/text_block/format.rb +17 -18
- data/lib/thinreports/core/shape/text_block/formatter.rb +7 -8
- data/lib/thinreports/core/shape/text_block/formatter/basic.rb +13 -12
- data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +8 -9
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +11 -12
- data/lib/thinreports/core/shape/text_block/formatter/padding.rb +9 -32
- data/lib/thinreports/core/shape/text_block/interface.rb +2 -2
- data/lib/thinreports/core/shape/text_block/internal.rb +19 -20
- data/lib/thinreports/core/utils.rb +33 -32
- data/lib/thinreports/generator.rb +6 -8
- data/lib/thinreports/generator/base.rb +15 -24
- data/lib/thinreports/generator/configuration.rb +10 -9
- data/lib/thinreports/generator/pdf.rb +27 -30
- data/lib/thinreports/generator/pdf/configuration.rb +11 -6
- data/lib/thinreports/generator/pdf/document.rb +28 -28
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +30 -31
- data/lib/thinreports/generator/pdf/document/font.rb +53 -44
- data/lib/thinreports/generator/pdf/document/graphics.rb +8 -9
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +25 -25
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +25 -25
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +15 -15
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +40 -41
- data/lib/thinreports/generator/pdf/document/page.rb +20 -21
- data/lib/thinreports/generator/pdf/document/parse_color.rb +9 -10
- data/lib/thinreports/generator/pdf/document/parse_svg.rb +14 -15
- data/lib/thinreports/generator/pdf/drawer/base.rb +13 -14
- data/lib/thinreports/generator/pdf/drawer/list.rb +13 -14
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +13 -14
- data/lib/thinreports/generator/pdf/drawer/page.rb +16 -17
- data/lib/thinreports/generator/pdf/prawn_ext.rb +17 -33
- data/lib/thinreports/layout.rb +2 -2
- data/lib/thinreports/layout/base.rb +22 -36
- data/lib/thinreports/layout/configuration.rb +11 -9
- data/lib/thinreports/layout/format.rb +26 -27
- data/lib/thinreports/layout/version.rb +8 -9
- data/lib/thinreports/report.rb +10 -14
- data/lib/thinreports/report/base.rb +104 -126
- data/lib/thinreports/report/events.rb +5 -5
- data/lib/thinreports/report/internal.rb +41 -33
- data/lib/thinreports/{core → report}/page.rb +38 -30
- data/lib/thinreports/version.rb +2 -3
- data/test/data/font.ttf +0 -0
- data/test/data/layout_block.tlf +1 -0
- data/test/data/layout_list.tlf +1 -0
- data/test/data/layout_list_noheader.tlf +1 -0
- data/test/data/layout_text1.tlf +1 -0
- data/test/data/layout_text2.tlf +1 -0
- data/test/test_helper.rb +74 -0
- data/test/{unit/tmp → tmp}/.gitkeep +0 -0
- data/test/unit/core/format/test_base.rb +14 -14
- data/test/unit/core/format/test_builder.rb +19 -23
- data/test/unit/core/shape/base/test_internal.rb +34 -37
- data/test/unit/core/shape/basic/test_basic_format.rb +4 -4
- data/test/unit/core/shape/basic/test_basic_interface.rb +15 -13
- data/test/unit/core/shape/basic/test_basic_internal.rb +19 -16
- data/test/unit/core/shape/basic/test_format.rb +4 -4
- data/test/unit/core/shape/basic/test_interface.rb +36 -46
- data/test/unit/core/shape/basic/test_internal.rb +23 -20
- data/test/unit/core/shape/image_block/test_format.rb +5 -5
- data/test/unit/core/shape/image_block/test_interface.rb +17 -16
- data/test/unit/core/shape/image_block/test_internal.rb +19 -16
- data/test/unit/core/shape/list/test_configuration.rb +45 -33
- data/test/unit/core/shape/list/test_events.rb +7 -7
- data/test/unit/core/shape/list/test_format.rb +16 -18
- data/test/unit/core/shape/list/test_manager.rb +5 -5
- data/test/unit/core/shape/list/test_page.rb +80 -22
- data/test/unit/core/shape/list/test_page_state.rb +12 -12
- data/test/unit/core/shape/list/test_section_format.rb +16 -17
- data/test/unit/core/shape/list/test_section_interface.rb +30 -22
- data/test/unit/core/shape/list/test_section_internal.rb +21 -19
- data/test/unit/core/shape/list/test_store.rb +7 -7
- data/test/unit/core/shape/manager/test_format.rb +11 -15
- data/test/unit/core/shape/manager/test_internal.rb +9 -9
- data/test/unit/core/shape/manager/test_target.rb +85 -57
- data/test/unit/core/shape/page_number/test_format.rb +4 -4
- data/test/unit/core/shape/page_number/test_interface.rb +11 -8
- data/test/unit/core/shape/page_number/test_internal.rb +5 -5
- data/test/unit/core/shape/styles/test_base.rb +9 -9
- data/test/unit/core/shape/styles/test_basic.rb +5 -5
- data/test/unit/core/shape/styles/test_graphic.rb +19 -33
- data/test/unit/core/shape/styles/test_text.rb +18 -7
- data/test/unit/core/shape/text/test_format.rb +6 -6
- data/test/unit/core/shape/text/test_internal.rb +11 -12
- data/test/unit/core/shape/text_block/formatter/test_basic.rb +16 -16
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +4 -4
- data/test/unit/core/shape/text_block/formatter/test_number.rb +34 -34
- data/test/unit/core/shape/text_block/formatter/test_padding.rb +44 -44
- data/test/unit/core/shape/text_block/test_format.rb +8 -8
- data/test/unit/core/shape/text_block/test_formatter.rb +17 -17
- data/test/unit/core/shape/text_block/test_interface.rb +37 -20
- data/test/unit/core/shape/text_block/test_internal.rb +38 -38
- data/test/unit/core/test_events.rb +5 -5
- data/test/unit/core/test_shape.rb +6 -6
- data/test/unit/core/test_utils.rb +68 -0
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +4 -4
- data/test/unit/generator/pdf/document/graphics/test_text.rb +60 -53
- data/test/unit/generator/pdf/document/test_draw_shape.rb +9 -7
- data/test/unit/generator/pdf/document/test_font.rb +79 -58
- data/test/unit/generator/pdf/document/test_graphics.rb +18 -19
- data/test/unit/generator/pdf/document/test_page.rb +44 -45
- data/test/unit/generator/pdf/document/test_parse_color.rb +5 -5
- data/test/unit/generator/pdf/test_configuration.rb +16 -9
- data/test/unit/generator/pdf/test_document.rb +8 -16
- data/test/unit/generator/test_base.rb +31 -42
- data/test/unit/generator/test_configuration.rb +6 -6
- data/test/unit/generator/test_pdf.rb +17 -14
- data/test/unit/layout/test_base.rb +34 -79
- data/test/unit/layout/test_configuration.rb +12 -37
- data/test/unit/layout/test_format.rb +36 -39
- data/test/unit/layout/test_version.rb +4 -4
- data/test/unit/report/test_base.rb +134 -213
- data/test/unit/report/test_events.rb +4 -4
- data/test/unit/report/test_internal.rb +84 -86
- data/test/unit/test_config.rb +31 -12
- data/test/unit/test_layout.rb +7 -7
- data/test/unit/test_report.rb +12 -24
- data/thinreports.gemspec +18 -22
- metadata +101 -200
- data/LICENSE +0 -1
- data/README.rdoc +0 -166
- data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
- data/lib/thinreports/core.rb +0 -20
- data/lib/thinreports/core/ext.rb +0 -5
- data/lib/thinreports/core/ext/array.rb +0 -19
- data/lib/thinreports/core/ext/hash.rb +0 -19
- data/lib/thinreports/core/ext/object.rb +0 -25
- data/lib/thinreports/core/format.rb +0 -14
- data/lib/thinreports/core/ordered_hash.rb +0 -39
- data/lib/thinreports/generator/pdf/drawer.rb +0 -16
- data/tasks/doc.rake +0 -12
- data/tasks/test.rake +0 -56
- data/test/benchmark/basic_estimate.tlf +0 -1
- data/test/benchmark/bench_basic_estimate.rb +0 -95
- data/test/case/character_spacing/character_spacing.rb +0 -8
- data/test/case/character_spacing/character_spacing.tlf +0 -1
- data/test/case/dynamic_image/dynamic_image.rb +0 -41
- data/test/case/dynamic_image/dynamic_image.tlf +0 -1
- data/test/case/dynamic_style/dynamic_style.rb +0 -154
- data/test/case/dynamic_style/dynamic_style.tlf +0 -1
- data/test/case/dynamic_style/dynamic_style_in_list.tlf +0 -1
- data/test/case/eudc/eudc.rb +0 -20
- data/test/case/eudc/eudc.tlf +0 -1
- data/test/case/hidden_shapes/hidden_shapes.rb +0 -9
- data/test/case/hidden_shapes/hidden_shapes.tlf +0 -1
- data/test/case/list_events/list_events.rb +0 -32
- data/test/case/list_events/list_events.tlf +0 -1
- data/test/case/list_manual_generation/list_manual_generation.tlf +0 -1
- data/test/case/list_page_number/list_page_number.tlf +0 -1
- data/test/case/page_number/page_number.rb +0 -33
- data/test/case/page_number/page_number.tlf +0 -1
- data/test/case/password_setting/password_setting.rb +0 -10
- data/test/case/password_setting/password_setting.tlf +0 -1
- data/test/case/single_line_tblock/single_line_tblock.tlf +0 -1
- data/test/case/tblock_overflow/tblock_overflow.rb +0 -20
- data/test/case/tblock_overflow/tblock_overflow.tlf +0 -1
- data/test/case/tblock_styles/tblock_styles.rb +0 -27
- data/test/case/tblock_styles/tblock_styles.tlf +0 -1
- data/test/case/text_align/text_align.rb +0 -8
- data/test/case/text_align/text_align.tlf +0 -1
- data/test/case/typeB_page_size/B4_ISO.tlf +0 -1
- data/test/case/typeB_page_size/B4_JIS.tlf +0 -1
- data/test/case/word_wrap/word_wrap.rb +0 -26
- data/test/case/word_wrap/word_wrap.tlf +0 -1
- data/test/unit/core/ext/array_spec.rb +0 -29
- data/test/unit/core/ext/hash_spec.rb +0 -29
- data/test/unit/core/ext/object_spec.rb +0 -30
- data/test/unit/core/ordered_hash_spec.rb +0 -51
- data/test/unit/core/shape/base/test_interface.rb +0 -52
- data/test/unit/core/utils_spec.rb +0 -56
- data/test/unit/data/basic_layout1.tlf +0 -1
- data/test/unit/data/basic_layout2.tlf +0 -1
- data/test/unit/data/basic_list_layout.tlf +0 -1
- data/test/unit/data/basic_list_noheader_layout.tlf +0 -1
- data/test/unit/helper.rb +0 -87
|
@@ -1,77 +1,77 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::TextBlock::Formatter::TestPadding < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
4
7
|
|
|
5
|
-
class ThinReports::Core::Shape::TextBlock::Formatter::TestPadding < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
8
|
# Alias
|
|
9
|
-
Formatter =
|
|
10
|
-
|
|
9
|
+
Formatter = Thinreports::Core::Shape::TextBlock::Formatter::Padding
|
|
10
|
+
|
|
11
11
|
def init_formatter(expect_formats)
|
|
12
|
-
format =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
16
|
Formatter.new(format)
|
|
17
17
|
end
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
def test_apply_padding_formats_with_left_direction
|
|
20
|
-
formatter = init_formatter(:
|
|
21
|
-
:
|
|
22
|
-
|
|
20
|
+
formatter = init_formatter(format_padding_length: 5,
|
|
21
|
+
format_padding_char: '0')
|
|
22
|
+
|
|
23
23
|
assert_equal formatter.apply(1), '00001'
|
|
24
24
|
assert_equal formatter.apply('日本語'), '00日本語'
|
|
25
25
|
end
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
def test_apply_padding_formats_should_not_apply_when_character_length_is_short
|
|
28
|
-
formatter = init_formatter(:
|
|
29
|
-
:
|
|
30
|
-
|
|
28
|
+
formatter = init_formatter(format_padding_length: 5,
|
|
29
|
+
format_padding_char: '0')
|
|
30
|
+
|
|
31
31
|
assert_equal formatter.apply('1234567'), '1234567'
|
|
32
32
|
end
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
def test_apply_padding_formats_with_right_direction
|
|
35
|
-
formatter = init_formatter(:
|
|
36
|
-
:
|
|
35
|
+
formatter = init_formatter(format_padding_length: 5,
|
|
36
|
+
format_padding_char: '0',
|
|
37
37
|
:format_padding_rdir? => true)
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
assert_equal formatter.apply(123), '12300'
|
|
40
40
|
end
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
def test_apply_padding_format_with_basic_format
|
|
43
|
-
formatter = init_formatter(:
|
|
44
|
-
:
|
|
45
|
-
:
|
|
43
|
+
formatter = init_formatter(format_base: '[{value}]',
|
|
44
|
+
format_padding_length: 10,
|
|
45
|
+
format_padding_char: ' ')
|
|
46
46
|
|
|
47
47
|
assert_equal formatter.apply('ABC'), '[ ABC]'
|
|
48
48
|
end
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
def test_return_raw_value_when_length_is_0
|
|
51
|
-
formatter = init_formatter(:
|
|
52
|
-
:
|
|
53
|
-
|
|
51
|
+
formatter = init_formatter(format_padding_length: 0,
|
|
52
|
+
format_padding_char: '0')
|
|
53
|
+
|
|
54
54
|
assert_same formatter.apply(v = 123), v
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
# But apply only basic format if have basic-format.
|
|
57
|
-
formatter = init_formatter(:
|
|
58
|
-
:
|
|
59
|
-
:
|
|
60
|
-
|
|
57
|
+
formatter = init_formatter(format_base: '<{value}>',
|
|
58
|
+
format_padding_length: 0,
|
|
59
|
+
format_padding_char: '0')
|
|
60
|
+
|
|
61
61
|
assert_equal formatter.apply(123), '<123>'
|
|
62
62
|
end
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
def test_return_raw_value_when_char_is_empty
|
|
65
|
-
formatter = init_formatter(:
|
|
66
|
-
:
|
|
67
|
-
|
|
65
|
+
formatter = init_formatter(format_padding_length: 10,
|
|
66
|
+
format_padding_char: '')
|
|
67
|
+
|
|
68
68
|
assert_same formatter.apply(v = '1'), v
|
|
69
69
|
|
|
70
70
|
# But apply only basic format if have basic-format.
|
|
71
|
-
formatter = init_formatter(:
|
|
72
|
-
:
|
|
73
|
-
:
|
|
74
|
-
|
|
71
|
+
formatter = init_formatter(format_base: '<{value}>',
|
|
72
|
+
format_padding_length: 0,
|
|
73
|
+
format_padding_char: '0')
|
|
74
|
+
|
|
75
75
|
assert_equal formatter.apply('1'), '<1>'
|
|
76
76
|
end
|
|
77
|
-
end
|
|
77
|
+
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
include
|
|
5
|
+
class Thinreports::Core::Shape::TextBlock::TestFormat < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
8
|
TEST_TBLOCK_FORMAT = {
|
|
9
9
|
"type" => "s-tblock",
|
|
@@ -25,7 +25,7 @@ class ThinReports::Core::Shape::TextBlock::TestFormat < MiniTest::Unit::TestCase
|
|
|
25
25
|
"delimiter" => ",",
|
|
26
26
|
"precision" => 1
|
|
27
27
|
}
|
|
28
|
-
},
|
|
28
|
+
},
|
|
29
29
|
"value" => "",
|
|
30
30
|
"ref-id" => "",
|
|
31
31
|
"svg" => {
|
|
@@ -38,7 +38,7 @@ class ThinReports::Core::Shape::TextBlock::TestFormat < MiniTest::Unit::TestCase
|
|
|
38
38
|
"fill" => "#000000",
|
|
39
39
|
"fill-opacity" => "1",
|
|
40
40
|
"font-size" => "12",
|
|
41
|
-
"font-family" => "
|
|
41
|
+
"font-family" => "Helvetica",
|
|
42
42
|
"font-weight" => "bold",
|
|
43
43
|
"font-style" => "normal",
|
|
44
44
|
"text-decoration" => "none",
|
|
@@ -52,7 +52,7 @@ class ThinReports::Core::Shape::TextBlock::TestFormat < MiniTest::Unit::TestCase
|
|
|
52
52
|
rescue => e
|
|
53
53
|
flunk exception_details(e, 'Building failed.')
|
|
54
54
|
end
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
def test_value_reader_via_TEST_TBLOCK_FORMAT
|
|
57
57
|
assert_equal format(TEST_TBLOCK_FORMAT).value, ''
|
|
58
58
|
end
|
|
@@ -161,10 +161,10 @@ class ThinReports::Core::Shape::TextBlock::TestFormat < MiniTest::Unit::TestCase
|
|
|
161
161
|
end
|
|
162
162
|
|
|
163
163
|
def build_format
|
|
164
|
-
|
|
164
|
+
Thinreports::Core::Shape::TextBlock::Format.build(TEST_TBLOCK_FORMAT)
|
|
165
165
|
end
|
|
166
166
|
|
|
167
167
|
def format(data)
|
|
168
|
-
|
|
168
|
+
Thinreports::Core::Shape::TextBlock::Format.new(data)
|
|
169
169
|
end
|
|
170
170
|
end
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::TextBlock::TestFormatter < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
4
7
|
|
|
5
|
-
class ThinReports::Core::Shape::TextBlock::TestFormatter < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
8
|
# Alias
|
|
9
|
-
Formatter =
|
|
10
|
-
|
|
9
|
+
Formatter = Thinreports::Core::Shape::TextBlock::Formatter
|
|
10
|
+
|
|
11
11
|
def test_initialize_formatter_by_type
|
|
12
12
|
assert_instance_of Formatter::Basic,
|
|
13
|
-
Formatter.setup(
|
|
14
|
-
|
|
13
|
+
Formatter.setup( stub(format_type: '') )
|
|
14
|
+
|
|
15
15
|
assert_instance_of Formatter::Number,
|
|
16
|
-
Formatter.setup(
|
|
17
|
-
|
|
16
|
+
Formatter.setup( stub(format_type: 'number') )
|
|
17
|
+
|
|
18
18
|
assert_instance_of Formatter::Datetime,
|
|
19
|
-
Formatter.setup(
|
|
20
|
-
|
|
19
|
+
Formatter.setup( stub(format_type: 'datetime') )
|
|
20
|
+
|
|
21
21
|
assert_instance_of Formatter::Padding,
|
|
22
|
-
Formatter.setup(
|
|
23
|
-
|
|
24
|
-
assert_raises
|
|
25
|
-
Formatter.setup(
|
|
22
|
+
Formatter.setup( stub(format_type: 'padding') )
|
|
23
|
+
|
|
24
|
+
assert_raises Thinreports::Errors::UnknownFormatterType do
|
|
25
|
+
Formatter.setup( stub(format_type: 'unknown') )
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
|
-
end
|
|
28
|
+
end
|
|
@@ -1,46 +1,63 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::TextBlock::TestInterface < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
4
7
|
|
|
5
|
-
class ThinReports::Core::Shape::TextBlock::TestInterface < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
8
|
# Alias
|
|
9
|
-
TextBlock =
|
|
10
|
-
|
|
9
|
+
TextBlock = Thinreports::Core::Shape::TextBlock
|
|
10
|
+
|
|
11
11
|
def create_interface(format_config = {})
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
report = new_report 'layout_text1'
|
|
13
|
+
parent = report.start_new_page
|
|
14
|
+
|
|
15
|
+
TextBlock::Interface.new parent, TextBlock::Format.new(format_config)
|
|
14
16
|
end
|
|
15
|
-
|
|
17
|
+
|
|
16
18
|
def test_format_enabled_asker_should_operate_as_delegator_of_internal
|
|
17
19
|
tblock = create_interface('format' => {'type' => 'datetime'})
|
|
18
20
|
assert_equal tblock.format_enabled?, tblock.internal.format_enabled?
|
|
19
21
|
end
|
|
20
|
-
|
|
22
|
+
|
|
21
23
|
def test_format_enabled_should_properly_set_value_to_internal
|
|
22
24
|
tblock = create_interface('format' => {'type' => 'number'})
|
|
23
25
|
tblock.format_enabled(false)
|
|
24
|
-
|
|
26
|
+
|
|
25
27
|
assert_equal tblock.internal.format_enabled?, false
|
|
26
28
|
end
|
|
27
|
-
|
|
29
|
+
|
|
28
30
|
def test_set_should_properly_set_a_value
|
|
29
31
|
tblock = create_interface
|
|
30
|
-
tblock.set(1000, :
|
|
31
|
-
|
|
32
|
+
tblock.set(1000, visible: false)
|
|
33
|
+
|
|
32
34
|
assert_equal tblock.value, 1000
|
|
33
35
|
end
|
|
34
|
-
|
|
36
|
+
|
|
35
37
|
def test_set_should_properly_set_styles
|
|
36
38
|
tblock = create_interface
|
|
37
|
-
tblock.set(1000, :
|
|
38
|
-
:
|
|
39
|
-
:
|
|
40
|
-
|
|
39
|
+
tblock.set(1000, color: '#ff0000',
|
|
40
|
+
bold: true,
|
|
41
|
+
italic: true)
|
|
42
|
+
|
|
41
43
|
assert_equal [tblock.style(:color),
|
|
42
44
|
tblock.style(:bold),
|
|
43
45
|
tblock.style(:italic)],
|
|
44
46
|
['#ff0000', true, true]
|
|
45
47
|
end
|
|
46
|
-
|
|
48
|
+
|
|
49
|
+
def test_value=
|
|
50
|
+
report = new_report 'layout_block.tlf'
|
|
51
|
+
page = report.start_new_page
|
|
52
|
+
|
|
53
|
+
page.item(:text_block1).value = 'foo'
|
|
54
|
+
assert_equal 'foo', page.item(:text_block1).value
|
|
55
|
+
|
|
56
|
+
page.item(:text_block1).value += 'bar'
|
|
57
|
+
assert_equal 'foobar', page.item(:text_block1).value
|
|
58
|
+
|
|
59
|
+
page.item(:text_block1).value = 1000
|
|
60
|
+
page.item(:text_block1).value += 999
|
|
61
|
+
assert_equal 1999, page.item(:text_block1).value
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::TextBlock::TestInternal < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
4
7
|
|
|
5
|
-
class ThinReports::Core::Shape::TextBlock::TestInternal < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
8
|
# Alias
|
|
9
|
-
TextBlock =
|
|
10
|
-
|
|
9
|
+
TextBlock = Thinreports::Core::Shape::TextBlock
|
|
10
|
+
|
|
11
11
|
def create_parent
|
|
12
|
-
report =
|
|
12
|
+
report = new_report('layout_text1.tlf')
|
|
13
13
|
report.start_new_page do |page|
|
|
14
14
|
# Add to force TextBlock shape.
|
|
15
15
|
page.manager.format.shapes[:foo] = TextBlock::Format.new('type' => 's-tblock',
|
|
@@ -18,111 +18,111 @@ class ThinReports::Core::Shape::TextBlock::TestInternal < MiniTest::Unit::TestCa
|
|
|
18
18
|
page.item(:foo).value('foo value')
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
def create_internal(format_config = {})
|
|
23
23
|
TextBlock::Internal.new(create_parent, TextBlock::Format.new(format_config))
|
|
24
24
|
end
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
def test_multiple_asker_should_operate_as_delegator_of_format
|
|
27
27
|
tblock = create_internal('multiple' => 'true')
|
|
28
28
|
assert_equal tblock.multiple?, tblock.format.multiple?
|
|
29
29
|
end
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
def test_style_should_return_the_instance_of_Style_Text
|
|
32
|
-
assert_instance_of
|
|
32
|
+
assert_instance_of Thinreports::Core::Shape::Style::Text, create_internal.style
|
|
33
33
|
end
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
def test_read_value_should_return_the_format_value_as_default
|
|
36
36
|
tblock = create_internal('value' => 'default value')
|
|
37
37
|
assert_equal tblock.read_value, 'default value'
|
|
38
38
|
end
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
def test_read_value_should_return_the_value_of_referenced_shape
|
|
41
41
|
tblock = create_internal('ref-id' => 'foo')
|
|
42
42
|
assert_equal tblock.read_value, 'foo value'
|
|
43
43
|
end
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
def test_read_value_should_return_the_value_stored_in_states
|
|
46
46
|
tblock = create_internal
|
|
47
47
|
tblock.states[:value] = 'value in states'
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
assert_equal tblock.read_value, 'value in states'
|
|
50
50
|
end
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
def test_write_value_should_properly_set_the_specified_value_to_states
|
|
53
53
|
tblock = create_internal
|
|
54
54
|
tblock.write_value(1000)
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
assert_equal tblock.states[:value], 1000
|
|
57
57
|
end
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
def test_write_value_should_show_warnings_when_tblock_has_reference
|
|
60
60
|
tblock = create_internal('id' => 'bar', 'ref-id' => 'foo')
|
|
61
61
|
out, err = capture_io do
|
|
62
62
|
tblock.write_value('value')
|
|
63
63
|
end
|
|
64
64
|
assert_equal err.chomp, 'The set value was not saved, ' +
|
|
65
|
-
"Because 'bar'
|
|
65
|
+
"Because 'bar' has reference to 'foo'."
|
|
66
66
|
end
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
def test_real_value_should_return_the_formatted_value_when_tblock_has_any_format
|
|
69
69
|
tblock = create_internal('format' => {'type' => 'datetime',
|
|
70
70
|
'datetime' => {'format' => '%Y/%m/%d'}})
|
|
71
71
|
tblock.write_value(value = Time.now)
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
assert_equal tblock.real_value, value.strftime('%Y/%m/%d')
|
|
74
74
|
end
|
|
75
|
-
|
|
75
|
+
|
|
76
76
|
def test_real_value_should_return_the_raw_value_when_tblock_has_no_format
|
|
77
77
|
tblock = create_internal
|
|
78
78
|
tblock.write_value('any value')
|
|
79
|
-
|
|
79
|
+
|
|
80
80
|
assert_equal tblock.real_value, 'any value'
|
|
81
81
|
end
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
def test_format_enabled_should_properly_set_value_to_states_as_format_enabled
|
|
84
84
|
tblock = create_internal
|
|
85
85
|
tblock.format_enabled(false)
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
assert_equal tblock.states[:format_enabled], false
|
|
88
88
|
end
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
def test_format_enabled_asker_should_return_true_when_format_has_any_type
|
|
91
91
|
tblock = create_internal('format' => {'type' => 'datetime'})
|
|
92
|
-
|
|
92
|
+
|
|
93
93
|
assert_equal tblock.format_enabled?, true
|
|
94
94
|
end
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
def test_format_enabled_asker_should_return_true_when_base_of_format_has_any_value
|
|
97
97
|
tblock = create_internal('format' => {'base' => '{value}'})
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
assert_equal tblock.format_enabled?, true
|
|
100
100
|
end
|
|
101
|
-
|
|
101
|
+
|
|
102
102
|
def test_format_enabled_asker_should_return_false_when_format_has_no_type_and_base_has_not_value
|
|
103
103
|
assert_equal create_internal.format_enabled?, false
|
|
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' => 'true',
|
|
107
|
+
tblock = create_internal('multiple' => 'true',
|
|
108
108
|
'format' => {'base' => '{value}',
|
|
109
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
116
|
assert_equal create_internal.type_of?(:tblock), true
|
|
117
117
|
end
|
|
118
|
-
|
|
118
|
+
|
|
119
119
|
def test_type_of_asker_should_return_true_when_value_is_block
|
|
120
120
|
assert_equal create_internal.type_of?(:block), true
|
|
121
121
|
end
|
|
122
|
-
|
|
122
|
+
|
|
123
123
|
def test_formatter_should_return_instance_of_FormatterBasic_when_format_is_enable
|
|
124
124
|
tblock = create_internal('format' => {'type' => 'datetime'})
|
|
125
|
-
|
|
125
|
+
|
|
126
126
|
assert_kind_of TextBlock::Formatter::Basic, tblock.send(:formatter)
|
|
127
127
|
end
|
|
128
|
-
end
|
|
128
|
+
end
|