thinreports 0.7.6 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (277) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -5
  3. data/.travis.yml +8 -4
  4. data/CHANGELOG.md +220 -0
  5. data/Gemfile +2 -9
  6. data/MIT-LICENSE +1 -1
  7. data/README.md +286 -0
  8. data/Rakefile +38 -8
  9. data/examples/character_spacing/character_spacing.rb +8 -0
  10. data/examples/character_spacing/character_spacing.tlf +1 -0
  11. data/examples/dynamic_image/dynamic_image.rb +31 -0
  12. data/examples/dynamic_image/dynamic_image.tlf +1 -0
  13. data/examples/dynamic_style/dynamic_style.rb +150 -0
  14. data/examples/dynamic_style/dynamic_style.tlf +1 -0
  15. data/examples/dynamic_style/dynamic_style_in_list.tlf +1 -0
  16. data/examples/eudc/eudc.rb +20 -0
  17. data/examples/eudc/eudc.tlf +1 -0
  18. data/examples/helper.rb +50 -0
  19. data/examples/hidden_shapes/hidden_shapes.rb +9 -0
  20. data/examples/hidden_shapes/hidden_shapes.tlf +1 -0
  21. data/examples/list_events/list_events.rb +59 -0
  22. data/examples/list_events/list_events_0_7_7.tlf +1 -0
  23. data/examples/list_events/list_events_0_8.tlf +1 -0
  24. data/examples/list_manual_generation/list_manual_generation.rb +22 -0
  25. data/examples/list_manual_generation/list_manual_generation.tlf +1 -0
  26. data/examples/list_page_number/list_page_number.rb +17 -0
  27. data/examples/list_page_number/list_page_number.tlf +1 -0
  28. data/examples/page_number/page_number.rb +33 -0
  29. data/examples/page_number/page_number.tlf +1 -0
  30. data/examples/password_setting/password_setting.rb +10 -0
  31. data/examples/password_setting/password_setting.tlf +1 -0
  32. data/examples/report_callbacks/report_callbacks.rb +31 -0
  33. data/examples/report_callbacks/report_callbacks.tlf +1 -0
  34. data/examples/single_line_tblock/single_line_tblock.rb +13 -0
  35. data/examples/single_line_tblock/single_line_tblock.tlf +1 -0
  36. data/examples/tblock_overflow/tblock_overflow.rb +20 -0
  37. data/examples/tblock_overflow/tblock_overflow.tlf +1 -0
  38. data/examples/tblock_styles/font_size.tlf +1 -0
  39. data/examples/tblock_styles/tblock_styles.rb +43 -0
  40. data/examples/tblock_styles/tblock_styles.tlf +1 -0
  41. data/examples/text_align/text_align.rb +8 -0
  42. data/examples/text_align/text_align.tlf +1 -0
  43. data/examples/typeB_page_size/B4_ISO.tlf +1 -0
  44. data/examples/typeB_page_size/B4_JIS.tlf +1 -0
  45. data/examples/typeB_page_size/typeB_page_size.rb +17 -0
  46. data/examples/word_wrap/word_wrap.rb +26 -0
  47. data/examples/word_wrap/word_wrap.tlf +1 -0
  48. data/lib/thinreports/config.rb +30 -10
  49. data/lib/thinreports/core/errors.rb +23 -20
  50. data/lib/thinreports/core/events.rb +18 -19
  51. data/lib/thinreports/core/format/base.rb +20 -25
  52. data/lib/thinreports/core/format/builder.rb +19 -27
  53. data/lib/thinreports/core/shape/base/interface.rb +15 -15
  54. data/lib/thinreports/core/shape/base/internal.rb +15 -20
  55. data/lib/thinreports/core/shape/base.rb +4 -5
  56. data/lib/thinreports/core/shape/basic/block_format.rb +3 -4
  57. data/lib/thinreports/core/shape/basic/block_interface.rb +9 -4
  58. data/lib/thinreports/core/shape/basic/block_internal.rb +9 -10
  59. data/lib/thinreports/core/shape/basic/format.rb +11 -10
  60. data/lib/thinreports/core/shape/basic/interface.rb +3 -3
  61. data/lib/thinreports/core/shape/basic/internal.rb +9 -6
  62. data/lib/thinreports/core/shape/basic.rb +1 -1
  63. data/lib/thinreports/core/shape/image_block/format.rb +5 -6
  64. data/lib/thinreports/core/shape/image_block/interface.rb +9 -7
  65. data/lib/thinreports/core/shape/image_block/internal.rb +5 -6
  66. data/lib/thinreports/core/shape/image_block.rb +1 -1
  67. data/lib/thinreports/core/shape/list/configuration.rb +37 -16
  68. data/lib/thinreports/core/shape/list/events.rb +11 -11
  69. data/lib/thinreports/core/shape/list/format.rb +27 -28
  70. data/lib/thinreports/core/shape/list/manager.rb +135 -95
  71. data/lib/thinreports/core/shape/list/page.rb +57 -51
  72. data/lib/thinreports/core/shape/list/page_state.rb +19 -17
  73. data/lib/thinreports/core/shape/list/section_format.rb +14 -15
  74. data/lib/thinreports/core/shape/list/section_interface.rb +15 -16
  75. data/lib/thinreports/core/shape/list/section_internal.rb +7 -8
  76. data/lib/thinreports/core/shape/list/store.rb +10 -11
  77. data/lib/thinreports/core/shape/list.rb +1 -1
  78. data/lib/thinreports/core/shape/manager/format.rb +10 -11
  79. data/lib/thinreports/core/shape/manager/internal.rb +22 -21
  80. data/lib/thinreports/core/shape/manager/target.rb +63 -34
  81. data/lib/thinreports/core/shape/manager.rb +1 -1
  82. data/lib/thinreports/core/shape/page_number/format.rb +25 -0
  83. data/lib/thinreports/core/shape/page_number/interface.rb +27 -0
  84. data/lib/thinreports/core/shape/page_number/internal.rb +57 -0
  85. data/lib/thinreports/core/shape/page_number.rb +15 -0
  86. data/lib/thinreports/core/shape/style/base.rb +29 -29
  87. data/lib/thinreports/core/shape/style/basic.rb +1 -1
  88. data/lib/thinreports/core/shape/style/graphic.rb +10 -25
  89. data/lib/thinreports/core/shape/style/text.rb +41 -31
  90. data/lib/thinreports/core/shape/style.rb +1 -1
  91. data/lib/thinreports/core/shape/text/format.rb +8 -9
  92. data/lib/thinreports/core/shape/text/interface.rb +2 -2
  93. data/lib/thinreports/core/shape/text/internal.rb +6 -7
  94. data/lib/thinreports/core/shape/text.rb +1 -1
  95. data/lib/thinreports/core/shape/text_block/format.rb +17 -17
  96. data/lib/thinreports/core/shape/text_block/formatter/basic.rb +13 -12
  97. data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +8 -9
  98. data/lib/thinreports/core/shape/text_block/formatter/number.rb +11 -12
  99. data/lib/thinreports/core/shape/text_block/formatter/padding.rb +9 -32
  100. data/lib/thinreports/core/shape/text_block/formatter.rb +7 -8
  101. data/lib/thinreports/core/shape/text_block/interface.rb +2 -2
  102. data/lib/thinreports/core/shape/text_block/internal.rb +19 -20
  103. data/lib/thinreports/core/shape/text_block.rb +1 -1
  104. data/lib/thinreports/core/shape.rb +11 -13
  105. data/lib/thinreports/core/utils.rb +33 -32
  106. data/lib/thinreports/generator/base.rb +15 -24
  107. data/lib/thinreports/generator/configuration.rb +10 -9
  108. data/lib/thinreports/generator/pdf/configuration.rb +11 -6
  109. data/lib/thinreports/generator/pdf/document/draw_shape.rb +41 -32
  110. data/lib/thinreports/generator/pdf/document/font.rb +53 -44
  111. data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +34 -25
  112. data/lib/thinreports/generator/pdf/document/graphics/basic.rb +25 -25
  113. data/lib/thinreports/generator/pdf/document/graphics/image.rb +15 -15
  114. data/lib/thinreports/generator/pdf/document/graphics/text.rb +43 -41
  115. data/lib/thinreports/generator/pdf/document/graphics.rb +8 -9
  116. data/lib/thinreports/generator/pdf/document/page.rb +37 -23
  117. data/lib/thinreports/generator/pdf/document/parse_color.rb +9 -10
  118. data/lib/thinreports/generator/pdf/document/parse_svg.rb +14 -15
  119. data/lib/thinreports/generator/pdf/document.rb +28 -28
  120. data/lib/thinreports/generator/pdf/drawer/base.rb +16 -22
  121. data/lib/thinreports/generator/pdf/drawer/list.rb +39 -21
  122. data/lib/thinreports/generator/pdf/drawer/list_section.rb +17 -18
  123. data/lib/thinreports/generator/pdf/drawer/page.rb +37 -26
  124. data/lib/thinreports/generator/pdf/prawn_ext.rb +18 -17
  125. data/lib/thinreports/generator/pdf.rb +28 -31
  126. data/lib/thinreports/generator.rb +6 -8
  127. data/lib/thinreports/layout/base.rb +24 -36
  128. data/lib/thinreports/layout/configuration.rb +11 -9
  129. data/lib/thinreports/layout/format.rb +26 -31
  130. data/lib/thinreports/layout/version.rb +8 -9
  131. data/lib/thinreports/layout.rb +2 -2
  132. data/lib/thinreports/report/base.rb +117 -109
  133. data/lib/thinreports/report/events.rb +5 -5
  134. data/lib/thinreports/report/internal.rb +48 -38
  135. data/lib/thinreports/{core → report}/page.rb +42 -32
  136. data/lib/thinreports/report.rb +10 -14
  137. data/lib/thinreports/version.rb +2 -3
  138. data/lib/thinreports.rb +14 -2
  139. data/test/data/font.ttf +0 -0
  140. data/test/data/layout_block.tlf +1 -0
  141. data/test/data/layout_list.tlf +1 -0
  142. data/test/data/layout_list_noheader.tlf +1 -0
  143. data/test/data/layout_text1.tlf +1 -0
  144. data/test/data/layout_text2.tlf +1 -0
  145. data/test/test_helper.rb +74 -0
  146. data/test/tmp/.gitkeep +0 -0
  147. data/test/unit/core/format/test_base.rb +14 -14
  148. data/test/unit/core/format/test_builder.rb +20 -25
  149. data/test/unit/core/shape/base/test_internal.rb +34 -37
  150. data/test/unit/core/shape/basic/test_basic_format.rb +4 -4
  151. data/test/unit/core/shape/basic/test_basic_interface.rb +15 -13
  152. data/test/unit/core/shape/basic/test_basic_internal.rb +19 -16
  153. data/test/unit/core/shape/basic/test_format.rb +4 -4
  154. data/test/unit/core/shape/basic/test_interface.rb +36 -46
  155. data/test/unit/core/shape/basic/test_internal.rb +29 -18
  156. data/test/unit/core/shape/image_block/test_format.rb +5 -5
  157. data/test/unit/core/shape/image_block/test_interface.rb +17 -16
  158. data/test/unit/core/shape/image_block/test_internal.rb +19 -16
  159. data/test/unit/core/shape/list/test_configuration.rb +50 -33
  160. data/test/unit/core/shape/list/test_events.rb +7 -7
  161. data/test/unit/core/shape/list/test_format.rb +16 -18
  162. data/test/unit/core/shape/list/test_manager.rb +15 -5
  163. data/test/unit/core/shape/list/test_page.rb +80 -22
  164. data/test/unit/core/shape/list/test_page_state.rb +13 -13
  165. data/test/unit/core/shape/list/test_section_format.rb +16 -17
  166. data/test/unit/core/shape/list/test_section_interface.rb +30 -22
  167. data/test/unit/core/shape/list/test_section_internal.rb +21 -19
  168. data/test/unit/core/shape/list/test_store.rb +7 -7
  169. data/test/unit/core/shape/manager/test_format.rb +11 -15
  170. data/test/unit/core/shape/manager/test_internal.rb +9 -9
  171. data/test/unit/core/shape/manager/test_target.rb +85 -57
  172. data/test/unit/core/shape/page_number/test_format.rb +73 -0
  173. data/test/unit/core/shape/page_number/test_interface.rb +33 -0
  174. data/test/unit/core/shape/page_number/test_internal.rb +81 -0
  175. data/test/unit/core/shape/styles/test_base.rb +9 -9
  176. data/test/unit/core/shape/styles/test_basic.rb +5 -5
  177. data/test/unit/core/shape/styles/test_graphic.rb +19 -33
  178. data/test/unit/core/shape/styles/test_text.rb +29 -7
  179. data/test/unit/core/shape/text/test_format.rb +6 -6
  180. data/test/unit/core/shape/text/test_internal.rb +11 -12
  181. data/test/unit/core/shape/text_block/formatter/test_basic.rb +16 -16
  182. data/test/unit/core/shape/text_block/formatter/test_datetime.rb +22 -20
  183. data/test/unit/core/shape/text_block/formatter/test_number.rb +34 -34
  184. data/test/unit/core/shape/text_block/formatter/test_padding.rb +44 -44
  185. data/test/unit/core/shape/text_block/test_format.rb +13 -8
  186. data/test/unit/core/shape/text_block/test_formatter.rb +17 -17
  187. data/test/unit/core/shape/text_block/test_interface.rb +37 -20
  188. data/test/unit/core/shape/text_block/test_internal.rb +38 -38
  189. data/test/unit/core/test_events.rb +10 -8
  190. data/test/unit/core/test_shape.rb +11 -7
  191. data/test/unit/core/test_utils.rb +68 -0
  192. data/test/unit/generator/pdf/document/graphics/test_attributes.rb +10 -4
  193. data/test/unit/generator/pdf/document/graphics/test_text.rb +60 -53
  194. data/test/unit/generator/pdf/document/test_draw_shape.rb +14 -6
  195. data/test/unit/generator/pdf/document/test_font.rb +79 -58
  196. data/test/unit/generator/pdf/document/test_graphics.rb +18 -19
  197. data/test/unit/generator/pdf/document/test_page.rb +68 -43
  198. data/test/unit/generator/pdf/document/test_parse_color.rb +5 -5
  199. data/test/unit/generator/pdf/test_configuration.rb +16 -9
  200. data/test/unit/generator/pdf/test_document.rb +8 -16
  201. data/test/unit/generator/test_base.rb +31 -42
  202. data/test/unit/generator/test_configuration.rb +6 -6
  203. data/test/unit/generator/test_pdf.rb +15 -21
  204. data/test/unit/layout/test_base.rb +34 -79
  205. data/test/unit/layout/test_configuration.rb +12 -37
  206. data/test/unit/layout/test_format.rb +36 -39
  207. data/test/unit/layout/test_version.rb +4 -4
  208. data/test/unit/report/test_base.rb +160 -192
  209. data/test/unit/report/test_events.rb +4 -4
  210. data/test/unit/report/test_internal.rb +102 -82
  211. data/test/unit/test_config.rb +31 -12
  212. data/test/unit/test_layout.rb +7 -7
  213. data/test/unit/test_report.rb +12 -24
  214. data/thinreports.gemspec +23 -26
  215. metadata +118 -181
  216. data/.yardopts +0 -1
  217. data/LICENSE +0 -1
  218. data/README.rdoc +0 -167
  219. data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
  220. data/lib/thinreports/core/ext/array.rb +0 -19
  221. data/lib/thinreports/core/ext/hash.rb +0 -19
  222. data/lib/thinreports/core/ext/object.rb +0 -25
  223. data/lib/thinreports/core/ext.rb +0 -5
  224. data/lib/thinreports/core/format.rb +0 -14
  225. data/lib/thinreports/core/ordered_hash.rb +0 -39
  226. data/lib/thinreports/core.rb +0 -20
  227. data/lib/thinreports/generator/pdf/drawer.rb +0 -16
  228. data/tasks/doc.rake +0 -13
  229. data/tasks/test.rake +0 -56
  230. data/test/benchmark/basic_estimate.tlf +0 -1
  231. data/test/benchmark/bench_basic_estimate.rb +0 -95
  232. data/test/case/character_spacing/character_spacing.rb +0 -7
  233. data/test/case/character_spacing/character_spacing.tlf +0 -1
  234. data/test/case/dynamic_image/dynamic_image.rb +0 -41
  235. data/test/case/dynamic_image/dynamic_image.tlf +0 -1
  236. data/test/case/dynamic_style/dynamic_style.rb +0 -154
  237. data/test/case/dynamic_style/dynamic_style.tlf +0 -1
  238. data/test/case/dynamic_style/dynamic_style_in_list.tlf +0 -1
  239. data/test/case/eudc/eudc.rb +0 -20
  240. data/test/case/eudc/eudc.tlf +0 -1
  241. data/test/case/helper.rb +0 -29
  242. data/test/case/hidden_shapes/hidden_shapes.rb +0 -13
  243. data/test/case/hidden_shapes/hidden_shapes.tlf +0 -1
  244. data/test/case/list_events/list_events.rb +0 -32
  245. data/test/case/list_events/list_events.tlf +0 -1
  246. data/test/case/list_header_inheriting/list_header_inheriting.rb +0 -17
  247. data/test/case/list_header_inheriting/list_header_inheriting.tlf +0 -1
  248. data/test/case/list_manual_generation/list_manual_generation.rb +0 -22
  249. data/test/case/list_manual_generation/list_manual_generation.tlf +0 -1
  250. data/test/case/single_line_tblock/single_line_tblock.rb +0 -15
  251. data/test/case/single_line_tblock/single_line_tblock.tlf +0 -1
  252. data/test/case/tblock_overflow/tblock_overflow.rb +0 -20
  253. data/test/case/tblock_overflow/tblock_overflow.tlf +0 -1
  254. data/test/case/tblock_styles/tblock_styles.rb +0 -27
  255. data/test/case/tblock_styles/tblock_styles.tlf +0 -1
  256. data/test/case/text_align/text_align.rb +0 -9
  257. data/test/case/text_align/text_align.tlf +0 -1
  258. data/test/unit/core/ext/array_spec.rb +0 -29
  259. data/test/unit/core/ext/hash_spec.rb +0 -29
  260. data/test/unit/core/ext/object_spec.rb +0 -30
  261. data/test/unit/core/ordered_hash_spec.rb +0 -51
  262. data/test/unit/core/shape/base/test_interface.rb +0 -52
  263. data/test/unit/core/utils_spec.rb +0 -56
  264. data/test/unit/data/basic_layout1.tlf +0 -1
  265. data/test/unit/data/basic_layout2.tlf +0 -1
  266. data/test/unit/data/basic_list_layout.tlf +0 -1
  267. data/test/unit/data/basic_list_noheader_layout.tlf +0 -1
  268. data/test/unit/helper.rb +0 -65
  269. /data/{test/case → examples}/dynamic_image/img200x100.png +0 -0
  270. /data/{test/case → examples}/dynamic_image/img50x50.png +0 -0
  271. /data/{test/case → examples}/dynamic_style/image.png +0 -0
  272. /data/{test/case → examples}/eudc/eudc.ttf +0 -0
  273. /data/{resources/fonts → fonts}/IPA_Font_License_Agreement_v1.0.txt +0 -0
  274. /data/{resources/fonts → fonts}/ipag.ttf +0 -0
  275. /data/{resources/fonts → fonts}/ipagp.ttf +0 -0
  276. /data/{resources/fonts → fonts}/ipam.ttf +0 -0
  277. /data/{resources/fonts → fonts}/ipamp.ttf +0 -0
@@ -1,121 +1,149 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
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 = ThinReports::Core::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 = create_basic_report('basic_layout1.tlf')
31
+ report = new_report('layout_text1.tlf')
32
32
  layout = report.layout
33
-
34
- # Add to dummy shapes.
35
- layout.format.shapes[:t1] = create_shape_format('s-tblock', 't1')
36
- layout.format.shapes[:t2] = create_shape_format('s-tblock', 't2')
37
- layout.format.shapes[:ls] = create_shape_format('s-list', 'ls')
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(:t1).id, 't1'
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('t2').id, 't2'
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 ThinReports::Errors::UnknownItemId do
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(:t1) {|s| id = s.id }
64
- assert_equal id, 't1'
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 ThinReports::Errors::UnknownItemId do
69
- create_manager.item(:ls)
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(:ls).id, 'ls'
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('ls').id, 'ls'
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 ThinReports::Errors::UnknownItemId do
83
- create_manager.list(:t1)
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(:t1 => 1000, 't2' => 'value')
94
-
95
- assert_equal [manager.item(:t1).value, manager.item(:t2).value], [1000, 'value']
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?(:t1), true
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?('t2'), true
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
@@ -0,0 +1,73 @@
1
+ # coding: utf-8
2
+
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Core::Shape::PageNumber::TestFormat < Minitest::Test
6
+ include Thinreports::TestHelper
7
+
8
+ TEST_PAGENO_FORMAT = {
9
+ "type" => "s-pageno",
10
+ "id" => "",
11
+ "display" => "true",
12
+ "box" => {
13
+ "x" => 100.0,
14
+ "y" => 100.0,
15
+ "width" => 100.0,
16
+ "height" => 100.0
17
+ },
18
+ "format" => "{page} / {total}",
19
+ "overflow" => "truncate",
20
+ "target" => "",
21
+ "svg" => {
22
+ "tag" => "text",
23
+ "attrs" => {
24
+ "x" => 308.2,
25
+ "y" => 239,
26
+ "kerning" => "auto",
27
+ "id" => "goog_939685354",
28
+ "fill" => "#000000",
29
+ "fill-opacity" => "1",
30
+ "font-size" => "18",
31
+ "font-family" => "Helvetica",
32
+ "font-weight" => "normal",
33
+ "font-style" => "normal",
34
+ "text-anchor" => "middle",
35
+ "text-decoration" => "none"
36
+ }
37
+ }
38
+ }
39
+
40
+ Format = Thinreports::Core::Shape::PageNumber::Format
41
+
42
+ def format(raw_format = nil)
43
+ Format.new(raw_format || TEST_PAGENO_FORMAT)
44
+ end
45
+
46
+ def test_build
47
+ Format.build(TEST_PAGENO_FORMAT)
48
+ rescue => e
49
+ flunk exception_details(e, 'Failed to build')
50
+ end
51
+
52
+ def test_id
53
+ pageno = format('id' => 'pageno_id')
54
+ assert_equal pageno.id, 'pageno_id'
55
+
56
+ pageno = format('id' => '')
57
+ assert_equal pageno.id, '__pageno1'
58
+ assert_same pageno.id, pageno.id
59
+ end
60
+
61
+ def test_overflow
62
+ assert_equal format.overflow, 'truncate'
63
+ end
64
+
65
+ def test_target
66
+ assert_equal format.target, ''
67
+ assert_equal format("target" => "list-id").target, 'list-id'
68
+ end
69
+
70
+ def test_default_format
71
+ assert_equal format.default_format, '{page} / {total}'
72
+ end
73
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Core::Shape::PageNumber::TestInterface < Minitest::Test
6
+ include Thinreports::TestHelper
7
+
8
+ PageNumber = Thinreports::Core::Shape::PageNumber
9
+
10
+ def create_pageno(format = {})
11
+ report = new_report 'layout_text1'
12
+ parent = report.start_new_page
13
+
14
+ PageNumber::Interface.new parent, PageNumber::Format.new(format)
15
+ end
16
+
17
+ def test_format
18
+ pageno = create_pageno 'format' => '{page}'
19
+
20
+ assert_equal pageno.format, '{page}'
21
+ pageno.format('{page} / {total}')
22
+ assert_equal pageno.format, '{page} / {total}'
23
+ end
24
+
25
+ def test_reset_format
26
+ pageno = create_pageno 'format' => '{page}'
27
+
28
+ pageno.format('-- {page} --')
29
+ pageno.reset_format
30
+
31
+ assert_equal pageno.format, '{page}'
32
+ end
33
+ end
@@ -0,0 +1,81 @@
1
+ # coding: utf-8
2
+
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Core::Shape::PageNumber::TestInternal < Minitest::Test
6
+ include Thinreports::TestHelper
7
+
8
+ PageNumber = Thinreports::Core::Shape::PageNumber
9
+
10
+ def setup
11
+ @report = new_report('layout_text1.tlf')
12
+ @report.start_new_page
13
+ end
14
+
15
+ def init_pageno(format = {})
16
+ PageNumber::Internal.new(@report.page, PageNumber::Format.new(format))
17
+ end
18
+
19
+ def test_read_format
20
+ pageno = init_pageno('format' => 'Page {page}')
21
+
22
+ assert_equal pageno.read_format, 'Page {page}'
23
+ end
24
+
25
+ def test_write_format
26
+ pageno = init_pageno('format' => 'Page {page}')
27
+ pageno.write_format('{page}')
28
+
29
+ assert_equal pageno.read_format, '{page}'
30
+ end
31
+
32
+ def test_reset_format
33
+ pageno = init_pageno('format' => '{page}')
34
+ pageno.write_format('Page {page}')
35
+ pageno.reset_format
36
+
37
+ assert_equal pageno.read_format, '{page}'
38
+ end
39
+
40
+ def test_build_format
41
+ pageno = init_pageno('format' => '{page} / {total}')
42
+ assert_equal pageno.build_format(1, 100), '1 / 100'
43
+
44
+ pageno.write_format('{page}')
45
+ assert_equal pageno.build_format(1, 100), '1'
46
+
47
+ @report.start_page_number_from 5
48
+ pageno = init_pageno('format' => '{page} / {total}')
49
+ assert_equal pageno.build_format(1, 100), '5 / 104'
50
+
51
+ # if counted target is a List shape
52
+ pageno = init_pageno('format' => '{page} / {total}',
53
+ 'target' => 'list-id')
54
+ assert_equal pageno.build_format(1, 100), '1 / 100'
55
+ end
56
+
57
+ def test_type_of
58
+ pageno = init_pageno
59
+ assert pageno.type_of?(:pageno)
60
+ end
61
+
62
+ def test_style
63
+ pageno = init_pageno
64
+ style = pageno.style
65
+
66
+ assert_instance_of PageNumber::Style, style
67
+ assert_same pageno.style, style
68
+ end
69
+
70
+ def test_for_report
71
+ pageno = init_pageno('target' => '')
72
+ assert_equal pageno.for_report?, true
73
+
74
+ pageno = init_pageno('target' => 'list-id')
75
+ assert_equal pageno.for_report?, false
76
+ end
77
+
78
+ def test_Style_class
79
+ refute_includes PageNumber::Style.accessible_styles, :valign
80
+ end
81
+ end
@@ -1,15 +1,15 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
4
 
5
- class ThinReports::Core::Shape::Style::TestBase < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
5
+ class Thinreports::Core::Shape::Style::TestBase < Minitest::Test
6
+ include Thinreports::TestHelper
7
7
 
8
8
  # Alias
9
- Style = ThinReports::Core::Shape::Style::Base
9
+ Style = Thinreports::Core::Shape::Style::Base
10
10
 
11
11
  def create_basic_format(attrs = {})
12
- ThinReports::Core::Shape::Basic::Format.new('svg' => {'attrs' => attrs})
12
+ Thinreports::Core::Shape::Basic::Format.new('svg' => {'attrs' => attrs})
13
13
  end
14
14
 
15
15
  def create_style(base = {})
@@ -178,17 +178,17 @@ class ThinReports::Core::Shape::Style::TestBase < MiniTest::Unit::TestCase
178
178
  end
179
179
 
180
180
  def test_reader_method_caller_should_raise_when_style_is_not_accessible
181
- assert_raises ThinReports::Errors::UnknownShapeStyleName do
181
+ assert_raises Thinreports::Errors::UnknownShapeStyleName do
182
182
  create_new_style[:unknown]
183
183
  end
184
184
  end
185
185
 
186
186
  def test_writer_method_caller_should_raise_when_style_is_not_accessible
187
- assert_raises ThinReports::Errors::UnknownShapeStyleName do
187
+ assert_raises Thinreports::Errors::UnknownShapeStyleName do
188
188
  create_new_style[:unknown] = 'value'
189
189
  end
190
190
  end
191
-
191
+
192
192
  def test_copy_should_return_the_instance_of_the_same_class_as_itself
193
193
  style = create_style
194
194
  assert_instance_of Style, style.copy
@@ -216,4 +216,4 @@ class ThinReports::Core::Shape::Style::TestBase < MiniTest::Unit::TestCase
216
216
 
217
217
  assert_equal style.identifier, style.styles.hash.to_s
218
218
  end
219
- end
219
+ end
@@ -1,13 +1,13 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
4
 
5
- class ThinReports::Core::Shape::Style::TestBasic < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
5
+ class Thinreports::Core::Shape::Style::TestBasic < Minitest::Test
6
+ include Thinreports::TestHelper
7
7
 
8
8
  def create_basic_style(format_config = {})
9
- format = ThinReports::Core::Shape::Basic::Format.new(format_config)
10
- ThinReports::Core::Shape::Style::Basic.new(format)
9
+ format = Thinreports::Core::Shape::Basic::Format.new(format_config)
10
+ Thinreports::Core::Shape::Style::Basic.new(format)
11
11
  end
12
12
 
13
13
  def test_visible_should_return_visibility_of_format_as_default
@@ -1,69 +1,55 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Core::Shape::Style::TestGraphic < Minitest::Test
6
+ include Thinreports::TestHelper
4
7
 
5
- class ThinReports::Core::Shape::Style::TestGraphic < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
8
  def create_graphic_style
9
- format = ThinReports::Core::Shape::Basic::Format.new({})
10
- ThinReports::Core::Shape::Style::Graphic.new(format)
9
+ format = Thinreports::Core::Shape::Basic::Format.new({})
10
+ Thinreports::Core::Shape::Style::Graphic.new(format)
11
11
  end
12
-
12
+
13
13
  def test_border_color_should_properly_set_to_internal_styles_as_stroke_style
14
14
  style = create_graphic_style
15
15
  style.border_color = '#ff0000'
16
-
16
+
17
17
  assert_equal style.styles['stroke'], '#ff0000'
18
18
  end
19
-
19
+
20
20
  def test_border_width_should_properly_set_to_internal_styles_as_stroke_width_style
21
21
  style = create_graphic_style
22
22
  style.border_width = 1
23
-
23
+
24
24
  assert_equal style.styles['stroke-width'], 1
25
25
  end
26
-
26
+
27
27
  def test_border_width_should_set_stroke_opacity_to_1_when_width_is_not_zero
28
28
  style = create_graphic_style
29
29
  style.border_width = 5
30
-
30
+
31
31
  assert_equal style.styles['stroke-opacity'], '1'
32
32
  end
33
-
33
+
34
34
  def test_fill_color_should_properly_set_to_internal_styles_as_fill_style
35
35
  style = create_graphic_style
36
36
  style.fill_color = '#0000ff'
37
-
37
+
38
38
  assert_equal style.styles['fill'], '#0000ff'
39
39
  end
40
-
41
- def test_fill_should_operate_like_the_fill_color_method
42
- style = create_graphic_style
43
- style.fill = '#ff0000'
44
-
45
- assert_same style.fill_color, style.fill
46
- end
47
-
48
- def test_stroke_should_operate_like_the_border_width_method
49
- style = create_graphic_style
50
- style.stroke = 5
51
-
52
- assert_same style.border_width, style.stroke
53
- end
54
-
40
+
55
41
  def test_border_should_return_an_Array_included_border_width_and_border_color
56
42
  style = create_graphic_style
57
43
  style.border_width = 1
58
44
  style.border_color = '#ff0000'
59
-
45
+
60
46
  assert_equal style.border, [style.border_width, style.border_color]
61
47
  end
62
-
48
+
63
49
  def test_border_should_properly_set_both_border_width_and_border_color_from_the_specified_array_argument
64
50
  style = create_graphic_style
65
51
  style.border = [5, '#000000']
66
-
52
+
67
53
  assert_equal style.border, [5, '#000000']
68
54
  end
69
- end
55
+ end
@@ -1,19 +1,30 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
4
 
5
- class ThinReports::Core::Shape::Style::TestText < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
5
+ class Thinreports::Core::Shape::Style::TestText < Minitest::Test
6
+ include Thinreports::TestHelper
7
7
 
8
8
  def create_format(format = {})
9
- ThinReports::Core::Shape::Text::Format.new(format)
9
+ Thinreports::Core::Shape::Text::Format.new(format)
10
10
  end
11
11
 
12
12
  def create_text_style(format = nil)
13
13
  format ||= create_format
14
- ThinReports::Core::Shape::Style::Text.new(format)
14
+ Thinreports::Core::Shape::Style::Text.new(format)
15
15
  end
16
-
16
+
17
+ def test_font_size
18
+ format = create_format('svg' => {'attrs' => {'font-size' => '12'}})
19
+ style = create_text_style(format)
20
+
21
+ assert_equal style.font_size, '12'
22
+
23
+ style.font_size = 19
24
+
25
+ assert_equal style.styles['font-size'], 19
26
+ end
27
+
17
28
  def test_bold_should_return_true_when_font_weight_property_of_format_is_bold
18
29
  format = create_format('svg' => {'attrs' => {'font-weight' => 'bold'}})
19
30
  style = create_text_style(format)
@@ -302,6 +313,17 @@ class ThinReports::Core::Shape::Style::TestText < MiniTest::Unit::TestCase
302
313
  create_text_style.valign = :unknonw
303
314
  end
304
315
  end
316
+
317
+ def test_initialize
318
+ klass = Class.new(Thinreports::Core::Shape::Style::Text)
319
+ klass.class_eval do
320
+ accessible_styles.delete(:valign)
321
+ end
322
+
323
+ style = klass.new(create_format('valign' => ''))
324
+ assert_equal style.valign, :top, 'should be set :top as default to @valign style ' +
325
+ 'if :valign is not accessible'
326
+ end
305
327
 
306
328
  def test_identifier_should_return_the_same_value_as_create_identifier_method_when_valign_has_not_been_changed
307
329
  style = create_text_style
@@ -315,4 +337,4 @@ class ThinReports::Core::Shape::Style::TestText < MiniTest::Unit::TestCase
315
337
  assert_equal style.identifier,
316
338
  style.send(:create_identifier, style.styles) + 'bottom'
317
339
  end
318
- end
340
+ end
@@ -1,9 +1,9 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
4
 
5
- class ThinReports::Core::Shape::Text::TestFormat < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
5
+ class Thinreports::Core::Shape::Text::TestFormat < Minitest::Test
6
+ include Thinreports::TestHelper
7
7
 
8
8
  TEST_TEXT_FORMAT = {
9
9
  "type" => "s-text",
@@ -44,14 +44,14 @@ class ThinReports::Core::Shape::Text::TestFormat < MiniTest::Unit::TestCase
44
44
  }
45
45
 
46
46
  # Alias
47
- Format = ThinReports::Core::Shape::Text::Format
47
+ Format = Thinreports::Core::Shape::Text::Format
48
48
 
49
49
  def test_build_format
50
50
  build_format
51
51
  rescue => e
52
52
  flunk exception_details(e, 'Building failed.')
53
53
  end
54
-
54
+
55
55
  def test_config_readers
56
56
  format = Format.new(TEST_TEXT_FORMAT)
57
57
 
@@ -70,4 +70,4 @@ class ThinReports::Core::Shape::Text::TestFormat < MiniTest::Unit::TestCase
70
70
  def build_format
71
71
  Format.build(TEST_TEXT_FORMAT)
72
72
  end
73
- end
73
+ end
@@ -1,21 +1,20 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
4
 
5
- class ThinReports::Core::Shape::Text::TestInternal < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
5
+ class Thinreports::Core::Shape::Text::TestInternal < Minitest::Test
6
+ include Thinreports::TestHelper
7
7
 
8
- Text = ThinReports::Core::Shape::Text
8
+ Text = Thinreports::Core::Shape::Text
9
9
 
10
- def setup
11
- format = flexmock('format')
12
- format.should_receive(:type => 's-text')
13
-
14
- @internal = Text::Internal.new(flexmock('parent'), format)
10
+ def create_internal(format_config = {})
11
+ report = new_report('layout_text1.tlf')
12
+ Text::Internal.new(report.start_new_page, Text::Format.new(format_config))
15
13
  end
16
14
 
17
15
  def test_type_of?
18
- assert_equal @internal.type_of?(:text), true
19
- assert_equal @internal.type_of?(:basic), false
16
+ assert create_internal.type_of?(:text), true
17
+ refute create_internal.type_of?(:basic), false
20
18
  end
21
- end
19
+
20
+ end