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,15 +1,15 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Core::Shape::TextBlock::TestInternal < Minitest::Test
6
+ include Thinreports::TestHelper
4
7
 
5
- class ThinReports::Core::Shape::TextBlock::TestInternal < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
8
  # Alias
9
- TextBlock = ThinReports::Core::Shape::TextBlock
10
-
9
+ TextBlock = Thinreports::Core::Shape::TextBlock
10
+
11
11
  def create_parent
12
- report = create_basic_report('basic_layout1.tlf')
12
+ report = new_report('layout_text1.tlf')
13
13
  report.start_new_page do |page|
14
14
  # Add to force TextBlock shape.
15
15
  page.manager.format.shapes[:foo] = TextBlock::Format.new('type' => 's-tblock',
@@ -18,111 +18,111 @@ class ThinReports::Core::Shape::TextBlock::TestInternal < MiniTest::Unit::TestCa
18
18
  page.item(:foo).value('foo value')
19
19
  end
20
20
  end
21
-
21
+
22
22
  def create_internal(format_config = {})
23
23
  TextBlock::Internal.new(create_parent, TextBlock::Format.new(format_config))
24
24
  end
25
-
25
+
26
26
  def test_multiple_asker_should_operate_as_delegator_of_format
27
27
  tblock = create_internal('multiple' => 'true')
28
28
  assert_equal tblock.multiple?, tblock.format.multiple?
29
29
  end
30
-
30
+
31
31
  def test_style_should_return_the_instance_of_Style_Text
32
- assert_instance_of ThinReports::Core::Shape::Style::Text, create_internal.style
32
+ assert_instance_of Thinreports::Core::Shape::Style::Text, create_internal.style
33
33
  end
34
-
34
+
35
35
  def test_read_value_should_return_the_format_value_as_default
36
36
  tblock = create_internal('value' => 'default value')
37
37
  assert_equal tblock.read_value, 'default value'
38
38
  end
39
-
39
+
40
40
  def test_read_value_should_return_the_value_of_referenced_shape
41
41
  tblock = create_internal('ref-id' => 'foo')
42
42
  assert_equal tblock.read_value, 'foo value'
43
43
  end
44
-
44
+
45
45
  def test_read_value_should_return_the_value_stored_in_states
46
46
  tblock = create_internal
47
47
  tblock.states[:value] = 'value in states'
48
-
48
+
49
49
  assert_equal tblock.read_value, 'value in states'
50
50
  end
51
-
51
+
52
52
  def test_write_value_should_properly_set_the_specified_value_to_states
53
53
  tblock = create_internal
54
54
  tblock.write_value(1000)
55
-
55
+
56
56
  assert_equal tblock.states[:value], 1000
57
57
  end
58
-
58
+
59
59
  def test_write_value_should_show_warnings_when_tblock_has_reference
60
60
  tblock = create_internal('id' => 'bar', 'ref-id' => 'foo')
61
61
  out, err = capture_io do
62
62
  tblock.write_value('value')
63
63
  end
64
64
  assert_equal err.chomp, 'The set value was not saved, ' +
65
- "Because 'bar' refers to 'foo'."
65
+ "Because 'bar' has reference to 'foo'."
66
66
  end
67
-
67
+
68
68
  def test_real_value_should_return_the_formatted_value_when_tblock_has_any_format
69
69
  tblock = create_internal('format' => {'type' => 'datetime',
70
70
  'datetime' => {'format' => '%Y/%m/%d'}})
71
71
  tblock.write_value(value = Time.now)
72
-
72
+
73
73
  assert_equal tblock.real_value, value.strftime('%Y/%m/%d')
74
74
  end
75
-
75
+
76
76
  def test_real_value_should_return_the_raw_value_when_tblock_has_no_format
77
77
  tblock = create_internal
78
78
  tblock.write_value('any value')
79
-
79
+
80
80
  assert_equal tblock.real_value, 'any value'
81
81
  end
82
-
82
+
83
83
  def test_format_enabled_should_properly_set_value_to_states_as_format_enabled
84
84
  tblock = create_internal
85
85
  tblock.format_enabled(false)
86
-
86
+
87
87
  assert_equal tblock.states[:format_enabled], false
88
88
  end
89
-
89
+
90
90
  def test_format_enabled_asker_should_return_true_when_format_has_any_type
91
91
  tblock = create_internal('format' => {'type' => 'datetime'})
92
-
92
+
93
93
  assert_equal tblock.format_enabled?, true
94
94
  end
95
-
95
+
96
96
  def test_format_enabled_asker_should_return_true_when_base_of_format_has_any_value
97
97
  tblock = create_internal('format' => {'base' => '{value}'})
98
-
98
+
99
99
  assert_equal tblock.format_enabled?, true
100
100
  end
101
-
101
+
102
102
  def test_format_enabled_asker_should_return_false_when_format_has_no_type_and_base_has_not_value
103
103
  assert_equal create_internal.format_enabled?, false
104
104
  end
105
-
105
+
106
106
  def test_format_enabled_asker_should_return_false_constantly_when_tblock_is_multiple_mode
107
- tblock = create_internal('multiple' => 'true',
107
+ tblock = create_internal('multiple' => 'true',
108
108
  'format' => {'base' => '{value}',
109
109
  'type' => 'number'})
110
110
  tblock.format_enabled(true)
111
-
111
+
112
112
  assert_equal tblock.format_enabled?, false
113
113
  end
114
-
114
+
115
115
  def test_type_of_asker_should_return_true_when_value_is_tblock
116
116
  assert_equal create_internal.type_of?(:tblock), true
117
117
  end
118
-
118
+
119
119
  def test_type_of_asker_should_return_true_when_value_is_block
120
120
  assert_equal create_internal.type_of?(:block), true
121
121
  end
122
-
122
+
123
123
  def test_formatter_should_return_instance_of_FormatterBasic_when_format_is_enable
124
124
  tblock = create_internal('format' => {'type' => 'datetime'})
125
-
125
+
126
126
  assert_kind_of TextBlock::Formatter::Basic, tblock.send(:formatter)
127
127
  end
128
- end
128
+ end
@@ -1,12 +1,12 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
4
 
5
- class ThinReports::Core::TestEvents < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
5
+ class Thinreports::Core::TestEvents < Minitest::Test
6
+ include Thinreports::TestHelper
7
7
 
8
8
  # Alias
9
- Events = ThinReports::Core::Events
9
+ Events = Thinreports::Core::Events
10
10
 
11
11
  def setup
12
12
  @events = Events.new(:load, :change, :blur)
@@ -33,7 +33,7 @@ class ThinReports::Core::TestEvents < MiniTest::Unit::TestCase
33
33
  end
34
34
 
35
35
  def test_listen_raise_error_when_unknown_event_type_is_set
36
- assert_raises ThinReports::Errors::UnknownEventType do
36
+ assert_raises Thinreports::Errors::UnknownEventType do
37
37
  @events.listen(:unknown) {|e| e.type }
38
38
  end
39
39
  end
@@ -77,12 +77,14 @@ class ThinReports::Core::TestEvents < MiniTest::Unit::TestCase
77
77
  end
78
78
 
79
79
  def test_copy
80
- @events.on(:change) {|e| e.type }
81
- @events.on(:load) {|e| e.type }
80
+ @events.on(:change) { :on_change }
81
+ @events.on(:load) { :on_load }
82
82
 
83
83
  copied = @events.copy
84
84
 
85
- assert_equal @events.events, copied.events
85
+ assert @events.events.all? {|k,f|
86
+ copied.events[k].call == f.call
87
+ }
86
88
  refute_same @events.events, copied.events
87
89
 
88
90
  @events.unlisten(:change)
@@ -1,13 +1,17 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
4
 
5
- class ThinReports::Core::TestShape < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
5
+ class Thinreports::Core::TestShape < Minitest::Test
6
+ include Thinreports::TestHelper
7
7
 
8
8
  # Alias
9
- ShapeModule = ThinReports::Core::Shape
9
+ ShapeModule = Thinreports::Core::Shape
10
10
 
11
+ def test_find_by_type_should_return_PageNumber
12
+ assert_same ShapeModule.find_by_type('s-pageno'), ShapeModule::PageNumber
13
+ end
14
+
11
15
  def test_find_by_type_should_return_ImageBlock
12
16
  assert_same ShapeModule.find_by_type('s-iblock'), ShapeModule::ImageBlock
13
17
  end
@@ -41,7 +45,7 @@ class ThinReports::Core::TestShape < MiniTest::Unit::TestCase
41
45
  end
42
46
 
43
47
  def test_find_by_type_should_raise
44
- assert_raises ThinReports::Errors::UnknownShapeType do
48
+ assert_raises Thinreports::Errors::UnknownShapeType do
45
49
  ShapeModule.find_by_type('unknown')
46
50
  end
47
51
  end
@@ -53,8 +57,8 @@ class ThinReports::Core::TestShape < MiniTest::Unit::TestCase
53
57
 
54
58
  def test_Configuration_should_raise
55
59
  # When shape don't have a Configuration
56
- assert_raises ThinReports::Errors::NoConfigurationFound do
60
+ assert_raises Thinreports::Errors::NoConfigurationFound do
57
61
  ShapeModule::Configuration('s-line')
58
62
  end
59
63
  end
60
- end
64
+ end
@@ -0,0 +1,68 @@
1
+ # coding: utf-8
2
+
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Core::TestShape < Minitest::Test
6
+ include Thinreports::TestHelper
7
+ include Thinreports::Utils
8
+
9
+ def test_call_block_in
10
+ expected = '123'
11
+ assert_same expected, call_block_in(expected)
12
+
13
+ assert_equal '321', call_block_in('123', &proc { reverse! })
14
+ assert_equal [1, 2, 3], call_block_in([2, 1, 3], &proc { |a| a.sort! })
15
+ end
16
+
17
+ def test_deep_copy_in_unsupported_object
18
+ [123, nil, Struct.new(:foo).new].each do |unsupported_value|
19
+ assert_raises ArgumentError do
20
+ deep_copy(unsupported_value)
21
+ end
22
+ end
23
+ end
24
+
25
+ def test_deep_copy_in_Array
26
+ src = ['string', Time.now]
27
+ dup = deep_copy(src)
28
+
29
+ refute_same dup, src
30
+
31
+ src.each_with_index do |e, i|
32
+ assert_equal dup[i], e
33
+ refute_same dup[i], e
34
+ end
35
+ end
36
+
37
+ def test_deep_copy_in_Hash
38
+ src = { a: 'string', b: Time.now }
39
+ dup = deep_copy(src)
40
+
41
+ refute_same dup, src
42
+
43
+ src.each do |k, v|
44
+ assert_equal dup[k], v
45
+ refute_same dup[k], v
46
+ end
47
+ end
48
+
49
+ def test_blank_value_in_String
50
+ ["", ''].each do |val|
51
+ assert_equal true, blank_value?(val)
52
+ end
53
+
54
+ [' ', ' ', 'abc', 'あいう'].each do |val|
55
+ assert_equal false, blank_value?(val)
56
+ end
57
+ end
58
+
59
+ def test_blank_value_in_NilClass
60
+ assert_equal true, blank_value?(nil)
61
+ end
62
+
63
+ def test_blank_value_in_other_classes
64
+ [0, 1, -1, 9.99, true, false, Time.now].each do |val|
65
+ assert_equal false, blank_value?(val)
66
+ end
67
+ end
68
+ end
@@ -1,12 +1,12 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
4
 
5
- class ThinReports::Generator::PDF::Graphics::TestAttributes < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
5
+ class Thinreports::Generator::PDF::Graphics::TestAttributes < Minitest::Test
6
+ include Thinreports::TestHelper
7
7
 
8
8
  def setup
9
- @pdf = ThinReports::Generator::PDF::Document.new
9
+ @pdf = Thinreports::Generator::PDF::Document.new
10
10
  end
11
11
 
12
12
  def test_common_graphic_attrs_should_return_converted_Hash_as_attributes
@@ -56,6 +56,12 @@ class ThinReports::Generator::PDF::Graphics::TestAttributes < MiniTest::Unit::Te
56
56
  assert_equal valigns.map {|a| @pdf.text_valign(a) },
57
57
  [:top, :center, :bottom, :top]
58
58
  end
59
+
60
+ def test_text_word_wrap
61
+ assert_equal @pdf.text_word_wrap('break-word'), :break_word
62
+ assert_equal @pdf.text_word_wrap('none'), :none
63
+ assert_equal @pdf.text_word_wrap(''), :none
64
+ end
59
65
 
60
66
  def test_extract_base64_string
61
67
  base64 = 'data:image/png;base64,iVBORw0KGg1+/AAy/plYlzil'
@@ -1,164 +1,171 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Generator::PDF::Graphics::TestText < Minitest::Test
6
+ include Thinreports::TestHelper
4
7
 
5
- class ThinReports::Generator::PDF::Graphics::TestText < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
8
  def setup
9
- @pdf = ThinReports::Generator::PDF::Document.new
9
+ @pdf = Thinreports::Generator::PDF::Document.new
10
10
  @pdf.internal.start_new_page
11
11
  end
12
-
12
+
13
13
  def exec_with_font_styles(attrs = nil, font = nil, &block)
14
- attrs ||= {:styles => [:bold]}
15
- font ||= {:name => 'IPAMincho', :size => 18, :color => 'ff0000'}
16
-
14
+ attrs ||= {styles: [:bold]}
15
+ font ||= {name: 'IPAMincho', size: 18, color: 'ff0000'}
16
+
17
17
  @pdf.send(:with_font_styles, attrs, font, &block)
18
18
  end
19
-
19
+
20
20
  def exec_with_text_styles(attrs = {}, &block)
21
- default_attrs = {:font => 'Helvetica',
22
- :color => 'ff0000',
23
- :size => 18}
21
+ default_attrs = {font: 'Helvetica',
22
+ color: 'ff0000',
23
+ size: 18}
24
24
  @pdf.send(:with_text_styles, default_attrs.merge(attrs), &block)
25
25
  end
26
-
26
+
27
27
  def test_with_text_styles_should_not_operate_when_color_is_none
28
- exec_with_text_styles(:color => 'none') do |attrs, styles|
28
+ exec_with_text_styles(color: 'none') do |attrs, styles|
29
29
  flunk
30
30
  end
31
31
  end
32
-
32
+
33
33
  def test_with_text_styles_should_set_leading_via_line_height_attribute
34
- exec_with_text_styles(:line_height => 30) do |attrs, styles|
34
+ exec_with_text_styles(line_height: 30) do |attrs, styles|
35
35
  expected = @pdf.send(:text_line_leading,
36
36
  @pdf.send(:s2f, 30),
37
- :name => 'Helvetica', :size => 18)
37
+ name: 'Helvetica', size: 18)
38
38
  assert_equal attrs[:leading], expected
39
39
  end
40
40
  end
41
-
41
+
42
42
  def test_with_text_styles_should_not_set_leading_when_line_height_is_not_specified
43
43
  exec_with_text_styles do |attrs, styles|
44
44
  refute_includes attrs.keys, :leading
45
45
  end
46
46
  end
47
-
47
+
48
48
  def test_with_text_styles_should_set_character_spacing_via_letter_spacing_attribute
49
- exec_with_text_styles(:letter_spacing => 5) do |attrs, styles|
49
+ exec_with_text_styles(letter_spacing: 5) do |attrs, styles|
50
50
  assert_equal attrs[:character_spacing], @pdf.send(:s2f, 5)
51
51
  end
52
52
  end
53
-
53
+
54
54
  def test_with_text_styles_should_not_set_character_spacing_when_letter_spacing_is_not_specified
55
55
  exec_with_text_styles do |attrs, styles|
56
56
  refute_includes attrs.keys, :character_spacing
57
57
  end
58
58
  end
59
-
59
+
60
60
  def test_with_text_styles_should_parse_color
61
- exec_with_text_styles(:color => '#ff0000') do |attrs, styles|
61
+ exec_with_text_styles(color: '#ff0000') do |attrs, styles|
62
62
  assert_equal @pdf.internal.fill_color, 'ff0000'
63
63
  end
64
64
  end
65
-
65
+
66
66
  def test_with_font_styles_should_set_fill_color_using_color_of_font
67
67
  exec_with_font_styles do |attrs, styles|
68
68
  assert_equal @pdf.internal.fill_color, 'ff0000'
69
69
  end
70
70
  end
71
-
71
+
72
72
  def test_with_font_styles_should_perform_manual_style_when_bold_style_cannot_be_applied
73
73
  exec_with_font_styles do |attrs, styles|
74
74
  assert_empty styles
75
75
  end
76
76
  end
77
-
77
+
78
78
  def test_with_font_styles_should_perform_manual_style_when_italic_style_cannot_be_applied
79
79
  exec_with_font_styles do |attrs, styles|
80
80
  assert_empty styles
81
81
  end
82
82
  end
83
-
83
+
84
84
  def test_with_font_styles_should_set_stroke_color_using_color_of_font_when_bold_style_cannot_be_applied
85
85
  exec_with_font_styles do |attrs, styles|
86
86
  assert_equal @pdf.internal.stroke_color, 'ff0000'
87
87
  end
88
88
  end
89
-
89
+
90
90
  def test_with_font_styles_should_set_line_width_calculated_from_font_size_when_bold_style_cannot_be_applied
91
91
  exec_with_font_styles do |attrs, styles|
92
92
  assert_equal @pdf.internal.line_width, 18 * 0.025
93
93
  end
94
94
  end
95
-
95
+
96
96
  def test_with_font_styles_should_set_mode_to_fill_stroke_when_bold_style_cannot_be_applied
97
97
  exec_with_font_styles do |attrs, styles|
98
98
  assert_equal attrs[:mode], :fill_stroke
99
99
  end
100
100
  end
101
-
101
+
102
102
  def test_with_font_styles_should_not_perform_a_manual_style_when_bold_style_can_be_applied
103
- exec_with_font_styles(nil, :name => 'Helvetica', :size => 12, :color => '0000ff') do |attrs, styles|
103
+ exec_with_font_styles(nil, name: 'Helvetica', size: 12, color: '0000ff') do |attrs, styles|
104
104
  assert_includes styles, :bold
105
105
  end
106
106
  end
107
-
107
+
108
108
  def test_with_font_styles_should_not_perform_a_manual_style_when_italic_style_can_be_applied
109
- exec_with_font_styles({:styles => [:italic]}, :name => 'Helvetica', :size => 12, :color => 'ff0000') do |attrs, styles|
109
+ exec_with_font_styles({styles: [:italic]}, name: 'Helvetica', size: 12, color: 'ff0000') do |attrs, styles|
110
110
  assert_includes styles, :italic
111
111
  end
112
112
  end
113
-
113
+
114
114
  def test_text_line_leading_should_return_a_specified_leading_value_minus_the_font_height
115
- font = {:name => 'IPAMincho', :size => 36}
116
- font_height = @pdf.internal.font(font[:name], :size => font[:size]).height
117
-
115
+ font = {name: 'IPAMincho', size: 36}
116
+ font_height = @pdf.internal.font(font[:name], size: font[:size]).height
117
+
118
118
  assert_equal @pdf.send(:text_line_leading, 100, font), 100 - font_height
119
119
  end
120
-
120
+
121
121
  def test_text_without_line_wrap_should_replace_the_spaces_NBSP
122
122
  assert_equal @pdf.send(:text_without_line_wrap, ' ' * 2), Prawn::Text::NBSP * 2
123
123
  end
124
-
124
+
125
125
  def test_text_box_should_not_raise_PrawnCannotFitError
126
- @pdf.text_box('foo', 0, 0, 1, 1, :font => 'IPAMincho',
127
- :size => 100,
128
- :color => '000000')
126
+ @pdf.text_box('foo', 0, 0, 1, 1, font: 'IPAMincho',
127
+ size: 100,
128
+ color: '000000')
129
129
  rescue Prawn::Errors::CannotFit
130
130
  flunk('Raise Prawn::Errors::CannotFit.')
131
131
  end
132
-
132
+
133
133
  def test_text_box_attrs_should_return_a_Hash_containing_a_at_and_width_options
134
134
  attrs = @pdf.send(:text_box_attrs, 0, 0, 50, 100)
135
-
135
+
136
136
  assert_equal attrs.values_at(:at, :width),
137
137
  [@pdf.send(:pos, 0, 0), @pdf.send(:s2f, 50)]
138
138
  end
139
-
139
+
140
140
  def test_text_box_attrs_should_return_a_Hash_which_doesnt_contain_the_single_line_option_when_single_is_true_but_overflow_is_expand
141
- attrs = @pdf.send(:text_box_attrs, 0, 0, 100, 100, :single => true, :overflow => :expand)
141
+ attrs = @pdf.send(:text_box_attrs, 0, 0, 100, 100, single: true, overflow: :expand)
142
142
  refute attrs.key?(:single_line)
143
143
  end
144
-
144
+
145
145
  def test_text_box_attrs_should_return_a_Hash_containing_a_single_line_option_when_single_is_true_and_overflow_isnot_expand
146
- attrs = @pdf.send(:text_box_attrs, 0, 0, 100, 100, :single => true, :overflow => :truncate)
146
+ attrs = @pdf.send(:text_box_attrs, 0, 0, 100, 100, single: true, overflow: :truncate)
147
147
  assert_equal attrs[:single_line], true
148
148
  end
149
-
149
+
150
150
  def test_text_box_attrs_should_return_a_Hash_which_does_not_contain_a_height_option_when_single_is_true
151
- attrs = @pdf.send(:text_box_attrs, 0, 0, 100, 100, :single => true)
151
+ attrs = @pdf.send(:text_box_attrs, 0, 0, 100, 100, single: true)
152
152
  refute attrs.key?(:height)
153
153
  end
154
-
154
+
155
155
  def test_text_box_attrs_should_return_a_Hash_which_does_not_contain_a_single_line_option_when_single_is_not_specified
156
156
  attrs = @pdf.send(:text_box_attrs, 0, 0, 100, 100)
157
157
  refute attrs.key?(:single_line)
158
158
  end
159
-
159
+
160
160
  def test_text_box_attrs_should_return_a_Hash_containing_a_height_optin_when_single_is_not_specified
161
161
  attrs = @pdf.send(:text_box_attrs, 0, 0, 100, 200)
162
162
  assert_equal attrs[:height], 200
163
163
  end
164
+
165
+ def test_text
166
+ @pdf.expects(:text_box).
167
+ with('contents', 100, 200, 150, 250, { overflow: :shirink_to_fit }).once
168
+
169
+ @pdf.text('contents', 100, 200, 150, 250)
170
+ end
164
171
  end
@@ -1,17 +1,20 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
4
 
5
- class ThinReports::Generator::PDF::TestDrawShape < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
5
+ class Thinreports::Generator::PDF::TestDrawShape < Minitest::Test
6
+ include Thinreports::TestHelper
7
7
 
8
8
  def setup
9
- @pdf = ThinReports::Generator::PDF::Document.new
9
+ @pdf = Thinreports::Generator::PDF::Document.new
10
10
  end
11
11
 
12
12
  def create_tblock_interface(format_config = {})
13
- format = ThinReports::Core::Shape::TextBlock::Format.new(format_config)
14
- ThinReports::Core::Shape::TextBlock::Interface.new(flexmock('parent'), format)
13
+ report = new_report 'layout_text1'
14
+ parent = report.start_new_page
15
+
16
+ format = Thinreports::Core::Shape::TextBlock::Format.new format_config
17
+ Thinreports::Core::Shape::TextBlock::Interface.new parent, format
15
18
  end
16
19
 
17
20
  def test_shape_text_attrs_should_return_attrs_containing_an_overflow_property
@@ -33,4 +36,9 @@ class ThinReports::Generator::PDF::TestDrawShape < MiniTest::Unit::TestCase
33
36
  tblock = create_tblock_interface('id' => 'text', 'line-height' => '')
34
37
  assert_nil @pdf.send(:shape_text_attrs, tblock.internal)[:line_height]
35
38
  end
39
+
40
+ def test_shape_text_attrs
41
+ tblock = create_tblock_interface('id' => 'text', 'word-wrap' => 'none')
42
+ assert_includes @pdf.send(:shape_text_attrs, tblock.internal).keys, :word_wrap
43
+ end
36
44
  end