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,58 +1,61 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::Basic::TestInternal < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
4
7
|
|
|
5
|
-
class ThinReports::Core::Shape::Basic::TestInternal < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
8
|
# Alias
|
|
9
|
-
Basic =
|
|
10
|
-
|
|
9
|
+
Basic = Thinreports::Core::Shape::Basic
|
|
10
|
+
|
|
11
11
|
def create_internal(format_config = {})
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
report = Thinreports::Report.new layout: data_file('layout_text1')
|
|
13
|
+
parent = report.start_new_page
|
|
14
|
+
|
|
15
|
+
Basic::Internal.new report.page, Basic::Format.new(format_config)
|
|
14
16
|
end
|
|
15
|
-
|
|
17
|
+
|
|
16
18
|
def test_id_should_operate_as_delegator_of_format
|
|
17
19
|
basic = create_internal('id' => 'basic-id')
|
|
18
20
|
assert_same basic.id, basic.format.id
|
|
19
21
|
end
|
|
20
|
-
|
|
22
|
+
|
|
21
23
|
def test_svg_tag_should_operate_as_delegator_of_format
|
|
22
24
|
basic = create_internal('svg' => {'tag' => 'rect'})
|
|
23
25
|
assert_same basic.svg_tag, basic.format.svg_tag
|
|
24
26
|
end
|
|
25
|
-
|
|
27
|
+
|
|
26
28
|
def test_type_should_operate_as_delegator_of_format
|
|
27
29
|
basic = create_internal('type' => 's-ellipse')
|
|
28
30
|
assert_same basic.type, basic.format.type
|
|
29
31
|
end
|
|
30
|
-
|
|
32
|
+
|
|
31
33
|
def test_style_should_return_instance_of_StyleGraphic
|
|
32
|
-
assert_instance_of
|
|
34
|
+
assert_instance_of Thinreports::Core::Shape::Style::Graphic,
|
|
33
35
|
create_internal.style
|
|
34
36
|
end
|
|
35
|
-
|
|
37
|
+
|
|
36
38
|
def test_type_of_asker_should_already_return_true_when_the_specified_type_is_basic
|
|
37
39
|
assert_equal create_internal.type_of?(:basic), true
|
|
38
40
|
end
|
|
39
|
-
|
|
41
|
+
|
|
40
42
|
def test_type_of_asker_should_return_true_when_the_specified_type_equal_self_type_name
|
|
41
43
|
result = []
|
|
42
|
-
|
|
44
|
+
|
|
43
45
|
result << create_internal('type' => 's-rect').type_of?(:rect)
|
|
44
46
|
result << create_internal('type' => 's-ellipse').type_of?(:ellipse)
|
|
45
47
|
result << create_internal('type' => 's-line').type_of?(:line)
|
|
46
48
|
result << create_internal('type' => 's-image').type_of?(:image)
|
|
47
|
-
|
|
49
|
+
|
|
48
50
|
assert_equal result.all?, true
|
|
49
51
|
end
|
|
50
52
|
|
|
51
53
|
def test_identifier
|
|
52
|
-
basic = create_internal
|
|
53
|
-
|
|
54
|
+
basic = create_internal 'id' => 'basic-id'
|
|
55
|
+
|
|
56
|
+
assert_equal 'basic-id', basic.identifier
|
|
54
57
|
|
|
55
|
-
|
|
58
|
+
basic.style.stubs(identifier: 'style-identifier')
|
|
56
59
|
assert_equal basic.identifier, 'basic-idstyle-identifier'
|
|
57
60
|
end
|
|
58
61
|
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::ImageBlock::TestFormat < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
8
|
TEST_IMAGE_BLOCK_FORMAT = {
|
|
9
9
|
"type" => "s-iblock",
|
|
@@ -48,11 +48,11 @@ class ThinReports::Core::Shape::ImageBlock::TestFormat < MiniTest::Unit::TestCas
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def build_format
|
|
51
|
-
|
|
51
|
+
Thinreports::Core::Shape::ImageBlock::Format.build(TEST_IMAGE_BLOCK_FORMAT)
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def format(data)
|
|
55
|
-
|
|
55
|
+
Thinreports::Core::Shape::ImageBlock::Format.new(data)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
end
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::ImageBlock::TestInterface < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
|
+
|
|
8
|
+
ImageBlock = Thinreports::Core::Shape::ImageBlock
|
|
4
9
|
|
|
5
|
-
class ThinReports::Core::Shape::ImageBlock::TestInterface < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
|
-
ImageBlock = ThinReports::Core::Shape::ImageBlock
|
|
9
|
-
|
|
10
10
|
def setup
|
|
11
|
-
@
|
|
12
|
-
|
|
11
|
+
@report = new_report 'layout_block.tlf'
|
|
12
|
+
@page = @report.start_new_page
|
|
13
13
|
end
|
|
14
|
-
|
|
15
|
-
def
|
|
16
|
-
@
|
|
17
|
-
assert_equal
|
|
14
|
+
|
|
15
|
+
def test_src
|
|
16
|
+
@page.item(:image_block1).src('/path/to/image.png')
|
|
17
|
+
assert_equal '/path/to/image.png', @page.item(:image_block1).src
|
|
18
18
|
end
|
|
19
|
-
|
|
20
|
-
def
|
|
21
|
-
|
|
19
|
+
|
|
20
|
+
def test_src=
|
|
21
|
+
@page.item(:image_block1).src = '/path/to/image.png'
|
|
22
|
+
assert_equal '/path/to/image.png', @page.item(:image_block1).src
|
|
22
23
|
end
|
|
23
|
-
end
|
|
24
|
+
end
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::ImageBlock::TestInternal < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
|
+
|
|
8
|
+
ImageBlock = Thinreports::Core::Shape::ImageBlock
|
|
4
9
|
|
|
5
|
-
class ThinReports::Core::Shape::ImageBlock::TestInternal < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
|
-
ImageBlock = ThinReports::Core::Shape::ImageBlock
|
|
9
|
-
|
|
10
10
|
def test_src_should_return_the_same_value_as_value_method
|
|
11
|
-
internal =
|
|
11
|
+
internal = create_internal
|
|
12
12
|
internal.write_value('/path/to/image.png')
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
assert_same internal.src, internal.read_value
|
|
15
15
|
end
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
def test_type_of_asker_should_return_true_when_iblock_value_is_given
|
|
18
|
-
assert_equal
|
|
18
|
+
assert_equal create_internal.type_of?(:iblock), true
|
|
19
19
|
end
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
def test_type_of_asker_should_return_true_when_block_value_is_given
|
|
22
|
-
assert_equal
|
|
22
|
+
assert_equal create_internal.type_of?(:block), true
|
|
23
23
|
end
|
|
24
|
-
|
|
25
|
-
def
|
|
26
|
-
|
|
24
|
+
|
|
25
|
+
def create_internal
|
|
26
|
+
report = new_report 'layout_text1'
|
|
27
|
+
parent = report.start_new_page
|
|
28
|
+
|
|
29
|
+
ImageBlock::Internal.new parent, ImageBlock::Format.new({})
|
|
27
30
|
end
|
|
28
|
-
end
|
|
31
|
+
end
|
|
@@ -1,31 +1,44 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::List::TestConfiguration < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
|
+
|
|
8
|
+
List = Thinreports::Core::Shape::List
|
|
4
9
|
|
|
5
|
-
class ThinReports::Core::Shape::List::TestConfiguration < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
|
-
List = ThinReports::Core::Shape::List
|
|
9
|
-
|
|
10
10
|
def setup
|
|
11
|
-
@events =
|
|
12
|
-
@store =
|
|
11
|
+
@events = mock('events')
|
|
12
|
+
@store = mock('store')
|
|
13
13
|
@config = List::Configuration.new
|
|
14
|
-
end
|
|
15
|
-
|
|
14
|
+
end
|
|
15
|
+
|
|
16
16
|
def test_use_stores
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
@config.use_stores(:
|
|
17
|
+
List::Store.expects(:init).once
|
|
18
|
+
|
|
19
|
+
@config.use_stores(a: 0, b: 0)
|
|
20
20
|
end
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
def test_events
|
|
23
|
+
assert_instance_of List::Events, @config.events
|
|
24
|
+
|
|
25
|
+
out, err = capture_io do
|
|
26
|
+
@config.events
|
|
27
|
+
end
|
|
28
|
+
assert_includes err, '[DEPRECATION]'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_internal_events
|
|
32
|
+
assert_same @config.events, @config.internal_events
|
|
33
|
+
end
|
|
34
|
+
|
|
22
35
|
def test_store
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
@config.use_stores(:
|
|
36
|
+
List::Store.expects(:init).returns(@store)
|
|
37
|
+
|
|
38
|
+
@config.use_stores(a: 0, b: 0)
|
|
26
39
|
assert_same @config.store, @store
|
|
27
40
|
end
|
|
28
|
-
|
|
41
|
+
|
|
29
42
|
def test_store_return_nil_when_uninitialized_yet
|
|
30
43
|
assert_nil @config.store
|
|
31
44
|
end
|
|
@@ -33,25 +46,24 @@ class ThinReports::Core::Shape::List::TestConfiguration < MiniTest::Unit::TestCa
|
|
|
33
46
|
def test_type
|
|
34
47
|
assert_equal @config.type, List::TYPE_NAME
|
|
35
48
|
end
|
|
36
|
-
|
|
49
|
+
|
|
37
50
|
def test_copy
|
|
38
|
-
copied_store =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
copied_events =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
51
|
+
copied_store = mock('copied store')
|
|
52
|
+
|
|
53
|
+
@store.stubs(copy: copied_store)
|
|
54
|
+
List::Store.expects(:init).returns(@store)
|
|
55
|
+
|
|
56
|
+
copied_events = mock('copied events')
|
|
57
|
+
|
|
58
|
+
@events.stubs(copy: copied_events)
|
|
59
|
+
List::Events.expects(:new).returns(@events)
|
|
60
|
+
|
|
48
61
|
@config = List::Configuration.new
|
|
49
|
-
@config.use_stores(:
|
|
50
|
-
|
|
62
|
+
@config.use_stores(a: 1)
|
|
63
|
+
|
|
51
64
|
copied_config = @config.copy
|
|
52
|
-
|
|
65
|
+
|
|
53
66
|
assert_same copied_config.events, copied_events
|
|
54
67
|
assert_same copied_config.store, copied_store
|
|
55
68
|
end
|
|
56
69
|
end
|
|
57
|
-
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
include
|
|
5
|
+
class Thinreports::Core::Shape::List::TestEvents < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
|
-
List =
|
|
8
|
+
List = Thinreports::Core::Shape::List
|
|
9
9
|
|
|
10
10
|
def setup
|
|
11
11
|
@events = List::Events.new
|
|
@@ -13,19 +13,19 @@ class ThinReports::Core::Shape::List::TestEvents < MiniTest::Unit::TestCase
|
|
|
13
13
|
|
|
14
14
|
def test_page_footer_insert_event_should_be_able_to_be_used
|
|
15
15
|
@events.send(:verify_event_type, :page_footer_insert)
|
|
16
|
-
rescue
|
|
16
|
+
rescue Thinreports::Errors::UnknownEventType
|
|
17
17
|
flunk ':page_footer_insert cannot be used.'
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def test_footer_insert_event_should_be_able_to_be_used
|
|
21
21
|
@events.send(:verify_event_type, :footer_insert)
|
|
22
|
-
rescue
|
|
22
|
+
rescue Thinreports::Errors::UnknownEventType
|
|
23
23
|
flunk ':footer_insert cannot be used.'
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def test_page_finalize_event_should_be_able_to_be_used
|
|
27
27
|
@events.send(:verify_event_type, :page_finalize)
|
|
28
|
-
rescue
|
|
28
|
+
rescue Thinreports::Errors::UnknownEventType
|
|
29
29
|
flunk ':page_finalize cannot be used.'
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::List::TestFormat < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
4
7
|
|
|
5
|
-
class ThinReports::Core::Shape::List::TestFormat < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
8
|
TEST_LIST_FORMAT = {
|
|
9
9
|
"type" => "s-list",
|
|
10
10
|
"id" => "List",
|
|
@@ -23,32 +23,30 @@ class ThinReports::Core::Shape::List::TestFormat < MiniTest::Unit::TestCase
|
|
|
23
23
|
"attrs" => {}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
List =
|
|
28
|
-
|
|
26
|
+
|
|
27
|
+
List = Thinreports::Core::Shape::List
|
|
28
|
+
|
|
29
29
|
def test_build_when_all_sections_enabled
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
List::SectionFormat.expects(:build).returns({}).times(4)
|
|
31
|
+
|
|
33
32
|
begin
|
|
34
33
|
format = build_format
|
|
35
34
|
rescue => e
|
|
36
35
|
flunk exception_details(e, 'Building failed.')
|
|
37
36
|
end
|
|
38
|
-
|
|
37
|
+
|
|
39
38
|
assert_equal format.sections.size, 4
|
|
40
39
|
[:detail, :header, :footer, :page_footer].each do |sec|
|
|
41
40
|
assert_includes format.sections.keys, sec
|
|
42
41
|
end
|
|
43
42
|
end
|
|
44
|
-
|
|
43
|
+
|
|
45
44
|
def test_build_when_page_footer_and_footer_disabled
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
List::SectionFormat.expects(:build).returns({}).times(2)
|
|
46
|
+
|
|
49
47
|
format = build_format('page-footer-enabled' => 'false',
|
|
50
48
|
'footer-enabled' => 'false')
|
|
51
|
-
|
|
49
|
+
|
|
52
50
|
assert_equal format.sections.size, 2
|
|
53
51
|
[:detail, :header].each do |sec|
|
|
54
52
|
assert_includes format.sections.keys, sec
|
|
@@ -57,14 +55,14 @@ class ThinReports::Core::Shape::List::TestFormat < MiniTest::Unit::TestCase
|
|
|
57
55
|
|
|
58
56
|
def test_config_readers
|
|
59
57
|
format = List::Format.new(TEST_LIST_FORMAT)
|
|
60
|
-
|
|
58
|
+
|
|
61
59
|
assert_equal format.height, 255
|
|
62
60
|
assert_equal format.auto_page_break?, true
|
|
63
61
|
assert_equal format.has_header?, true
|
|
64
62
|
assert_equal format.has_footer?, true
|
|
65
63
|
assert_equal format.has_page_footer?, true
|
|
66
64
|
end
|
|
67
|
-
|
|
65
|
+
|
|
68
66
|
def build_format(data = {})
|
|
69
67
|
List::Format.build(TEST_LIST_FORMAT.merge(data))
|
|
70
68
|
end
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
include
|
|
5
|
+
class Thinreports::Core::Shape::List::TestManager < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
8
|
# Alias
|
|
9
|
-
List =
|
|
9
|
+
List = Thinreports::Core::Shape::List
|
|
10
10
|
|
|
11
11
|
def create_report(&block)
|
|
12
|
-
|
|
12
|
+
new_report('layout_list.tlf', &block)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def list_manager
|
|
@@ -1,75 +1,133 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::List::TestPage < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
4
7
|
|
|
5
|
-
class ThinReports::Core::Shape::List::TestPage < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
8
|
# Alias
|
|
9
|
-
List =
|
|
10
|
-
|
|
9
|
+
List = Thinreports::Core::Shape::List
|
|
10
|
+
|
|
11
11
|
def create_report(&block)
|
|
12
|
-
|
|
12
|
+
new_report('layout_list.tlf', &block)
|
|
13
13
|
end
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
def create_report_for_checking_dispatched_event(event)
|
|
16
16
|
@target_event = event
|
|
17
17
|
@is_dispatched = false
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
create_report do |r|
|
|
20
20
|
r.layout.config.list(:list) do |list|
|
|
21
21
|
list.events.on(event) {|e| @is_dispatched = true }
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
def assert_dispatched_event
|
|
27
27
|
assert @is_dispatched, "The :#{@target_event} event was not dispatched."
|
|
28
28
|
end
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
def test_on_page_finalize_callback
|
|
31
|
+
report = create_report
|
|
32
|
+
list = report.list(:list)
|
|
33
|
+
|
|
34
|
+
counter = 0
|
|
35
|
+
callback = -> { counter += 1 }
|
|
36
|
+
|
|
37
|
+
list.on_page_finalize(&callback)
|
|
38
|
+
|
|
39
|
+
5.times { list.add_row }
|
|
40
|
+
assert_equal 1, counter
|
|
41
|
+
|
|
42
|
+
report.generate
|
|
43
|
+
assert_equal 2, counter
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def test_on_page_footer_insert_callback
|
|
47
|
+
report = create_report
|
|
48
|
+
list = report.list(:list)
|
|
49
|
+
|
|
50
|
+
tester = 0
|
|
51
|
+
callback = -> footer {
|
|
52
|
+
assert_instance_of List::SectionInterface, footer
|
|
53
|
+
assert_equal footer.internal.section_name, :page_footer
|
|
54
|
+
|
|
55
|
+
tester += 1
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
list.on_page_footer_insert(&callback)
|
|
59
|
+
|
|
60
|
+
5.times { list.add_row }
|
|
61
|
+
assert_equal 1, tester
|
|
62
|
+
|
|
63
|
+
report.generate
|
|
64
|
+
assert_equal 2, tester
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_on_footer_insert_callback
|
|
68
|
+
report = create_report
|
|
69
|
+
list = report.list(:list)
|
|
70
|
+
|
|
71
|
+
tester = 0
|
|
72
|
+
callback = -> footer {
|
|
73
|
+
assert_instance_of List::SectionInterface, footer
|
|
74
|
+
assert_equal footer.internal.section_name, :footer
|
|
75
|
+
|
|
76
|
+
tester += 1
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
list.on_footer_insert(&callback)
|
|
80
|
+
|
|
81
|
+
5.times { list.add_row }
|
|
82
|
+
assert_equal 0, tester
|
|
83
|
+
|
|
84
|
+
report.generate
|
|
85
|
+
assert_equal 1, tester
|
|
86
|
+
end
|
|
87
|
+
|
|
30
88
|
def test_page_finalize_event_should_be_dispatched_when_page_break_is_called
|
|
31
89
|
report = create_report_for_checking_dispatched_event :page_finalize
|
|
32
90
|
report.start_new_page do
|
|
33
91
|
list(:list).page_break
|
|
34
92
|
end
|
|
35
|
-
|
|
93
|
+
|
|
36
94
|
assert_dispatched_event
|
|
37
95
|
end
|
|
38
|
-
|
|
96
|
+
|
|
39
97
|
def test_page_finalize_event_should_be_dispatched_when_list_was_overflowed
|
|
40
98
|
report = create_report_for_checking_dispatched_event :page_finalize
|
|
41
99
|
report.start_new_page do
|
|
42
100
|
6.times { list(:list).add_row }
|
|
43
101
|
end
|
|
44
|
-
|
|
102
|
+
|
|
45
103
|
assert_dispatched_event
|
|
46
104
|
end
|
|
47
|
-
|
|
105
|
+
|
|
48
106
|
def test_page_finalize_event_should_be_dispatched_when_a_new_page_is_created
|
|
49
107
|
report = create_report_for_checking_dispatched_event :page_finalize
|
|
50
108
|
report.start_new_page do
|
|
51
109
|
list(:list).add_row
|
|
52
110
|
end
|
|
53
111
|
report.start_new_page
|
|
54
|
-
|
|
112
|
+
|
|
55
113
|
assert_dispatched_event
|
|
56
114
|
end
|
|
57
|
-
|
|
115
|
+
|
|
58
116
|
def test_page_finalize_event_should_be_dispatched_when_report_is_finalized
|
|
59
117
|
report = create_report_for_checking_dispatched_event :page_finalize
|
|
60
118
|
report.start_new_page do
|
|
61
119
|
list(:list).add_row
|
|
62
120
|
end
|
|
63
121
|
report.finalize
|
|
64
|
-
|
|
122
|
+
|
|
65
123
|
assert_dispatched_event
|
|
66
124
|
end
|
|
67
|
-
|
|
125
|
+
|
|
68
126
|
def test_copy_should_properly_work_when_list_has_not_header
|
|
69
|
-
report =
|
|
70
|
-
|
|
127
|
+
report = new_report('layout_list_noheader.tlf')
|
|
128
|
+
|
|
71
129
|
10.times {|t| report.list.add_row }
|
|
72
130
|
rescue => e
|
|
73
131
|
flunk exception_details(e, 'Not worked when list has not header')
|
|
74
132
|
end
|
|
75
|
-
end
|
|
133
|
+
end
|