thinreports 0.10.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/CONTRIBUTING.md +2 -2
- data/.github/workflows/test.yml +51 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +49 -0
- data/Dockerfile +12 -0
- data/Gemfile +2 -1
- data/README.md +46 -21
- data/Rakefile +13 -29
- data/gemfiles/prawn-2.2.gemfile +5 -0
- data/gemfiles/prawn-2.3.gemfile +5 -0
- data/gemfiles/prawn-2.4.gemfile +5 -0
- data/lib/thinreports.rb +5 -0
- data/lib/thinreports/core/shape.rb +4 -3
- data/lib/thinreports/core/shape/base/interface.rb +0 -1
- data/lib/thinreports/core/shape/basic/format.rb +5 -0
- data/lib/thinreports/core/shape/image_block.rb +1 -1
- data/lib/thinreports/core/shape/list.rb +1 -1
- data/lib/thinreports/core/shape/list/manager.rb +1 -4
- data/lib/thinreports/core/shape/list/page.rb +2 -5
- data/lib/thinreports/core/shape/manager/internal.rb +0 -1
- data/lib/thinreports/core/shape/page_number.rb +1 -1
- data/lib/thinreports/core/shape/page_number/internal.rb +0 -1
- data/lib/thinreports/core/shape/stack_view.rb +17 -0
- data/lib/thinreports/core/shape/stack_view/format.rb +27 -0
- data/lib/thinreports/core/shape/stack_view/interface.rb +17 -0
- data/lib/thinreports/core/shape/stack_view/internal.rb +22 -0
- data/lib/thinreports/core/shape/stack_view/row_format.rb +39 -0
- data/lib/thinreports/core/shape/style/basic.rb +4 -1
- data/lib/thinreports/core/shape/text.rb +1 -1
- data/lib/thinreports/core/shape/text_block.rb +1 -1
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +21 -9
- data/lib/thinreports/core/shape/text_block/internal.rb +0 -2
- data/lib/thinreports/core/utils.rb +6 -3
- data/lib/thinreports/generate.rb +11 -0
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +31 -11
- data/lib/thinreports/generator/pdf/document/draw_template_items.rb +1 -2
- data/lib/thinreports/generator/pdf/document/font.rb +16 -10
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +0 -1
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +0 -1
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +19 -1
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +10 -8
- data/lib/thinreports/generator/pdf/document/page.rb +13 -4
- data/lib/thinreports/generator/pdf/drawer/list.rb +0 -1
- data/lib/thinreports/generator/pdf/prawn_ext/calc_image_dimensions.rb +1 -3
- data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +7 -7
- data/lib/thinreports/layout/base.rb +2 -4
- data/lib/thinreports/layout/format.rb +0 -1
- data/lib/thinreports/layout/legacy_schema.rb +2 -6
- data/lib/thinreports/layout/version.rb +1 -1
- data/lib/thinreports/report/internal.rb +4 -4
- data/lib/thinreports/report/page.rb +2 -7
- data/lib/thinreports/section_report/build.rb +32 -0
- data/lib/thinreports/section_report/builder/item_builder.rb +49 -0
- data/lib/thinreports/section_report/builder/report_builder.rb +82 -0
- data/lib/thinreports/section_report/builder/report_data.rb +13 -0
- data/lib/thinreports/section_report/builder/stack_view_builder.rb +55 -0
- data/lib/thinreports/section_report/builder/stack_view_data.rb +11 -0
- data/lib/thinreports/section_report/generate.rb +26 -0
- data/lib/thinreports/section_report/pdf/render.rb +23 -0
- data/lib/thinreports/section_report/pdf/renderer/draw_item.rb +68 -0
- data/lib/thinreports/section_report/pdf/renderer/group_renderer.rb +57 -0
- data/lib/thinreports/section_report/pdf/renderer/headers_renderer.rb +24 -0
- data/lib/thinreports/section_report/pdf/renderer/section_height.rb +100 -0
- data/lib/thinreports/section_report/pdf/renderer/section_renderer.rb +39 -0
- data/lib/thinreports/section_report/pdf/renderer/stack_view_renderer.rb +55 -0
- data/lib/thinreports/section_report/pdf/renderer/stack_view_row_renderer.rb +38 -0
- data/lib/thinreports/section_report/schema/loader.rb +28 -0
- data/lib/thinreports/section_report/schema/parser.rb +52 -0
- data/lib/thinreports/section_report/schema/report.rb +30 -0
- data/lib/thinreports/section_report/schema/section.rb +47 -0
- data/lib/thinreports/version.rb +1 -1
- data/thinreports.gemspec +11 -11
- metadata +48 -164
- data/.rubocop.yml +0 -41
- data/.travis.yml +0 -17
- data/examples/character_spacing/character_spacing.rb +0 -8
- data/examples/character_spacing/character_spacing.tlf +0 -293
- data/examples/dynamic_image/dynamic_image.rb +0 -31
- data/examples/dynamic_image/dynamic_image.tlf +0 -661
- data/examples/dynamic_image/img200x100.png +0 -0
- data/examples/dynamic_image/img50x50.png +0 -0
- data/examples/dynamic_style/dynamic_style.rb +0 -150
- data/examples/dynamic_style/dynamic_style.tlf +0 -1835
- data/examples/dynamic_style/dynamic_style_in_list.tlf +0 -344
- data/examples/dynamic_style/image.png +0 -0
- data/examples/eudc/eudc.rb +0 -20
- data/examples/eudc/eudc.tlf +0 -180
- data/examples/eudc/eudc.ttf +0 -0
- data/examples/helper.rb +0 -50
- data/examples/hidden_shapes/hidden_shapes.rb +0 -9
- data/examples/hidden_shapes/hidden_shapes.tlf +0 -449
- data/examples/list_events/list_events.rb +0 -32
- data/examples/list_events/list_events.tlf +0 -361
- data/examples/list_manual_generation/list_manual_generation.rb +0 -22
- data/examples/list_manual_generation/list_manual_generation.tlf +0 -132
- data/examples/list_page_number/list_page_number.rb +0 -17
- data/examples/list_page_number/list_page_number.tlf +0 -254
- data/examples/page_number/page_number.rb +0 -33
- data/examples/page_number/page_number.tlf +0 -215
- data/examples/palleted_png/palleted_png.png +0 -0
- data/examples/palleted_png/palleted_png.rb +0 -9
- data/examples/palleted_png/palleted_png.tlf +0 -47
- data/examples/password_setting/password_setting.rb +0 -10
- data/examples/password_setting/password_setting.tlf +0 -45
- data/examples/report_callbacks/report_callbacks.rb +0 -14
- data/examples/report_callbacks/report_callbacks.tlf +0 -147
- data/examples/single_line_tblock/single_line_tblock.rb +0 -13
- data/examples/single_line_tblock/single_line_tblock.tlf +0 -170
- data/examples/tblock_overflow/tblock_overflow.rb +0 -20
- data/examples/tblock_overflow/tblock_overflow.tlf +0 -538
- data/examples/tblock_styles/font_size.tlf +0 -383
- data/examples/tblock_styles/tblock_styles.rb +0 -43
- data/examples/tblock_styles/tblock_styles.tlf +0 -889
- data/examples/text_align/text_align.rb +0 -8
- data/examples/text_align/text_align.tlf +0 -241
- data/examples/typeB_page_size/B4_ISO.tlf +0 -45
- data/examples/typeB_page_size/B4_JIS.tlf +0 -45
- data/examples/typeB_page_size/typeB_page_size.rb +0 -17
- data/examples/word_wrap/word_wrap.rb +0 -26
- data/examples/word_wrap/word_wrap.tlf +0 -297
- data/test/data/font.ttf +0 -0
- data/test/data/image_normal.jpg +0 -0
- data/test/data/image_normal.png +0 -0
- data/test/data/image_normal_jpg_noext +0 -0
- data/test/data/image_normal_png_noext +0 -0
- data/test/data/image_pallete_based.png +0 -0
- data/test/data/legacy_layout/all-items.tlf +0 -1
- data/test/schema_helper.rb +0 -122
- data/test/test_helper.rb +0 -48
- data/test/tmp/.gitkeep +0 -0
- data/test/unit/core/format/test_base.rb +0 -152
- data/test/unit/core/shape/base/test_internal.rb +0 -87
- data/test/unit/core/shape/basic/test_block_format.rb +0 -23
- data/test/unit/core/shape/basic/test_block_interface.rb +0 -29
- data/test/unit/core/shape/basic/test_block_internal.rb +0 -55
- data/test/unit/core/shape/basic/test_format.rb +0 -37
- data/test/unit/core/shape/basic/test_interface.rb +0 -108
- data/test/unit/core/shape/basic/test_internal.rb +0 -55
- data/test/unit/core/shape/image_block/test_interface.rb +0 -24
- data/test/unit/core/shape/image_block/test_internal.rb +0 -31
- data/test/unit/core/shape/list/test_format.rb +0 -111
- data/test/unit/core/shape/list/test_manager.rb +0 -67
- data/test/unit/core/shape/list/test_page.rb +0 -82
- data/test/unit/core/shape/list/test_page_state.rb +0 -31
- data/test/unit/core/shape/list/test_section_format.rb +0 -36
- data/test/unit/core/shape/list/test_section_interface.rb +0 -75
- data/test/unit/core/shape/list/test_section_internal.rb +0 -50
- data/test/unit/core/shape/manager/test_format.rb +0 -38
- data/test/unit/core/shape/manager/test_internal.rb +0 -132
- data/test/unit/core/shape/manager/test_target.rb +0 -140
- data/test/unit/core/shape/page_number/test_format.rb +0 -55
- data/test/unit/core/shape/page_number/test_interface.rb +0 -33
- data/test/unit/core/shape/page_number/test_internal.rb +0 -81
- data/test/unit/core/shape/styles/test_base.rb +0 -191
- data/test/unit/core/shape/styles/test_basic.rb +0 -24
- data/test/unit/core/shape/styles/test_graphic.rb +0 -50
- data/test/unit/core/shape/styles/test_text.rb +0 -97
- data/test/unit/core/shape/text/test_format.rb +0 -44
- data/test/unit/core/shape/text/test_internal.rb +0 -20
- data/test/unit/core/shape/text_block/formatter/test_basic.rb +0 -24
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +0 -49
- data/test/unit/core/shape/text_block/formatter/test_number.rb +0 -76
- data/test/unit/core/shape/text_block/formatter/test_padding.rb +0 -77
- data/test/unit/core/shape/text_block/test_format.rb +0 -169
- data/test/unit/core/shape/text_block/test_formatter.rb +0 -28
- data/test/unit/core/shape/text_block/test_interface.rb +0 -63
- data/test/unit/core/shape/text_block/test_internal.rb +0 -128
- data/test/unit/core/test_shape.rb +0 -52
- data/test/unit/core/test_utils.rb +0 -68
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +0 -135
- data/test/unit/generator/pdf/document/graphics/test_basic.rb +0 -46
- data/test/unit/generator/pdf/document/graphics/test_image.rb +0 -46
- data/test/unit/generator/pdf/document/graphics/test_text.rb +0 -171
- data/test/unit/generator/pdf/document/test_font.rb +0 -84
- data/test/unit/generator/pdf/document/test_graphics.rb +0 -42
- data/test/unit/generator/pdf/document/test_page.rb +0 -122
- data/test/unit/generator/pdf/document/test_parse_color.rb +0 -30
- data/test/unit/generator/pdf/prawn_ext/test_calc_image_dimensions.rb +0 -41
- data/test/unit/generator/pdf/prawn_ext/test_width_of.rb +0 -22
- data/test/unit/generator/pdf/test_document.rb +0 -22
- data/test/unit/generator/test_pdf.rb +0 -26
- data/test/unit/layout/test_base.rb +0 -41
- data/test/unit/layout/test_format.rb +0 -100
- data/test/unit/layout/test_legacy_schema.rb +0 -574
- data/test/unit/layout/test_version.rb +0 -26
- data/test/unit/report/test_base.rb +0 -248
- data/test/unit/report/test_internal.rb +0 -206
- data/test/unit/test_config.rb +0 -36
- data/test/unit/test_layout.rb +0 -12
- data/test/unit/test_report.rb +0 -18
@@ -1,67 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::List::TestManager < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
# Alias
|
9
|
-
List = Thinreports::Core::Shape::List
|
10
|
-
|
11
|
-
def create_report(&block)
|
12
|
-
report = Thinreports::Report.new layout: layout_file.path
|
13
|
-
block.call(report) if block_given?
|
14
|
-
report
|
15
|
-
end
|
16
|
-
|
17
|
-
def list_manager
|
18
|
-
report = create_report {|r| r.start_new_page }
|
19
|
-
report.page.list.manager
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_current_page_should_return_the_instance_of_ListPage
|
23
|
-
assert_instance_of List::Page, list_manager.current_page
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_current_page_state_should_return_the_instance_of_ListPageState
|
27
|
-
assert_instance_of List::PageState, list_manager.current_page_state
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_switch_current_should_replace_own_current_page_property_by_the_given_page
|
31
|
-
report = create_report {|r| r.start_new_page }
|
32
|
-
list = report.page.list
|
33
|
-
new_page = List::Page.new(report.page, list.internal.format)
|
34
|
-
|
35
|
-
list.manager.switch_current!(new_page)
|
36
|
-
|
37
|
-
assert_same list.manager.current_page, new_page
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_switch_current_should_replace_own_current_page_state_property_by_internal_property_of_the_given_page
|
41
|
-
report = create_report {|r| r.start_new_page }
|
42
|
-
list = report.page.list
|
43
|
-
new_page = List::Page.new(report.page, list.internal.format)
|
44
|
-
|
45
|
-
list.manager.switch_current!(new_page)
|
46
|
-
|
47
|
-
assert_same list.manager.current_page_state, new_page.internal
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_switch_current_should_return_the_self
|
51
|
-
report = create_report {|r| r.start_new_page }
|
52
|
-
list = report.page.list
|
53
|
-
new_page = List::Page.new(report.page, list.internal.format)
|
54
|
-
|
55
|
-
assert_same list.manager.switch_current!(new_page), list.manager
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_page_count
|
59
|
-
report = create_report
|
60
|
-
assert_equal report.page_count, 0
|
61
|
-
|
62
|
-
report.list.page_break
|
63
|
-
report.list.page_break
|
64
|
-
|
65
|
-
assert_equal report.list.manager.page_count, 2
|
66
|
-
end
|
67
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::List::TestPage < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
# Alias
|
9
|
-
List = Thinreports::Core::Shape::List
|
10
|
-
|
11
|
-
def create_report(&block)
|
12
|
-
report = Thinreports::Report.new layout: layout_file.path
|
13
|
-
block.call(report) if block_given?
|
14
|
-
report
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_on_page_finalize_callback
|
18
|
-
report = create_report
|
19
|
-
list = report.list
|
20
|
-
|
21
|
-
counter = 0
|
22
|
-
callback = -> { counter += 1 }
|
23
|
-
|
24
|
-
list.on_page_finalize(&callback)
|
25
|
-
|
26
|
-
5.times { list.add_row }
|
27
|
-
assert_equal 1, counter
|
28
|
-
|
29
|
-
report.finalize
|
30
|
-
assert_equal 2, counter
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_on_page_footer_insert_callback
|
34
|
-
report = create_report
|
35
|
-
list = report.list
|
36
|
-
|
37
|
-
tester = 0
|
38
|
-
callback = -> footer {
|
39
|
-
assert_instance_of List::SectionInterface, footer
|
40
|
-
assert_equal footer.internal.section_name, :page_footer
|
41
|
-
|
42
|
-
tester += 1
|
43
|
-
}
|
44
|
-
|
45
|
-
list.on_page_footer_insert(&callback)
|
46
|
-
|
47
|
-
5.times { list.add_row }
|
48
|
-
assert_equal 1, tester
|
49
|
-
|
50
|
-
report.finalize
|
51
|
-
assert_equal 2, tester
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_on_footer_insert_callback
|
55
|
-
report = create_report
|
56
|
-
list = report.list
|
57
|
-
|
58
|
-
tester = 0
|
59
|
-
callback = -> footer {
|
60
|
-
assert_instance_of List::SectionInterface, footer
|
61
|
-
assert_equal footer.internal.section_name, :footer
|
62
|
-
|
63
|
-
tester += 1
|
64
|
-
}
|
65
|
-
|
66
|
-
list.on_footer_insert(&callback)
|
67
|
-
|
68
|
-
5.times { list.add_row }
|
69
|
-
assert_equal 0, tester
|
70
|
-
|
71
|
-
report.finalize
|
72
|
-
assert_equal 1, tester
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_copy_should_properly_work_when_list_has_not_header
|
76
|
-
report = Thinreports::Report.new layout: layout_file(schema: LIST_NO_HEADER_SCHEMA_JSON).path
|
77
|
-
|
78
|
-
10.times { report.list.add_row }
|
79
|
-
rescue => e
|
80
|
-
flunk exception_details(e, 'Not worked when list has not header')
|
81
|
-
end
|
82
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::List::TestPageState < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
# Alias
|
9
|
-
List = Thinreports::Core::Shape::List
|
10
|
-
|
11
|
-
def setup
|
12
|
-
parent = mock('parent')
|
13
|
-
format = mock('format')
|
14
|
-
|
15
|
-
@state = List::PageState.new(parent, format)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_alias_class
|
19
|
-
assert_same List::PageState, List::Internal
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_type_of?
|
23
|
-
assert_equal @state.type_of?('list'), true
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_finalized!
|
27
|
-
assert_equal @state.finalized?, false
|
28
|
-
@state.finalized!
|
29
|
-
assert_equal @state.finalized?, true
|
30
|
-
end
|
31
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::List::TestSectionFormat < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
LIST_SECTION_FORMAT = {
|
9
|
-
'enabled' => true,
|
10
|
-
'height' => 47.7,
|
11
|
-
'translate' => { 'x' => 0, 'y' => -64.2 },
|
12
|
-
'items' => [
|
13
|
-
{ 'type' => 'rect', 'id' => '' },
|
14
|
-
{ 'type' => 'text-block', 'id' => 'text_block' }
|
15
|
-
]
|
16
|
-
}
|
17
|
-
|
18
|
-
Shape = Thinreports::Core::Shape
|
19
|
-
List = Thinreports::Core::Shape::List
|
20
|
-
|
21
|
-
def test_attribute_readers
|
22
|
-
format = List::SectionFormat.new(LIST_SECTION_FORMAT)
|
23
|
-
|
24
|
-
assert_equal 47.7, format.height
|
25
|
-
assert_equal 0, format.relative_left
|
26
|
-
assert_equal(-64.2, format.relative_top)
|
27
|
-
assert_equal true, format.display?
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_initialize_items
|
31
|
-
format = List::SectionFormat.new(LIST_SECTION_FORMAT)
|
32
|
-
|
33
|
-
assert_equal 1, format.shapes.count
|
34
|
-
assert_instance_of Shape::TextBlock::Format, format.shapes[:text_block]
|
35
|
-
end
|
36
|
-
end
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::List::TestSectionInterface < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
BASIC_SECTION_SCHEMA = {
|
9
|
-
'height' => 1.0,
|
10
|
-
'enabled' => true,
|
11
|
-
'items' => []
|
12
|
-
}
|
13
|
-
|
14
|
-
# Alias
|
15
|
-
List = Thinreports::Core::Shape::List
|
16
|
-
|
17
|
-
def setup
|
18
|
-
@report = Thinreports::Report.new layout: layout_file.path
|
19
|
-
end
|
20
|
-
|
21
|
-
def create_interface(extra_section_schema = {})
|
22
|
-
parent = @report.start_new_page
|
23
|
-
|
24
|
-
List::SectionInterface.new(
|
25
|
-
parent,
|
26
|
-
List::SectionFormat.new(BASIC_SECTION_SCHEMA.merge(extra_section_schema)),
|
27
|
-
:section
|
28
|
-
)
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_internal_should_return_instance_of_SectionInternal
|
32
|
-
assert_instance_of List::SectionInternal, create_interface.internal
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_initialize_should_properly_set_the_specified_section_name_to_internal
|
36
|
-
assert_equal create_interface.internal.section_name, :section
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_initialize_should_properly_initialize_manager
|
40
|
-
assert_instance_of Thinreports::Core::Shape::Manager::Internal,
|
41
|
-
create_interface.manager
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_height_should_operate_as_delegator_of_internal
|
45
|
-
list = create_interface('height' => 100)
|
46
|
-
assert_same list.height, list.internal.height
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_copied_interface_should_succeed_an_section_name_of_original
|
50
|
-
list = create_interface
|
51
|
-
new_parent = @report.start_new_page
|
52
|
-
|
53
|
-
assert_same list.copy(new_parent).internal.section_name,
|
54
|
-
list.internal.section_name
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_copied_interface_should_have_all_the_copies_of_Shape_which_original_holds
|
58
|
-
list = create_interface
|
59
|
-
copied_list(list) do |new_list|
|
60
|
-
assert_equal new_list.manager.shapes.size, 3
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def copied_list(list, &block)
|
65
|
-
tblock = Thinreports::Core::Shape::TextBlock
|
66
|
-
new_parent = @report.start_new_page
|
67
|
-
|
68
|
-
%w( foo bar hoge ).each do |id|
|
69
|
-
list.manager.format.shapes[id.to_sym] = tblock::Format.new('type' => 'text-block', 'id' => id)
|
70
|
-
list.item(id).value(10)
|
71
|
-
end
|
72
|
-
|
73
|
-
block.call(list.copy(new_parent))
|
74
|
-
end
|
75
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::List::TestSectionInternal < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
BASIC_SECTION_SCHEMA = {
|
9
|
-
'height' => 1.0,
|
10
|
-
'enabled' => true,
|
11
|
-
'items' => []
|
12
|
-
}
|
13
|
-
|
14
|
-
# Alias
|
15
|
-
List = Thinreports::Core::Shape::List
|
16
|
-
|
17
|
-
def create_internal(extra_section_schema = {})
|
18
|
-
report = Thinreports::Report.new layout: layout_file.path
|
19
|
-
|
20
|
-
List::SectionInternal.new(
|
21
|
-
report,
|
22
|
-
List::SectionFormat.new(BASIC_SECTION_SCHEMA.merge(extra_section_schema))
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_height_should_operate_as_delegator_of_format
|
27
|
-
list = create_internal('height' => 100)
|
28
|
-
assert_same list.height, list.format.height
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_relative_left_should_operate_as_delegator_of_format
|
32
|
-
list = create_internal('translate' => {'x' => 10})
|
33
|
-
assert_same list.relative_left, list.format.relative_left
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_move_top_to_should_properly_set_value_to_states_as_relative_top
|
37
|
-
list = create_internal
|
38
|
-
list.move_top_to(200)
|
39
|
-
|
40
|
-
assert_equal list.states[:relative_top], 200
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_relative_top
|
44
|
-
list = create_internal('translate' => { 'y' => 100 })
|
45
|
-
assert_equal 0, list.relative_top
|
46
|
-
|
47
|
-
list.move_top_to 50
|
48
|
-
assert_equal 50, list.relative_top
|
49
|
-
end
|
50
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
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
|
9
|
-
|
10
|
-
def test_identifier_should_return_the_same_as_object_id_when_id_is_not_given
|
11
|
-
format = TestFormat.new({})
|
12
|
-
assert_equal format.identifier, format.object_id
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_identifier_should_return_the_specified_id_when_id_is_given
|
16
|
-
assert_equal TestFormat.new({}, :any_id).identifier, :any_id
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_has_shape
|
20
|
-
format = TestFormat.new({}) do |f|
|
21
|
-
f.shapes[:foo] = 1
|
22
|
-
end
|
23
|
-
assert format.has_shape?(:foo)
|
24
|
-
refute format.has_shape?(:unknown)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_find_shape_should_return_format_of_shape_when_shape_is_found
|
28
|
-
format = TestFormat.new({}) do |f|
|
29
|
-
f.shapes[:foo] = Thinreports::Core::Shape::TextBlock::Format.new('id' => 'foo',
|
30
|
-
'type' => 'text-block')
|
31
|
-
end
|
32
|
-
assert_equal format.find_shape(:foo).id, 'foo'
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_find_shape_should_return_nil_when_shape_is_not_found
|
36
|
-
assert_nil TestFormat.new({}).find_shape(:unknown)
|
37
|
-
end
|
38
|
-
end
|
@@ -1,132 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::Manager::TestInternal < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
# Alias
|
9
|
-
Shape = Thinreports::Core::Shape
|
10
|
-
|
11
|
-
def create_shape_format(type, id, other_config = {})
|
12
|
-
Shape::Format(type).new({'id' => id,
|
13
|
-
'type' => type,
|
14
|
-
'display' => true}.merge(other_config))
|
15
|
-
end
|
16
|
-
|
17
|
-
def create_internal(&block)
|
18
|
-
report = Thinreports::Report.new layout: layout_file.path
|
19
|
-
format = report.layout.format
|
20
|
-
|
21
|
-
block.call(format) if block_given?
|
22
|
-
|
23
|
-
report.start_new_page.manager
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_find_format_should_return_format_with_the_specified_Symbol_id
|
27
|
-
assert_equal create_internal.find_format(:text_block).id, 'text_block'
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_find_format_should_return_format_with_the_specified_String_id
|
31
|
-
assert_equal create_internal.find_format('text_block').id, 'text_block'
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_find_format_should_return_nil_when_format_with_specified_id_is_not_found
|
35
|
-
assert_nil create_internal.find_format(:unknown)
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_find_item_should_return_shape_with_the_specified_id
|
39
|
-
assert_instance_of Shape::TextBlock::Interface, create_internal.find_item(:text_block)
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_find_item_should_return_shape_in_shapes_registry_when_the_specified_shape_exists_in_registry
|
43
|
-
internal = create_internal
|
44
|
-
internal.find_item(:text_block)
|
45
|
-
|
46
|
-
assert_same internal.find_item(:text_block), internal.shapes[:text_block]
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_find_item_should_return_shape_when_passing_in_the_specified_only_filter
|
50
|
-
internal = create_internal
|
51
|
-
assert_equal internal.find_item(:text_block, only: 'text-block').id, 'text_block'
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_find_item_should_return_nil_when_not_passing_in_the_specified_only_filter
|
55
|
-
internal = create_internal
|
56
|
-
assert_nil internal.find_item(:text_block, only: 'list')
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_find_item_should_return_shape_when_passing_in_the_specified_except_filter
|
60
|
-
internal = create_internal
|
61
|
-
assert_equal internal.find_item(:default, except: 'text-block').id, 'default'
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_find_item_should_return_shape_when_not_passing_in_the_specified_except_filter
|
65
|
-
internal = create_internal
|
66
|
-
assert_nil internal.find_item(:default, except: 'list')
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_final_shape_should_return_nil_when_shape_is_not_found
|
70
|
-
internal = create_internal
|
71
|
-
assert_nil internal.final_shape(:unknown)
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_final_shape_should_return_nil_when_shape_is_stored_in_shapes_and_hidden
|
75
|
-
internal = create_internal
|
76
|
-
internal.find_item(:text_block).hide
|
77
|
-
|
78
|
-
assert_nil internal.final_shape(:text_block)
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_final_shape_should_return_shape_when_shape_is_stored_in_shapes_and_TextBlock_with_value
|
82
|
-
internal = create_internal
|
83
|
-
internal.find_item(:text_block).value('value')
|
84
|
-
|
85
|
-
assert_equal internal.final_shape(:text_block).id, 'text_block'
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_final_shape_should_return_nil_when_shape_is_stored_in_shapes_and_TextBlock_with_no_value
|
89
|
-
internal = create_internal
|
90
|
-
internal.find_item(:text_block)
|
91
|
-
|
92
|
-
assert_nil internal.final_shape(:text_block)
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_final_shape_should_return_shape_when_shape_is_stored_in_shapes_and_ImageBlock_with_src
|
96
|
-
internal = create_internal
|
97
|
-
internal.find_item(:image_block).src('/path/to/image.png')
|
98
|
-
|
99
|
-
assert_equal internal.final_shape(:image_block).id, 'image_block'
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_final_shape_should_return_nil_when_shape_is_stored_in_shapes_and_ImageBlock_with_no_src
|
103
|
-
internal = create_internal
|
104
|
-
assert_nil internal.final_shape(:image_block)
|
105
|
-
end
|
106
|
-
|
107
|
-
def test_final_shape_should_return_nil_when_shape_isnot_stored_in_shapes_and_hidden
|
108
|
-
assert_nil create_internal.final_shape(:text_block_hidden)
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_final_shape_should_return_shape_when_shape_isnot_stored_in_shapes_and_not_Block
|
112
|
-
assert_equal create_internal.final_shape(:rect_with_id).id, 'rect_with_id'
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_final_shape_should_return_nil_when_shape_isnot_stored_in_shapes_and_ImageBlock
|
116
|
-
internal = create_internal do |f|
|
117
|
-
f.shapes[:iblock] = create_shape_format('image-block', 'iblock')
|
118
|
-
end
|
119
|
-
|
120
|
-
assert_nil internal.final_shape(:iblock)
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_final_shape_should_return_shape_when_shape_isnot_stored_in_shapes_and_TextBlock_with_reference
|
124
|
-
assert_equal create_internal.final_shape(:text_block_referenced).id, 'text_block_referenced'
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_final_shape_should_return_nil_when_shape_isnot_stored_in_shapes_and_TextBlock_with_no_value_no_reference
|
128
|
-
internal = create_internal
|
129
|
-
|
130
|
-
assert_nil internal.final_shape(:t1)
|
131
|
-
end
|
132
|
-
end
|