thinreports 0.9.1 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/test.yml +39 -0
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +59 -2
  5. data/Dockerfile +12 -0
  6. data/Gemfile +7 -4
  7. data/README.md +44 -22
  8. data/Rakefile +14 -31
  9. data/lib/thinreports.rb +16 -15
  10. data/lib/thinreports/config.rb +2 -24
  11. data/lib/thinreports/core/errors.rb +6 -17
  12. data/lib/thinreports/core/format/base.rb +62 -61
  13. data/lib/thinreports/core/shape.rb +10 -12
  14. data/lib/thinreports/core/shape/base.rb +3 -12
  15. data/lib/thinreports/core/shape/base/interface.rb +34 -32
  16. data/lib/thinreports/core/shape/base/internal.rb +45 -43
  17. data/lib/thinreports/core/shape/basic.rb +12 -12
  18. data/lib/thinreports/core/shape/basic/block_format.rb +8 -6
  19. data/lib/thinreports/core/shape/basic/block_interface.rb +24 -22
  20. data/lib/thinreports/core/shape/basic/block_internal.rb +28 -26
  21. data/lib/thinreports/core/shape/basic/format.rb +11 -9
  22. data/lib/thinreports/core/shape/basic/interface.rb +79 -77
  23. data/lib/thinreports/core/shape/basic/internal.rb +17 -14
  24. data/lib/thinreports/core/shape/image_block.rb +9 -9
  25. data/lib/thinreports/core/shape/image_block/format.rb +7 -5
  26. data/lib/thinreports/core/shape/image_block/interface.rb +15 -13
  27. data/lib/thinreports/core/shape/image_block/internal.rb +10 -8
  28. data/lib/thinreports/core/shape/list.rb +13 -13
  29. data/lib/thinreports/core/shape/list/format.rb +83 -77
  30. data/lib/thinreports/core/shape/list/manager.rb +179 -176
  31. data/lib/thinreports/core/shape/list/page.rb +91 -93
  32. data/lib/thinreports/core/shape/list/page_state.rb +42 -40
  33. data/lib/thinreports/core/shape/list/section_format.rb +28 -26
  34. data/lib/thinreports/core/shape/list/section_interface.rb +42 -40
  35. data/lib/thinreports/core/shape/list/section_internal.rb +21 -19
  36. data/lib/thinreports/core/shape/manager.rb +4 -13
  37. data/lib/thinreports/core/shape/manager/format.rb +21 -19
  38. data/lib/thinreports/core/shape/manager/internal.rb +87 -84
  39. data/lib/thinreports/core/shape/manager/target.rb +93 -95
  40. data/lib/thinreports/core/shape/page_number.rb +9 -9
  41. data/lib/thinreports/core/shape/page_number/format.rb +20 -18
  42. data/lib/thinreports/core/shape/page_number/interface.rb +20 -18
  43. data/lib/thinreports/core/shape/page_number/internal.rb +46 -44
  44. data/lib/thinreports/core/shape/style.rb +5 -14
  45. data/lib/thinreports/core/shape/style/base.rb +121 -120
  46. data/lib/thinreports/core/shape/style/basic.rb +12 -10
  47. data/lib/thinreports/core/shape/style/graphic.rb +35 -33
  48. data/lib/thinreports/core/shape/style/text.rb +113 -107
  49. data/lib/thinreports/core/shape/text.rb +9 -9
  50. data/lib/thinreports/core/shape/text/format.rb +10 -9
  51. data/lib/thinreports/core/shape/text/interface.rb +13 -11
  52. data/lib/thinreports/core/shape/text/internal.rb +14 -12
  53. data/lib/thinreports/core/shape/text_block.rb +10 -10
  54. data/lib/thinreports/core/shape/text_block/format.rb +35 -33
  55. data/lib/thinreports/core/shape/text_block/formatter.rb +26 -24
  56. data/lib/thinreports/core/shape/text_block/formatter/basic.rb +25 -25
  57. data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +15 -12
  58. data/lib/thinreports/core/shape/text_block/formatter/number.rb +52 -34
  59. data/lib/thinreports/core/shape/text_block/formatter/padding.rb +17 -14
  60. data/lib/thinreports/core/shape/text_block/interface.rb +25 -23
  61. data/lib/thinreports/core/shape/text_block/internal.rb +66 -68
  62. data/lib/thinreports/core/utils.rb +7 -3
  63. data/lib/thinreports/generator/pdf.rb +24 -25
  64. data/lib/thinreports/generator/pdf/document.rb +109 -110
  65. data/lib/thinreports/generator/pdf/document/draw_shape.rb +57 -51
  66. data/lib/thinreports/generator/pdf/document/draw_template_items.rb +50 -47
  67. data/lib/thinreports/generator/pdf/document/font.rb +67 -58
  68. data/lib/thinreports/generator/pdf/document/graphics.rb +32 -33
  69. data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +121 -121
  70. data/lib/thinreports/generator/pdf/document/graphics/basic.rb +112 -114
  71. data/lib/thinreports/generator/pdf/document/graphics/image.rb +58 -150
  72. data/lib/thinreports/generator/pdf/document/graphics/text.rb +149 -137
  73. data/lib/thinreports/generator/pdf/document/page.rb +60 -64
  74. data/lib/thinreports/generator/pdf/document/parse_color.rb +37 -37
  75. data/lib/thinreports/generator/pdf/drawer/base.rb +41 -41
  76. data/lib/thinreports/generator/pdf/drawer/list.rb +56 -54
  77. data/lib/thinreports/generator/pdf/drawer/list_section.rb +42 -40
  78. data/lib/thinreports/generator/pdf/drawer/page.rb +101 -96
  79. data/lib/thinreports/generator/pdf/prawn_ext.rb +4 -30
  80. data/lib/thinreports/generator/pdf/prawn_ext/calc_image_dimensions.rb +32 -0
  81. data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +35 -0
  82. data/lib/thinreports/layout.rb +5 -7
  83. data/lib/thinreports/layout/base.rb +5 -9
  84. data/lib/thinreports/layout/format.rb +17 -13
  85. data/lib/thinreports/layout/legacy_schema.rb +17 -13
  86. data/lib/thinreports/layout/version.rb +22 -25
  87. data/lib/thinreports/report.rb +4 -6
  88. data/lib/thinreports/report/base.rb +24 -51
  89. data/lib/thinreports/report/internal.rb +13 -15
  90. data/lib/thinreports/report/page.rb +5 -11
  91. data/lib/thinreports/version.rb +2 -2
  92. data/thinreports.gemspec +10 -19
  93. metadata +13 -288
  94. data/.travis.yml +0 -19
  95. data/examples/character_spacing/character_spacing.rb +0 -8
  96. data/examples/character_spacing/character_spacing.tlf +0 -293
  97. data/examples/dynamic_image/dynamic_image.rb +0 -31
  98. data/examples/dynamic_image/dynamic_image.tlf +0 -661
  99. data/examples/dynamic_image/img200x100.png +0 -0
  100. data/examples/dynamic_image/img50x50.png +0 -0
  101. data/examples/dynamic_style/dynamic_style.rb +0 -150
  102. data/examples/dynamic_style/dynamic_style.tlf +0 -1835
  103. data/examples/dynamic_style/dynamic_style_in_list.tlf +0 -344
  104. data/examples/dynamic_style/image.png +0 -0
  105. data/examples/eudc/eudc.rb +0 -20
  106. data/examples/eudc/eudc.tlf +0 -180
  107. data/examples/eudc/eudc.ttf +0 -0
  108. data/examples/helper.rb +0 -50
  109. data/examples/hidden_shapes/hidden_shapes.rb +0 -9
  110. data/examples/hidden_shapes/hidden_shapes.tlf +0 -449
  111. data/examples/list_events/list_events.rb +0 -32
  112. data/examples/list_events/list_events.tlf +0 -361
  113. data/examples/list_manual_generation/list_manual_generation.rb +0 -22
  114. data/examples/list_manual_generation/list_manual_generation.tlf +0 -132
  115. data/examples/list_page_number/list_page_number.rb +0 -17
  116. data/examples/list_page_number/list_page_number.tlf +0 -254
  117. data/examples/page_number/page_number.rb +0 -33
  118. data/examples/page_number/page_number.tlf +0 -215
  119. data/examples/palleted_png/palleted_png.png +0 -0
  120. data/examples/palleted_png/palleted_png.rb +0 -11
  121. data/examples/palleted_png/palleted_png.tlf +0 -47
  122. data/examples/password_setting/password_setting.rb +0 -10
  123. data/examples/password_setting/password_setting.tlf +0 -45
  124. data/examples/report_callbacks/report_callbacks.rb +0 -14
  125. data/examples/report_callbacks/report_callbacks.tlf +0 -147
  126. data/examples/single_line_tblock/single_line_tblock.rb +0 -13
  127. data/examples/single_line_tblock/single_line_tblock.tlf +0 -170
  128. data/examples/tblock_overflow/tblock_overflow.rb +0 -20
  129. data/examples/tblock_overflow/tblock_overflow.tlf +0 -538
  130. data/examples/tblock_styles/font_size.tlf +0 -383
  131. data/examples/tblock_styles/tblock_styles.rb +0 -43
  132. data/examples/tblock_styles/tblock_styles.tlf +0 -889
  133. data/examples/text_align/text_align.rb +0 -8
  134. data/examples/text_align/text_align.tlf +0 -241
  135. data/examples/typeB_page_size/B4_ISO.tlf +0 -45
  136. data/examples/typeB_page_size/B4_JIS.tlf +0 -45
  137. data/examples/typeB_page_size/typeB_page_size.rb +0 -17
  138. data/examples/word_wrap/word_wrap.rb +0 -26
  139. data/examples/word_wrap/word_wrap.tlf +0 -297
  140. data/lib/thinreports/generator.rb +0 -29
  141. data/lib/thinreports/generator/base.rb +0 -40
  142. data/lib/thinreports/generator/configuration.rb +0 -31
  143. data/lib/thinreports/report/events.rb +0 -32
  144. data/test/data/font.ttf +0 -0
  145. data/test/data/image_normal.jpg +0 -0
  146. data/test/data/image_normal.png +0 -0
  147. data/test/data/image_normal_jpg_noext +0 -0
  148. data/test/data/image_normal_png_noext +0 -0
  149. data/test/data/image_pallete_based.png +0 -0
  150. data/test/data/legacy_layout/all-items.tlf +0 -1
  151. data/test/schema_helper.rb +0 -121
  152. data/test/test_helper.rb +0 -42
  153. data/test/tmp/.gitkeep +0 -0
  154. data/test/unit/core/format/test_base.rb +0 -152
  155. data/test/unit/core/shape/base/test_internal.rb +0 -87
  156. data/test/unit/core/shape/basic/test_block_format.rb +0 -23
  157. data/test/unit/core/shape/basic/test_block_interface.rb +0 -29
  158. data/test/unit/core/shape/basic/test_block_internal.rb +0 -55
  159. data/test/unit/core/shape/basic/test_format.rb +0 -37
  160. data/test/unit/core/shape/basic/test_interface.rb +0 -108
  161. data/test/unit/core/shape/basic/test_internal.rb +0 -55
  162. data/test/unit/core/shape/image_block/test_interface.rb +0 -24
  163. data/test/unit/core/shape/image_block/test_internal.rb +0 -31
  164. data/test/unit/core/shape/list/test_format.rb +0 -111
  165. data/test/unit/core/shape/list/test_manager.rb +0 -67
  166. data/test/unit/core/shape/list/test_page.rb +0 -82
  167. data/test/unit/core/shape/list/test_page_state.rb +0 -31
  168. data/test/unit/core/shape/list/test_section_format.rb +0 -36
  169. data/test/unit/core/shape/list/test_section_interface.rb +0 -75
  170. data/test/unit/core/shape/list/test_section_internal.rb +0 -50
  171. data/test/unit/core/shape/manager/test_format.rb +0 -38
  172. data/test/unit/core/shape/manager/test_internal.rb +0 -132
  173. data/test/unit/core/shape/manager/test_target.rb +0 -140
  174. data/test/unit/core/shape/page_number/test_format.rb +0 -55
  175. data/test/unit/core/shape/page_number/test_interface.rb +0 -33
  176. data/test/unit/core/shape/page_number/test_internal.rb +0 -81
  177. data/test/unit/core/shape/styles/test_base.rb +0 -191
  178. data/test/unit/core/shape/styles/test_basic.rb +0 -24
  179. data/test/unit/core/shape/styles/test_graphic.rb +0 -50
  180. data/test/unit/core/shape/styles/test_text.rb +0 -97
  181. data/test/unit/core/shape/text/test_format.rb +0 -44
  182. data/test/unit/core/shape/text/test_internal.rb +0 -20
  183. data/test/unit/core/shape/text_block/formatter/test_basic.rb +0 -24
  184. data/test/unit/core/shape/text_block/formatter/test_datetime.rb +0 -49
  185. data/test/unit/core/shape/text_block/formatter/test_number.rb +0 -76
  186. data/test/unit/core/shape/text_block/formatter/test_padding.rb +0 -77
  187. data/test/unit/core/shape/text_block/test_format.rb +0 -169
  188. data/test/unit/core/shape/text_block/test_formatter.rb +0 -28
  189. data/test/unit/core/shape/text_block/test_interface.rb +0 -63
  190. data/test/unit/core/shape/text_block/test_internal.rb +0 -128
  191. data/test/unit/core/test_shape.rb +0 -52
  192. data/test/unit/core/test_utils.rb +0 -68
  193. data/test/unit/generator/pdf/document/graphics/test_attributes.rb +0 -135
  194. data/test/unit/generator/pdf/document/graphics/test_basic.rb +0 -45
  195. data/test/unit/generator/pdf/document/graphics/test_image.rb +0 -150
  196. data/test/unit/generator/pdf/document/graphics/test_text.rb +0 -171
  197. data/test/unit/generator/pdf/document/test_font.rb +0 -84
  198. data/test/unit/generator/pdf/document/test_graphics.rb +0 -42
  199. data/test/unit/generator/pdf/document/test_page.rb +0 -122
  200. data/test/unit/generator/pdf/document/test_parse_color.rb +0 -30
  201. data/test/unit/generator/pdf/test_document.rb +0 -20
  202. data/test/unit/generator/test_base.rb +0 -40
  203. data/test/unit/generator/test_configuration.rb +0 -21
  204. data/test/unit/generator/test_pdf.rb +0 -24
  205. data/test/unit/layout/test_base.rb +0 -41
  206. data/test/unit/layout/test_format.rb +0 -100
  207. data/test/unit/layout/test_legacy_schema.rb +0 -574
  208. data/test/unit/layout/test_version.rb +0 -95
  209. data/test/unit/report/test_base.rb +0 -262
  210. data/test/unit/report/test_internal.rb +0 -206
  211. data/test/unit/test_config.rb +0 -51
  212. data/test/unit/test_layout.rb +0 -12
  213. data/test/unit/test_report.rb +0 -18
@@ -1,111 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'test_helper'
4
-
5
- class Thinreports::Core::Shape::List::TestFormat < Minitest::Test
6
- include Thinreports::TestHelper
7
-
8
- LIST_FORMAT = {
9
- 'type' => 'list',
10
- 'id' => 'list',
11
- 'display' => true,
12
- 'x' => 10.0,
13
- 'y' => 20.0,
14
- 'width' => 30.0,
15
- 'height' => 40.0,
16
- 'content-height' => 255,
17
- 'auto-page-break' => true,
18
- 'header' => {
19
- 'enabled' => true,
20
- 'height' => 10.0,
21
- 'translate' => { 'x' => 210.0, 'y' => 310.0 },
22
- 'items' => []
23
- },
24
- 'detail' => {
25
- 'height' => 20.0,
26
- 'translate' => { 'x' => 220.0, 'y' => 320.0 },
27
- 'items' => []
28
- },
29
- 'page-footer' => {
30
- 'enabled' => true,
31
- 'height' => 30.0,
32
- 'translate' => { 'x' => 230.0, 'y' => 330.0 },
33
- 'items' => []
34
- },
35
- 'footer' => {
36
- 'enabled' => false,
37
- 'height' => 40.0,
38
- 'translate' => { 'x' => 240.0, 'y' => 340.0 },
39
- 'items' => []
40
- }
41
- }
42
-
43
- List = Thinreports::Core::Shape::List
44
-
45
- def test_has_section?
46
- format = List::Format.new(LIST_FORMAT)
47
-
48
- assert_equal true, format.has_section?(:detail)
49
- assert_equal true, format.has_section?(:page_footer)
50
- assert_equal false, format.has_section?(:footer)
51
- end
52
-
53
- def test_section_height
54
- format = List::Format.new(LIST_FORMAT)
55
-
56
- assert_equal 10.0, format.section_height(:header)
57
- end
58
-
59
- def test_attribute_readers
60
- format = List::Format.new(LIST_FORMAT)
61
-
62
- assert_equal 255, format.height
63
- assert_equal true, format.auto_page_break?
64
- assert_equal true, format.has_header?
65
- assert_equal true, format.has_page_footer?
66
- assert_equal false, format.has_footer?
67
- assert_equal 20.0, format.detail_height
68
- assert_equal 30.0, format.page_footer_height
69
- assert_equal 40.0, format.footer_height
70
- assert_equal 10.0, format.header_height
71
- end
72
-
73
- def test_section_base_position_top
74
- page_footer_disabled = LIST_FORMAT
75
-
76
- format = List::Format.new(page_footer_disabled)
77
- assert_equal 310.0, format.section_base_position_top(:header)
78
- assert_equal 320.0, format.section_base_position_top(:detail)
79
- assert_equal 310.0, format.section_base_position_top(:page_footer)
80
- assert_equal 0, format.section_base_position_top(:footer)
81
-
82
- format_footer_enabled = format_section_enabled(true, 'footer', LIST_FORMAT)
83
-
84
- format = List::Format.new(format_footer_enabled)
85
- assert_equal 290.0, format.section_base_position_top(:footer)
86
-
87
- format_footer_enabld_and_page_footer_disabled = format_section_enabled(false, 'page-footer', format_footer_enabled)
88
-
89
- format = List::Format.new(format_footer_enabld_and_page_footer_disabled)
90
- assert_equal 320.0, format.section_base_position_top(:footer)
91
- end
92
-
93
- def test_initialize_sections
94
- format = List::Format.new(LIST_FORMAT)
95
-
96
- assert_instance_of List::SectionFormat, format.sections[:header]
97
- assert_instance_of List::SectionFormat, format.sections[:detail]
98
- assert_instance_of List::SectionFormat, format.sections[:page_footer]
99
-
100
- assert_nil format.sections[:footer]
101
- end
102
-
103
- private
104
-
105
- def format_section_enabled(enable, section, list_format)
106
- section_format = list_format[section].dup
107
- section_format['enabled'] = enable
108
-
109
- list_format.merge(section => section_format)
110
- end
111
- end
@@ -1,67 +0,0 @@
1
- # coding: utf-8
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
- # coding: utf-8
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
- # coding: utf-8
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
- # coding: utf-8
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
- # coding: utf-8
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
- # coding: utf-8
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