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,28 +1,28 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::List::TestPageState < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
4
7
|
|
|
5
|
-
class ThinReports::Core::Shape::List::TestPageState < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
8
|
# Alias
|
|
9
|
-
List =
|
|
10
|
-
|
|
9
|
+
List = Thinreports::Core::Shape::List
|
|
10
|
+
|
|
11
11
|
def setup
|
|
12
|
-
parent =
|
|
13
|
-
format =
|
|
14
|
-
|
|
12
|
+
parent = mock('parent')
|
|
13
|
+
format = mock('format')
|
|
14
|
+
|
|
15
15
|
@state = List::PageState.new(parent, format)
|
|
16
16
|
end
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
def test_alias_class
|
|
19
19
|
assert_same List::PageState, List::Internal
|
|
20
20
|
end
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
def test_type_of?
|
|
23
23
|
assert_equal @state.type_of?(:list), true
|
|
24
24
|
end
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
def test_finalized!
|
|
27
27
|
assert_equal @state.finalized?, false
|
|
28
28
|
@state.finalized!
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::List::TestSectionFormat < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
4
7
|
|
|
5
|
-
class ThinReports::Core::Shape::List::TestSectionFormat < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
8
|
TEST_LIST_SECTION_FORMAT = {
|
|
9
9
|
"height" => 47.7,
|
|
10
10
|
"translate" => {"x" => 0, "y" => -64.2},
|
|
@@ -15,32 +15,31 @@ class ThinReports::Core::Shape::List::TestSectionFormat < MiniTest::Unit::TestCa
|
|
|
15
15
|
"<!---SHAPE{\"type\":\"s-tblock\",\"id\":\"t2\"}SHAPE--->"
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
Shape =
|
|
20
|
-
|
|
18
|
+
|
|
19
|
+
Shape = Thinreports::Core::Shape
|
|
20
|
+
|
|
21
21
|
def test_build
|
|
22
|
-
shape_format =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
should_receive(:build).times(1).and_return(shape_format)
|
|
22
|
+
shape_format = stub(id: 'mock')
|
|
23
|
+
|
|
24
|
+
Shape::TextBlock::Format.expects(:build).returns(shape_format).times(2)
|
|
25
|
+
Shape::Basic::Format.expects(:build).returns(shape_format).times(1)
|
|
26
|
+
|
|
28
27
|
begin
|
|
29
28
|
build_format
|
|
30
29
|
rescue => e
|
|
31
30
|
flunk exception_details(e, 'Building failed.')
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
|
-
|
|
33
|
+
|
|
35
34
|
def test_config_readers
|
|
36
35
|
format = Shape::List::SectionFormat.new(TEST_LIST_SECTION_FORMAT)
|
|
37
|
-
|
|
36
|
+
|
|
38
37
|
assert_equal format.height, 47.7
|
|
39
38
|
assert_equal format.relative_left, 0
|
|
40
39
|
assert_equal format.relative_top, -64.2
|
|
41
40
|
end
|
|
42
|
-
|
|
41
|
+
|
|
43
42
|
def build_format
|
|
44
43
|
Shape::List::SectionFormat.build(TEST_LIST_SECTION_FORMAT.dup)
|
|
45
44
|
end
|
|
46
|
-
end
|
|
45
|
+
end
|
|
@@ -1,59 +1,67 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::List::TestSectionInterface < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
4
7
|
|
|
5
|
-
class ThinReports::Core::Shape::List::TestSectionInterface < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
8
|
# Alias
|
|
9
|
-
List =
|
|
10
|
-
|
|
9
|
+
List = Thinreports::Core::Shape::List
|
|
10
|
+
|
|
11
|
+
def setup
|
|
12
|
+
@report = new_report 'layout_text1'
|
|
13
|
+
end
|
|
14
|
+
|
|
11
15
|
def create_interface(format_config = {})
|
|
12
|
-
|
|
16
|
+
parent = @report.start_new_page
|
|
17
|
+
|
|
18
|
+
List::SectionInterface.new parent,
|
|
13
19
|
List::SectionFormat.new(format_config),
|
|
14
|
-
:section
|
|
20
|
+
:section
|
|
15
21
|
end
|
|
16
|
-
|
|
22
|
+
|
|
17
23
|
def test_internal_should_return_instance_of_SectionInternal
|
|
18
24
|
assert_instance_of List::SectionInternal, create_interface.internal
|
|
19
25
|
end
|
|
20
|
-
|
|
26
|
+
|
|
21
27
|
def test_initialize_should_properly_set_the_specified_section_name_to_internal
|
|
22
28
|
assert_equal create_interface.internal.section_name, :section
|
|
23
29
|
end
|
|
24
|
-
|
|
30
|
+
|
|
25
31
|
def test_initialize_should_properly_initialize_manager
|
|
26
|
-
assert_instance_of
|
|
32
|
+
assert_instance_of Thinreports::Core::Shape::Manager::Internal,
|
|
27
33
|
create_interface.manager
|
|
28
34
|
end
|
|
29
|
-
|
|
35
|
+
|
|
30
36
|
def test_height_should_operate_as_delegator_of_internal
|
|
31
37
|
list = create_interface('height' => 100)
|
|
32
38
|
assert_same list.height, list.internal.height
|
|
33
39
|
end
|
|
34
|
-
|
|
40
|
+
|
|
35
41
|
def test_copied_interface_should_succeed_an_section_name_of_original
|
|
36
42
|
list = create_interface
|
|
37
|
-
|
|
43
|
+
new_parent = @report.start_new_page
|
|
44
|
+
|
|
45
|
+
assert_same list.copy(new_parent).internal.section_name,
|
|
38
46
|
list.internal.section_name
|
|
39
47
|
end
|
|
40
|
-
|
|
48
|
+
|
|
41
49
|
def test_copied_interface_should_have_all_the_copies_of_Shape_which_original_holds
|
|
42
50
|
list = create_interface
|
|
43
51
|
copied_list(list) do |new_list|
|
|
44
52
|
assert_equal new_list.manager.shapes.size, 3
|
|
45
53
|
end
|
|
46
54
|
end
|
|
47
|
-
|
|
55
|
+
|
|
48
56
|
def copied_list(list, &block)
|
|
49
|
-
tblock =
|
|
50
|
-
new_parent =
|
|
51
|
-
|
|
57
|
+
tblock = Thinreports::Core::Shape::TextBlock
|
|
58
|
+
new_parent = @report.start_new_page
|
|
59
|
+
|
|
52
60
|
%w( foo bar hoge ).each do |id|
|
|
53
61
|
list.manager.format.shapes[id.to_sym] = tblock::Format.new('type' => 's-tblock', 'id' => id)
|
|
54
62
|
list.item(id).value(10)
|
|
55
63
|
end
|
|
56
|
-
|
|
64
|
+
|
|
57
65
|
block.call(list.copy(new_parent))
|
|
58
66
|
end
|
|
59
|
-
end
|
|
67
|
+
end
|
|
@@ -1,55 +1,57 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::List::TestSectionInternal < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
4
7
|
|
|
5
|
-
class ThinReports::Core::Shape::List::TestSectionInternal < 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_internal(format_config = {})
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
report = new_report 'layout_text1'
|
|
13
|
+
parent = report.start_new_page
|
|
14
|
+
|
|
15
|
+
List::SectionInternal.new report, List::SectionFormat.new(format_config)
|
|
14
16
|
end
|
|
15
|
-
|
|
17
|
+
|
|
16
18
|
def test_height_should_operate_as_delegator_of_format
|
|
17
19
|
list = create_internal('height' => 100)
|
|
18
20
|
assert_same list.height, list.format.height
|
|
19
21
|
end
|
|
20
|
-
|
|
22
|
+
|
|
21
23
|
def test_relative_left_should_operate_as_delegator_of_format
|
|
22
24
|
list = create_internal('translate' => {'x' => 10})
|
|
23
25
|
assert_same list.relative_left, list.format.relative_left
|
|
24
26
|
end
|
|
25
|
-
|
|
27
|
+
|
|
26
28
|
def test_relative_top_should_operate_as_delegator_of_format
|
|
27
29
|
list = create_internal('translate' => {'y' => 10})
|
|
28
30
|
assert_same list.relative_top, list.format.relative_top
|
|
29
31
|
end
|
|
30
|
-
|
|
32
|
+
|
|
31
33
|
def test_svg_tag_should_operate_as_delegator_of_format
|
|
32
34
|
list = create_internal('svg' => {'tag' => 'g'})
|
|
33
35
|
assert_same list.svg_tag, list.format.svg_tag
|
|
34
36
|
end
|
|
35
|
-
|
|
37
|
+
|
|
36
38
|
def test_move_top_to_should_properly_set_value_to_states_as_relative_top
|
|
37
39
|
list = create_internal
|
|
38
40
|
list.move_top_to(200)
|
|
39
|
-
|
|
41
|
+
|
|
40
42
|
assert_equal list.states[:relative_top], 200
|
|
41
43
|
end
|
|
42
|
-
|
|
44
|
+
|
|
43
45
|
def test_relative_position_should_return_Array_included_coordinates
|
|
44
46
|
list = create_internal('translate' => {'x' => 100, 'y' => 200})
|
|
45
|
-
|
|
47
|
+
|
|
46
48
|
assert_equal list.relative_position, [100, 200]
|
|
47
49
|
end
|
|
48
|
-
|
|
50
|
+
|
|
49
51
|
def test_Y_coordinate_which_relative_position_returns_should_be_calculated_position_with_relative_top_of_states
|
|
50
52
|
list = create_internal('translate' => {'x' => 100, 'y' => 100})
|
|
51
53
|
list.move_top_to(50)
|
|
52
|
-
|
|
54
|
+
|
|
53
55
|
assert_equal list.relative_position.last, 150
|
|
54
56
|
end
|
|
55
|
-
end
|
|
57
|
+
end
|
|
@@ -1,14 +1,14 @@
|
|
|
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::TestStore < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
|
-
List =
|
|
8
|
+
List = Thinreports::Core::Shape::List
|
|
9
9
|
|
|
10
10
|
def test_new
|
|
11
|
-
klass = List::Store.new(:
|
|
11
|
+
klass = List::Store.new(foo: 'foo', hoge: 0)
|
|
12
12
|
|
|
13
13
|
assert_instance_of ::Class, klass
|
|
14
14
|
|
|
@@ -21,7 +21,7 @@ class ThinReports::Core::Shape::List::TestStore < MiniTest::Unit::TestCase
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def test_init
|
|
24
|
-
store = List::Store.init(:
|
|
24
|
+
store = List::Store.init(foo: 0, hoge: 'hoge')
|
|
25
25
|
|
|
26
26
|
assert_respond_to store, :foo
|
|
27
27
|
assert_respond_to store, :hoge
|
|
@@ -31,7 +31,7 @@ class ThinReports::Core::Shape::List::TestStore < MiniTest::Unit::TestCase
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def test_copy
|
|
34
|
-
store = List::Store.init(:
|
|
34
|
+
store = List::Store.init(foo: Time.now)
|
|
35
35
|
|
|
36
36
|
copied = store.copy
|
|
37
37
|
|
|
@@ -1,34 +1,30 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::Manager::TestFormat < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
|
+
|
|
8
|
+
class TestFormat < Thinreports::Core::Shape::Manager::Format; end
|
|
4
9
|
|
|
5
|
-
class ThinReports::Core::Shape::Manager::TestFormat < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
|
-
class TestFormat < ThinReports::Core::Shape::Manager::Format; end
|
|
9
|
-
|
|
10
10
|
def test_identifier_should_return_the_same_as_object_id_when_id_is_not_given
|
|
11
11
|
format = TestFormat.new({})
|
|
12
12
|
assert_equal format.identifier, format.object_id
|
|
13
13
|
end
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
def test_identifier_should_return_the_specified_id_when_id_is_given
|
|
16
16
|
assert_equal TestFormat.new({}, :any_id).identifier, :any_id
|
|
17
17
|
end
|
|
18
|
-
|
|
19
|
-
def test_shapes_should_return_instance_of_OrderedHash
|
|
20
|
-
assert_instance_of ThinReports::Core::OrderedHash, TestFormat.new({}).shapes
|
|
21
|
-
end
|
|
22
|
-
|
|
18
|
+
|
|
23
19
|
def test_find_shape_should_return_format_of_shape_when_shape_is_found
|
|
24
20
|
format = TestFormat.new({}) do |f|
|
|
25
|
-
f.shapes[:foo] =
|
|
21
|
+
f.shapes[:foo] = Thinreports::Core::Shape::TextBlock::Format.new('id' => 'foo',
|
|
26
22
|
'type' => 's-tblock')
|
|
27
23
|
end
|
|
28
24
|
assert_equal format.find_shape(:foo).id, 'foo'
|
|
29
25
|
end
|
|
30
|
-
|
|
26
|
+
|
|
31
27
|
def test_find_shape_should_return_nil_when_shape_is_not_found
|
|
32
28
|
assert_nil TestFormat.new({}).find_shape(:unknown)
|
|
33
29
|
end
|
|
34
|
-
end
|
|
30
|
+
end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
include
|
|
5
|
+
class Thinreports::Core::Shape::Manager::TestInternal < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
8
|
# Alias
|
|
9
|
-
Shape =
|
|
9
|
+
Shape = Thinreports::Core::Shape
|
|
10
10
|
|
|
11
11
|
def create_shape_format(type, id, other_config = {})
|
|
12
12
|
Shape::Format(type).new({'id' => id,
|
|
@@ -15,7 +15,7 @@ class ThinReports::Core::Shape::Manager::TestInternal < MiniTest::Unit::TestCase
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def create_internal(&block)
|
|
18
|
-
report =
|
|
18
|
+
report = new_report('layout_text1.tlf')
|
|
19
19
|
format = report.layout.format
|
|
20
20
|
|
|
21
21
|
# Add to default dummy shapes.
|
|
@@ -53,22 +53,22 @@ class ThinReports::Core::Shape::Manager::TestInternal < MiniTest::Unit::TestCase
|
|
|
53
53
|
|
|
54
54
|
def test_find_item_should_return_shape_when_passing_in_the_specified_only_filter
|
|
55
55
|
internal = create_internal
|
|
56
|
-
assert_equal internal.find_item(:t1, :
|
|
56
|
+
assert_equal internal.find_item(:t1, only: 's-tblock').id, 't1'
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def test_find_item_should_return_nil_when_not_passing_in_the_specified_only_filter
|
|
60
60
|
internal = create_internal
|
|
61
|
-
assert_nil internal.find_item(:t1, :
|
|
61
|
+
assert_nil internal.find_item(:t1, only: 's-list')
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def test_find_item_should_return_shape_when_passing_in_the_specified_except_filter
|
|
65
65
|
internal = create_internal
|
|
66
|
-
assert_equal internal.find_item(:ls, :
|
|
66
|
+
assert_equal internal.find_item(:ls, except: 's-tblock').id, 'ls'
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def test_find_item_should_return_shape_when_not_passing_in_the_specified_except_filter
|
|
70
70
|
internal = create_internal
|
|
71
|
-
assert_nil internal.find_item(:ls, :
|
|
71
|
+
assert_nil internal.find_item(:ls, except: 's-list')
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
def test_final_shape_should_return_nil_when_shape_is_not_found
|
|
@@ -1,121 +1,149 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::Manager::TestTarget < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
4
7
|
|
|
5
|
-
class ThinReports::Core::Shape::Manager::TestTarget < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
8
|
# Alias
|
|
9
|
-
Shape =
|
|
10
|
-
|
|
9
|
+
Shape = Thinreports::Core::Shape
|
|
10
|
+
|
|
11
11
|
class TestManager
|
|
12
12
|
include Shape::Manager::Target
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
attr_reader :layout, :report
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
def initialize(report, layout)
|
|
17
17
|
@report = report
|
|
18
18
|
@layout = layout
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
initialize_manager(layout.format) do |f|
|
|
21
21
|
Shape::Interface(self, f)
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
def create_shape_format(type, id)
|
|
27
27
|
Shape::Format(type).new('id' => id, 'type' => type)
|
|
28
28
|
end
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
def create_manager
|
|
31
|
-
report =
|
|
31
|
+
report = new_report('layout_text1.tlf')
|
|
32
32
|
layout = report.layout
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
layout.format.shapes[:
|
|
36
|
-
layout.format.shapes[:
|
|
37
|
-
layout.format.shapes[:
|
|
33
|
+
|
|
34
|
+
layout.format.shapes[:text_block1] = create_shape_format('s-tblock', 'text_block1')
|
|
35
|
+
layout.format.shapes[:text_block2] = create_shape_format('s-tblock', 'text_block2')
|
|
36
|
+
layout.format.shapes[:image_block] = create_shape_format('s-iblock', 'image_block')
|
|
37
|
+
layout.format.shapes[:rectangle] = create_shape_format('s-rect', 'rectangle')
|
|
38
|
+
layout.format.shapes[:line] = create_shape_format('s-line', 'line')
|
|
39
|
+
layout.format.shapes[:list1] = create_shape_format('s-list', 'list1')
|
|
40
|
+
layout.format.shapes[:list2] = create_shape_format('s-list', 'list2')
|
|
38
41
|
layout.format.shapes[:default] = create_shape_format('s-list', 'default')
|
|
39
|
-
|
|
42
|
+
|
|
40
43
|
TestManager.new(report, layout)
|
|
41
44
|
end
|
|
42
|
-
|
|
45
|
+
|
|
46
|
+
def test_shorthand_for_finding_item
|
|
47
|
+
manager = create_manager
|
|
48
|
+
|
|
49
|
+
text_block1 = manager[:text_block1]
|
|
50
|
+
text_block1.value = 'block1'
|
|
51
|
+
|
|
52
|
+
assert_instance_of Shape::TextBlock::Interface, manager[:text_block1]
|
|
53
|
+
assert_instance_of Shape::ImageBlock::Interface, manager[:image_block]
|
|
54
|
+
assert_instance_of Shape::Basic::Interface, manager[:rectangle]
|
|
55
|
+
|
|
56
|
+
assert_raises Thinreports::Errors::UnknownItemId do
|
|
57
|
+
manager[:unknown_id]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
assert_raises Thinreports::Errors::UnknownItemId do
|
|
61
|
+
manager[:list1]
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_shorthand_for_setting_value_to_block
|
|
66
|
+
manager = create_manager
|
|
67
|
+
|
|
68
|
+
manager[:text_block1] = 'value of text block1'
|
|
69
|
+
assert_equal 'value of text block1', manager.item(:text_block1).value
|
|
70
|
+
|
|
71
|
+
manager[:image_block] = '/path/to/image.png'
|
|
72
|
+
assert_equal '/path/to/image.png', manager.item(:image_block).src
|
|
73
|
+
|
|
74
|
+
assert_raises(NoMethodError) { manager[:rectangle] = 'value' }
|
|
75
|
+
assert_raises(Thinreports::Errors::UnknownItemId) { manager[:list1] = 'value' }
|
|
76
|
+
end
|
|
77
|
+
|
|
43
78
|
def test_manager_should_return_instance_of_ManagerInternal
|
|
44
79
|
assert_instance_of Shape::Manager::Internal, create_manager.manager
|
|
45
80
|
end
|
|
46
|
-
|
|
81
|
+
|
|
47
82
|
def test_item_should_properly_return_shape_with_the_specified_Symbol_id
|
|
48
|
-
assert_equal create_manager.item(:
|
|
83
|
+
assert_equal create_manager.item(:text_block1).id, 'text_block1'
|
|
49
84
|
end
|
|
50
|
-
|
|
85
|
+
|
|
51
86
|
def test_item_should_properly_return_shape_with_the_specified_String_id
|
|
52
|
-
assert_equal create_manager.item('
|
|
87
|
+
assert_equal create_manager.item('text_block2').id, 'text_block2'
|
|
53
88
|
end
|
|
54
|
-
|
|
89
|
+
|
|
55
90
|
def test_item_should_raise_when_the_shape_with_the_specified_id_is_not_found
|
|
56
|
-
assert_raises
|
|
91
|
+
assert_raises Thinreports::Errors::UnknownItemId do
|
|
57
92
|
create_manager.item(:unknown)
|
|
58
93
|
end
|
|
59
94
|
end
|
|
60
|
-
|
|
95
|
+
|
|
61
96
|
def test_item_should_set_an_shape_as_argument_when_a_block_is_given
|
|
62
97
|
id = nil
|
|
63
|
-
create_manager.item(:
|
|
64
|
-
assert_equal id, '
|
|
98
|
+
create_manager.item(:text_block1) {|s| id = s.id }
|
|
99
|
+
assert_equal id, 'text_block1'
|
|
65
100
|
end
|
|
66
|
-
|
|
101
|
+
|
|
67
102
|
def test_item_should_raise_when_type_of_shape_with_the_specified_id_is_list
|
|
68
|
-
assert_raises
|
|
69
|
-
create_manager.item(:
|
|
103
|
+
assert_raises Thinreports::Errors::UnknownItemId do
|
|
104
|
+
create_manager.item(:list1)
|
|
70
105
|
end
|
|
71
106
|
end
|
|
72
|
-
|
|
107
|
+
|
|
73
108
|
def test_list_should_properly_return_list_with_the_specified_Symbol_id
|
|
74
|
-
assert_equal create_manager.list(:
|
|
109
|
+
assert_equal create_manager.list(:list1).id, 'list1'
|
|
75
110
|
end
|
|
76
|
-
|
|
111
|
+
|
|
77
112
|
def test_list_should_properly_return_list_with_the_specified_String_id
|
|
78
|
-
assert_equal create_manager.list('
|
|
113
|
+
assert_equal create_manager.list('list1').id, 'list1'
|
|
79
114
|
end
|
|
80
|
-
|
|
115
|
+
|
|
81
116
|
def test_list_should_raise_when_type_of_shape_with_the_specified_id_is_not_list
|
|
82
|
-
assert_raises
|
|
83
|
-
create_manager.list(:
|
|
117
|
+
assert_raises Thinreports::Errors::UnknownItemId do
|
|
118
|
+
create_manager.list(:text_block1)
|
|
84
119
|
end
|
|
85
120
|
end
|
|
86
|
-
|
|
121
|
+
|
|
87
122
|
def test_list_should_use_default_as_id_when_id_is_omitted
|
|
88
123
|
assert_equal create_manager.list.id, 'default'
|
|
89
124
|
end
|
|
90
|
-
|
|
125
|
+
|
|
91
126
|
def test_values_should_properly_set_values_to_shapes_with_specified_id
|
|
92
127
|
manager = create_manager
|
|
93
|
-
manager.values(:
|
|
94
|
-
|
|
95
|
-
assert_equal [manager.item(:
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def test_items_should_show_deprecation_warning
|
|
99
|
-
out, err = capture_io do
|
|
100
|
-
create_manager.items(:t1 => 1000)
|
|
101
|
-
end
|
|
102
|
-
assert_match %r!DEPRECATION!, err
|
|
128
|
+
manager.values(text_block1: 1000, 'text_block2' => 'value')
|
|
129
|
+
|
|
130
|
+
assert_equal [manager.item(:text_block1).value, manager.item(:text_block2).value], [1000, 'value']
|
|
103
131
|
end
|
|
104
|
-
|
|
132
|
+
|
|
105
133
|
def test_item_exists_asker_should_return_true_when_shape_with_specified_Symbol_id_is_found
|
|
106
|
-
assert_equal create_manager.item_exists?(:
|
|
134
|
+
assert_equal create_manager.item_exists?(:text_block1), true
|
|
107
135
|
end
|
|
108
|
-
|
|
136
|
+
|
|
109
137
|
def test_item_exists_asker_should_return_true_when_shape_with_specified_String_id_is_found
|
|
110
|
-
assert_equal create_manager.item_exists?('
|
|
138
|
+
assert_equal create_manager.item_exists?('text_block2'), true
|
|
111
139
|
end
|
|
112
|
-
|
|
140
|
+
|
|
113
141
|
def test_item_exists_asker_should_return_false_when_shape_with_specified_id_not_found
|
|
114
142
|
assert_equal create_manager.item_exists?('unknown'), false
|
|
115
143
|
end
|
|
116
|
-
|
|
144
|
+
|
|
117
145
|
def test_exists_asker_should_operate_like_as_item_exists_asker
|
|
118
146
|
manager = create_manager
|
|
119
147
|
assert_equal manager.exists?(:unknown), manager.item_exists?(:unknown)
|
|
120
148
|
end
|
|
121
|
-
end
|
|
149
|
+
end
|