thinreports 0.7.7 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (280) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -6
  3. data/.travis.yml +4 -10
  4. data/CHANGELOG.md +220 -0
  5. data/Gemfile +3 -3
  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/{test/case → examples}/dynamic_image/img200x100.png +0 -0
  14. data/{test/case → examples}/dynamic_image/img50x50.png +0 -0
  15. data/examples/dynamic_style/dynamic_style.rb +150 -0
  16. data/examples/dynamic_style/dynamic_style.tlf +1 -0
  17. data/examples/dynamic_style/dynamic_style_in_list.tlf +1 -0
  18. data/{test/case → examples}/dynamic_style/image.png +0 -0
  19. data/examples/eudc/eudc.rb +20 -0
  20. data/examples/eudc/eudc.tlf +1 -0
  21. data/{test/case → examples}/eudc/eudc.ttf +0 -0
  22. data/{test/case → examples}/helper.rb +14 -12
  23. data/examples/hidden_shapes/hidden_shapes.rb +9 -0
  24. data/examples/hidden_shapes/hidden_shapes.tlf +1 -0
  25. data/examples/list_events/list_events.rb +59 -0
  26. data/examples/list_events/list_events_0_7_7.tlf +1 -0
  27. data/examples/list_events/list_events_0_8.tlf +1 -0
  28. data/{test/case → examples}/list_manual_generation/list_manual_generation.rb +4 -4
  29. data/examples/list_manual_generation/list_manual_generation.tlf +1 -0
  30. data/{test/case → examples}/list_page_number/list_page_number.rb +3 -3
  31. data/examples/list_page_number/list_page_number.tlf +1 -0
  32. data/examples/page_number/page_number.rb +33 -0
  33. data/examples/page_number/page_number.tlf +1 -0
  34. data/examples/password_setting/password_setting.rb +10 -0
  35. data/examples/password_setting/password_setting.tlf +1 -0
  36. data/examples/report_callbacks/report_callbacks.rb +31 -0
  37. data/examples/report_callbacks/report_callbacks.tlf +1 -0
  38. data/{test/case → examples}/single_line_tblock/single_line_tblock.rb +2 -2
  39. data/examples/single_line_tblock/single_line_tblock.tlf +1 -0
  40. data/examples/tblock_overflow/tblock_overflow.rb +20 -0
  41. data/examples/tblock_overflow/tblock_overflow.tlf +1 -0
  42. data/examples/tblock_styles/font_size.tlf +1 -0
  43. data/examples/tblock_styles/tblock_styles.rb +43 -0
  44. data/examples/tblock_styles/tblock_styles.tlf +1 -0
  45. data/examples/text_align/text_align.rb +8 -0
  46. data/examples/text_align/text_align.tlf +1 -0
  47. data/examples/typeB_page_size/B4_ISO.tlf +1 -0
  48. data/examples/typeB_page_size/B4_JIS.tlf +1 -0
  49. data/{test/case → examples}/typeB_page_size/typeB_page_size.rb +3 -3
  50. data/examples/word_wrap/word_wrap.rb +26 -0
  51. data/examples/word_wrap/word_wrap.tlf +1 -0
  52. data/{resources/fonts → fonts}/IPA_Font_License_Agreement_v1.0.txt +0 -0
  53. data/{resources/fonts → fonts}/ipag.ttf +0 -0
  54. data/{resources/fonts → fonts}/ipagp.ttf +0 -0
  55. data/{resources/fonts → fonts}/ipam.ttf +0 -0
  56. data/{resources/fonts → fonts}/ipamp.ttf +0 -0
  57. data/lib/thinreports.rb +14 -2
  58. data/lib/thinreports/config.rb +30 -10
  59. data/lib/thinreports/core/errors.rb +23 -20
  60. data/lib/thinreports/core/events.rb +18 -19
  61. data/lib/thinreports/core/format/base.rb +20 -20
  62. data/lib/thinreports/core/format/builder.rb +14 -22
  63. data/lib/thinreports/core/shape.rb +9 -13
  64. data/lib/thinreports/core/shape/base.rb +4 -5
  65. data/lib/thinreports/core/shape/base/interface.rb +15 -15
  66. data/lib/thinreports/core/shape/base/internal.rb +15 -20
  67. data/lib/thinreports/core/shape/basic.rb +1 -1
  68. data/lib/thinreports/core/shape/basic/block_format.rb +3 -4
  69. data/lib/thinreports/core/shape/basic/block_interface.rb +9 -4
  70. data/lib/thinreports/core/shape/basic/block_internal.rb +9 -10
  71. data/lib/thinreports/core/shape/basic/format.rb +11 -10
  72. data/lib/thinreports/core/shape/basic/interface.rb +3 -3
  73. data/lib/thinreports/core/shape/basic/internal.rb +4 -5
  74. data/lib/thinreports/core/shape/image_block.rb +1 -1
  75. data/lib/thinreports/core/shape/image_block/format.rb +5 -6
  76. data/lib/thinreports/core/shape/image_block/interface.rb +9 -7
  77. data/lib/thinreports/core/shape/image_block/internal.rb +5 -6
  78. data/lib/thinreports/core/shape/list.rb +1 -1
  79. data/lib/thinreports/core/shape/list/configuration.rb +30 -15
  80. data/lib/thinreports/core/shape/list/events.rb +11 -11
  81. data/lib/thinreports/core/shape/list/format.rb +27 -28
  82. data/lib/thinreports/core/shape/list/manager.rb +128 -95
  83. data/lib/thinreports/core/shape/list/page.rb +54 -50
  84. data/lib/thinreports/core/shape/list/page_state.rb +15 -16
  85. data/lib/thinreports/core/shape/list/section_format.rb +14 -15
  86. data/lib/thinreports/core/shape/list/section_interface.rb +15 -16
  87. data/lib/thinreports/core/shape/list/section_internal.rb +7 -8
  88. data/lib/thinreports/core/shape/list/store.rb +10 -11
  89. data/lib/thinreports/core/shape/manager.rb +1 -1
  90. data/lib/thinreports/core/shape/manager/format.rb +10 -11
  91. data/lib/thinreports/core/shape/manager/internal.rb +21 -20
  92. data/lib/thinreports/core/shape/manager/target.rb +63 -34
  93. data/lib/thinreports/core/shape/page_number.rb +1 -1
  94. data/lib/thinreports/core/shape/page_number/format.rb +3 -3
  95. data/lib/thinreports/core/shape/page_number/interface.rb +2 -2
  96. data/lib/thinreports/core/shape/page_number/internal.rb +3 -3
  97. data/lib/thinreports/core/shape/style.rb +1 -1
  98. data/lib/thinreports/core/shape/style/base.rb +29 -29
  99. data/lib/thinreports/core/shape/style/basic.rb +1 -1
  100. data/lib/thinreports/core/shape/style/graphic.rb +10 -25
  101. data/lib/thinreports/core/shape/style/text.rb +36 -30
  102. data/lib/thinreports/core/shape/text.rb +1 -1
  103. data/lib/thinreports/core/shape/text/format.rb +8 -9
  104. data/lib/thinreports/core/shape/text/interface.rb +2 -2
  105. data/lib/thinreports/core/shape/text/internal.rb +6 -7
  106. data/lib/thinreports/core/shape/text_block.rb +1 -1
  107. data/lib/thinreports/core/shape/text_block/format.rb +17 -18
  108. data/lib/thinreports/core/shape/text_block/formatter.rb +7 -8
  109. data/lib/thinreports/core/shape/text_block/formatter/basic.rb +13 -12
  110. data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +8 -9
  111. data/lib/thinreports/core/shape/text_block/formatter/number.rb +11 -12
  112. data/lib/thinreports/core/shape/text_block/formatter/padding.rb +9 -32
  113. data/lib/thinreports/core/shape/text_block/interface.rb +2 -2
  114. data/lib/thinreports/core/shape/text_block/internal.rb +19 -20
  115. data/lib/thinreports/core/utils.rb +33 -32
  116. data/lib/thinreports/generator.rb +6 -8
  117. data/lib/thinreports/generator/base.rb +15 -24
  118. data/lib/thinreports/generator/configuration.rb +10 -9
  119. data/lib/thinreports/generator/pdf.rb +27 -30
  120. data/lib/thinreports/generator/pdf/configuration.rb +11 -6
  121. data/lib/thinreports/generator/pdf/document.rb +28 -28
  122. data/lib/thinreports/generator/pdf/document/draw_shape.rb +30 -31
  123. data/lib/thinreports/generator/pdf/document/font.rb +53 -44
  124. data/lib/thinreports/generator/pdf/document/graphics.rb +8 -9
  125. data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +25 -25
  126. data/lib/thinreports/generator/pdf/document/graphics/basic.rb +25 -25
  127. data/lib/thinreports/generator/pdf/document/graphics/image.rb +15 -15
  128. data/lib/thinreports/generator/pdf/document/graphics/text.rb +40 -41
  129. data/lib/thinreports/generator/pdf/document/page.rb +20 -21
  130. data/lib/thinreports/generator/pdf/document/parse_color.rb +9 -10
  131. data/lib/thinreports/generator/pdf/document/parse_svg.rb +14 -15
  132. data/lib/thinreports/generator/pdf/drawer/base.rb +13 -14
  133. data/lib/thinreports/generator/pdf/drawer/list.rb +13 -14
  134. data/lib/thinreports/generator/pdf/drawer/list_section.rb +13 -14
  135. data/lib/thinreports/generator/pdf/drawer/page.rb +16 -17
  136. data/lib/thinreports/generator/pdf/prawn_ext.rb +17 -33
  137. data/lib/thinreports/layout.rb +2 -2
  138. data/lib/thinreports/layout/base.rb +22 -36
  139. data/lib/thinreports/layout/configuration.rb +11 -9
  140. data/lib/thinreports/layout/format.rb +26 -27
  141. data/lib/thinreports/layout/version.rb +8 -9
  142. data/lib/thinreports/report.rb +10 -14
  143. data/lib/thinreports/report/base.rb +104 -126
  144. data/lib/thinreports/report/events.rb +5 -5
  145. data/lib/thinreports/report/internal.rb +41 -33
  146. data/lib/thinreports/{core → report}/page.rb +38 -30
  147. data/lib/thinreports/version.rb +2 -3
  148. data/test/data/font.ttf +0 -0
  149. data/test/data/layout_block.tlf +1 -0
  150. data/test/data/layout_list.tlf +1 -0
  151. data/test/data/layout_list_noheader.tlf +1 -0
  152. data/test/data/layout_text1.tlf +1 -0
  153. data/test/data/layout_text2.tlf +1 -0
  154. data/test/test_helper.rb +74 -0
  155. data/test/{unit/tmp → tmp}/.gitkeep +0 -0
  156. data/test/unit/core/format/test_base.rb +14 -14
  157. data/test/unit/core/format/test_builder.rb +19 -23
  158. data/test/unit/core/shape/base/test_internal.rb +34 -37
  159. data/test/unit/core/shape/basic/test_basic_format.rb +4 -4
  160. data/test/unit/core/shape/basic/test_basic_interface.rb +15 -13
  161. data/test/unit/core/shape/basic/test_basic_internal.rb +19 -16
  162. data/test/unit/core/shape/basic/test_format.rb +4 -4
  163. data/test/unit/core/shape/basic/test_interface.rb +36 -46
  164. data/test/unit/core/shape/basic/test_internal.rb +23 -20
  165. data/test/unit/core/shape/image_block/test_format.rb +5 -5
  166. data/test/unit/core/shape/image_block/test_interface.rb +17 -16
  167. data/test/unit/core/shape/image_block/test_internal.rb +19 -16
  168. data/test/unit/core/shape/list/test_configuration.rb +45 -33
  169. data/test/unit/core/shape/list/test_events.rb +7 -7
  170. data/test/unit/core/shape/list/test_format.rb +16 -18
  171. data/test/unit/core/shape/list/test_manager.rb +5 -5
  172. data/test/unit/core/shape/list/test_page.rb +80 -22
  173. data/test/unit/core/shape/list/test_page_state.rb +12 -12
  174. data/test/unit/core/shape/list/test_section_format.rb +16 -17
  175. data/test/unit/core/shape/list/test_section_interface.rb +30 -22
  176. data/test/unit/core/shape/list/test_section_internal.rb +21 -19
  177. data/test/unit/core/shape/list/test_store.rb +7 -7
  178. data/test/unit/core/shape/manager/test_format.rb +11 -15
  179. data/test/unit/core/shape/manager/test_internal.rb +9 -9
  180. data/test/unit/core/shape/manager/test_target.rb +85 -57
  181. data/test/unit/core/shape/page_number/test_format.rb +4 -4
  182. data/test/unit/core/shape/page_number/test_interface.rb +11 -8
  183. data/test/unit/core/shape/page_number/test_internal.rb +5 -5
  184. data/test/unit/core/shape/styles/test_base.rb +9 -9
  185. data/test/unit/core/shape/styles/test_basic.rb +5 -5
  186. data/test/unit/core/shape/styles/test_graphic.rb +19 -33
  187. data/test/unit/core/shape/styles/test_text.rb +18 -7
  188. data/test/unit/core/shape/text/test_format.rb +6 -6
  189. data/test/unit/core/shape/text/test_internal.rb +11 -12
  190. data/test/unit/core/shape/text_block/formatter/test_basic.rb +16 -16
  191. data/test/unit/core/shape/text_block/formatter/test_datetime.rb +4 -4
  192. data/test/unit/core/shape/text_block/formatter/test_number.rb +34 -34
  193. data/test/unit/core/shape/text_block/formatter/test_padding.rb +44 -44
  194. data/test/unit/core/shape/text_block/test_format.rb +8 -8
  195. data/test/unit/core/shape/text_block/test_formatter.rb +17 -17
  196. data/test/unit/core/shape/text_block/test_interface.rb +37 -20
  197. data/test/unit/core/shape/text_block/test_internal.rb +38 -38
  198. data/test/unit/core/test_events.rb +5 -5
  199. data/test/unit/core/test_shape.rb +6 -6
  200. data/test/unit/core/test_utils.rb +68 -0
  201. data/test/unit/generator/pdf/document/graphics/test_attributes.rb +4 -4
  202. data/test/unit/generator/pdf/document/graphics/test_text.rb +60 -53
  203. data/test/unit/generator/pdf/document/test_draw_shape.rb +9 -7
  204. data/test/unit/generator/pdf/document/test_font.rb +79 -58
  205. data/test/unit/generator/pdf/document/test_graphics.rb +18 -19
  206. data/test/unit/generator/pdf/document/test_page.rb +44 -45
  207. data/test/unit/generator/pdf/document/test_parse_color.rb +5 -5
  208. data/test/unit/generator/pdf/test_configuration.rb +16 -9
  209. data/test/unit/generator/pdf/test_document.rb +8 -16
  210. data/test/unit/generator/test_base.rb +31 -42
  211. data/test/unit/generator/test_configuration.rb +6 -6
  212. data/test/unit/generator/test_pdf.rb +17 -14
  213. data/test/unit/layout/test_base.rb +34 -79
  214. data/test/unit/layout/test_configuration.rb +12 -37
  215. data/test/unit/layout/test_format.rb +36 -39
  216. data/test/unit/layout/test_version.rb +4 -4
  217. data/test/unit/report/test_base.rb +134 -213
  218. data/test/unit/report/test_events.rb +4 -4
  219. data/test/unit/report/test_internal.rb +84 -86
  220. data/test/unit/test_config.rb +31 -12
  221. data/test/unit/test_layout.rb +7 -7
  222. data/test/unit/test_report.rb +12 -24
  223. data/thinreports.gemspec +18 -22
  224. metadata +101 -200
  225. data/LICENSE +0 -1
  226. data/README.rdoc +0 -166
  227. data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
  228. data/lib/thinreports/core.rb +0 -20
  229. data/lib/thinreports/core/ext.rb +0 -5
  230. data/lib/thinreports/core/ext/array.rb +0 -19
  231. data/lib/thinreports/core/ext/hash.rb +0 -19
  232. data/lib/thinreports/core/ext/object.rb +0 -25
  233. data/lib/thinreports/core/format.rb +0 -14
  234. data/lib/thinreports/core/ordered_hash.rb +0 -39
  235. data/lib/thinreports/generator/pdf/drawer.rb +0 -16
  236. data/tasks/doc.rake +0 -12
  237. data/tasks/test.rake +0 -56
  238. data/test/benchmark/basic_estimate.tlf +0 -1
  239. data/test/benchmark/bench_basic_estimate.rb +0 -95
  240. data/test/case/character_spacing/character_spacing.rb +0 -8
  241. data/test/case/character_spacing/character_spacing.tlf +0 -1
  242. data/test/case/dynamic_image/dynamic_image.rb +0 -41
  243. data/test/case/dynamic_image/dynamic_image.tlf +0 -1
  244. data/test/case/dynamic_style/dynamic_style.rb +0 -154
  245. data/test/case/dynamic_style/dynamic_style.tlf +0 -1
  246. data/test/case/dynamic_style/dynamic_style_in_list.tlf +0 -1
  247. data/test/case/eudc/eudc.rb +0 -20
  248. data/test/case/eudc/eudc.tlf +0 -1
  249. data/test/case/hidden_shapes/hidden_shapes.rb +0 -9
  250. data/test/case/hidden_shapes/hidden_shapes.tlf +0 -1
  251. data/test/case/list_events/list_events.rb +0 -32
  252. data/test/case/list_events/list_events.tlf +0 -1
  253. data/test/case/list_manual_generation/list_manual_generation.tlf +0 -1
  254. data/test/case/list_page_number/list_page_number.tlf +0 -1
  255. data/test/case/page_number/page_number.rb +0 -33
  256. data/test/case/page_number/page_number.tlf +0 -1
  257. data/test/case/password_setting/password_setting.rb +0 -10
  258. data/test/case/password_setting/password_setting.tlf +0 -1
  259. data/test/case/single_line_tblock/single_line_tblock.tlf +0 -1
  260. data/test/case/tblock_overflow/tblock_overflow.rb +0 -20
  261. data/test/case/tblock_overflow/tblock_overflow.tlf +0 -1
  262. data/test/case/tblock_styles/tblock_styles.rb +0 -27
  263. data/test/case/tblock_styles/tblock_styles.tlf +0 -1
  264. data/test/case/text_align/text_align.rb +0 -8
  265. data/test/case/text_align/text_align.tlf +0 -1
  266. data/test/case/typeB_page_size/B4_ISO.tlf +0 -1
  267. data/test/case/typeB_page_size/B4_JIS.tlf +0 -1
  268. data/test/case/word_wrap/word_wrap.rb +0 -26
  269. data/test/case/word_wrap/word_wrap.tlf +0 -1
  270. data/test/unit/core/ext/array_spec.rb +0 -29
  271. data/test/unit/core/ext/hash_spec.rb +0 -29
  272. data/test/unit/core/ext/object_spec.rb +0 -30
  273. data/test/unit/core/ordered_hash_spec.rb +0 -51
  274. data/test/unit/core/shape/base/test_interface.rb +0 -52
  275. data/test/unit/core/utils_spec.rb +0 -56
  276. data/test/unit/data/basic_layout1.tlf +0 -1
  277. data/test/unit/data/basic_layout2.tlf +0 -1
  278. data/test/unit/data/basic_list_layout.tlf +0 -1
  279. data/test/unit/data/basic_list_noheader_layout.tlf +0 -1
  280. data/test/unit/helper.rb +0 -87
@@ -1,43 +1,42 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Generator::PDF::TestGraphics < Minitest::Test
6
+ include Thinreports::TestHelper
4
7
 
5
- class ThinReports::Generator::PDF::TestGraphics < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
8
  class TestGraphics
9
9
  attr_accessor :pdf
10
- include ThinReports::Generator::PDF::Graphics
10
+ include Thinreports::Generator::PDF::Graphics
11
11
  end
12
-
12
+
13
13
  def setup
14
- @g = TestGraphics.new
15
- @g.pdf = flexmock('pdf')
14
+ @g = TestGraphics.new
15
+ @g.pdf = mock('pdf')
16
16
  end
17
-
17
+
18
18
  def test_setup_custom_graphic_states
19
- @g.pdf.
20
- should_receive(:line_width).
19
+ @g.pdf.expects(:line_width).
21
20
  with(TestGraphics::BASE_LINE_WIDTH).once
22
-
21
+
23
22
  @g.send(:setup_custom_graphic_states)
24
23
  end
25
-
24
+
26
25
  def test_line_width
27
26
  @g.pdf.
28
- should_receive(:line_width).
27
+ expects(:line_width).
29
28
  with(10 * TestGraphics::BASE_LINE_WIDTH).once
30
-
29
+
31
30
  @g.send(:line_width, 10)
32
31
  end
33
-
32
+
34
33
  def test_save_graphics_state
35
- @g.pdf.should_receive(:save_graphics_state).once
34
+ @g.pdf.expects(:save_graphics_state).once
36
35
  @g.send(:save_graphics_state)
37
36
  end
38
-
37
+
39
38
  def test_restore_graphics_state
40
- @g.pdf.should_receive(:restore_graphics_state).once
39
+ @g.pdf.expects(:restore_graphics_state).once
41
40
  @g.send(:restore_graphics_state)
42
41
  end
43
42
  end
@@ -1,16 +1,16 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Generator::PDF::Document::TestPage < Minitest::Test
6
+ include Thinreports::TestHelper
4
7
 
5
- class ThinReports::Generator::PDF::Document::TestPage < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
8
  def create_pdf
9
- @pdf = ThinReports::Generator::PDF::Document.new
9
+ @pdf = Thinreports::Generator::PDF::Document.new
10
10
  end
11
11
 
12
12
  def test_page_geometry
13
- page_geometry = Prawn::Document::PageGeometry::SIZES
13
+ page_geometry = ::PDF::Core::PageGeometry::SIZES
14
14
  assert_equal page_geometry['B4_JIS'], [728.5, 1031.8]
15
15
  assert_equal page_geometry['B5_JIS'], [515.9, 728.5]
16
16
  end
@@ -18,8 +18,8 @@ class ThinReports::Generator::PDF::Document::TestPage < MiniTest::Unit::TestCase
18
18
  def test_B4_paper_size_should_be_converted_to_B4_JIS
19
19
  create_pdf
20
20
 
21
- format = create_basic_layout_format('basic_layout1.tlf')
22
- flexmock(format).should_receive(:page_paper_type).and_return('B4')
21
+ format = new_layout_format('layout_text1.tlf')
22
+ format.stubs(page_paper_type: 'B4')
23
23
 
24
24
  @pdf.start_new_page(format)
25
25
  assert_equal @pdf.internal.page.size, 'B4_JIS'
@@ -28,8 +28,8 @@ class ThinReports::Generator::PDF::Document::TestPage < MiniTest::Unit::TestCase
28
28
  def test_B4_ISO_paper_size_should_be_converted_to_B4
29
29
  create_pdf
30
30
 
31
- format = create_basic_layout_format('basic_layout1.tlf')
32
- flexmock(format).should_receive(:page_paper_type).and_return('B4_ISO')
31
+ format = new_layout_format('layout_text1.tlf')
32
+ format.stubs(page_paper_type: 'B4_ISO')
33
33
 
34
34
  @pdf.start_new_page(format)
35
35
  assert_equal @pdf.internal.page.size, 'B4'
@@ -37,85 +37,84 @@ class ThinReports::Generator::PDF::Document::TestPage < MiniTest::Unit::TestCase
37
37
 
38
38
  def test_change_page_format_should_return_true_at_first_time
39
39
  create_pdf
40
- format = create_basic_layout_format('basic_layout1.tlf')
41
-
40
+ format = new_layout_format('layout_text1.tlf')
41
+
42
42
  assert_equal @pdf.send(:change_page_format?, format), true
43
43
  end
44
-
44
+
45
45
  def test_change_page_format_should_return_false_when_given_the_same_format
46
46
  create_pdf
47
- format = create_basic_layout_format('basic_layout1.tlf')
48
-
47
+ format = new_layout_format('layout_text1.tlf')
48
+
49
49
  @pdf.instance_variable_set(:@current_page_format, format)
50
50
  assert_equal @pdf.send(:change_page_format?, format), false
51
51
  end
52
-
52
+
53
53
  def test_change_page_format_should_return_true_when_given_the_other_format
54
54
  create_pdf
55
- format1 = create_basic_layout_format('basic_layout1.tlf')
56
- format2 = create_basic_layout_format('basic_layout2.tlf')
57
-
55
+ format1 = new_layout_format('layout_text1.tlf')
56
+ format2 = new_layout_format('layout_text2.tlf')
57
+
58
58
  @pdf.instance_variable_set(:@current_page_format, format1)
59
59
  assert_equal @pdf.send(:change_page_format?, format2), true
60
60
  end
61
-
61
+
62
62
  def test_new_basic_page_options
63
- format = create_basic_layout_format('basic_layout1.tlf')
63
+ format = new_layout_format('layout_text1.tlf')
64
64
  options = create_pdf.send(:new_basic_page_options, format)
65
-
65
+
66
66
  assert_equal options[:layout], format.page_orientation.to_sym
67
67
  assert_equal options[:size], format.page_paper_type
68
68
  end
69
-
69
+
70
70
  def test_new_basic_page_options_when_the_layout_has_customize_size
71
- format = flexmock('format').
72
- should_receive(:user_paper_type? => true,
73
- :page_width => 100,
74
- :page_height => 100,
75
- :page_orientation => 'portrait').mock
76
-
71
+ format = stub user_paper_type?: true,
72
+ page_width: 100,
73
+ page_height: 100,
74
+ page_orientation: 'portrait'
75
+
77
76
  options = create_pdf.send(:new_basic_page_options, format)
78
77
  assert_equal options[:size], [100, 100]
79
78
  end
80
-
79
+
81
80
  def test_start_new_page_should_create_stamp
82
81
  create_pdf
83
- format = create_basic_layout_format('basic_layout1.tlf')
82
+ format = new_layout_format('layout_text1.tlf')
84
83
  @pdf.start_new_page(format)
85
-
84
+
86
85
  assert_includes @pdf.send(:format_stamp_registry), format.identifier
87
86
  end
88
-
87
+
89
88
  def test_start_new_page_should_not_create_stamp
90
89
  create_pdf
91
- format = create_basic_layout_format('basic_layout1.tlf')
90
+ format = new_layout_format('layout_text1.tlf')
92
91
  @pdf.start_new_page(format)
93
92
  @pdf.start_new_page(format)
94
-
93
+
95
94
  assert_equal @pdf.send(:format_stamp_registry).size, 1
96
95
  end
97
-
96
+
98
97
  def test_start_new_page_should_stamp_constantly
99
98
  create_pdf
100
- format = create_basic_layout_format('basic_layout1.tlf')
101
- flexmock(@pdf).should_receive(:stamp).with(format.identifier.to_s).times(2)
102
-
99
+ format = new_layout_format('layout_text1.tlf')
100
+ @pdf.expects(:stamp).with(format.identifier.to_s).times(2)
101
+
103
102
  @pdf.start_new_page(format)
104
103
  @pdf.start_new_page(format)
105
104
  end
106
105
 
107
106
  def test_add_blank_page_should_create_an_A4_size_page_in_first_page
108
107
  create_pdf
109
- flexmock(@pdf.internal).should_receive(:start_new_page).with(:size => 'A4').once
110
-
108
+ @pdf.internal.expects(:start_new_page).with(size: 'A4').once
109
+
111
110
  @pdf.add_blank_page
112
111
  end
113
-
112
+
114
113
  def test_add_blank_page_should_call_with_no_arguments_since_second_page
115
114
  create_pdf
116
- @pdf.start_new_page(create_basic_layout_format('basic_layout1.tlf'))
117
- flexmock(@pdf.internal).should_receive(:start_new_page).with(Hash.new).once
118
-
115
+ @pdf.start_new_page(new_layout_format('layout_text1.tlf'))
116
+ @pdf.internal.expects(:start_new_page).with({}).once
117
+
119
118
  @pdf.add_blank_page
120
119
  end
121
120
  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::TestParseColor < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
5
+ class Thinreports::Generator::PDF::TestParseColor < Minitest::Test
6
+ include Thinreports::TestHelper
7
7
 
8
8
  class TestColorParser
9
- include ThinReports::Generator::PDF::ParseColor
9
+ include Thinreports::Generator::PDF::ParseColor
10
10
  end
11
11
 
12
12
  def setup
@@ -23,7 +23,7 @@ class ThinReports::Generator::PDF::TestParseColor < MiniTest::Unit::TestCase
23
23
  end
24
24
 
25
25
  def test_parse_color_with_colorname_raise_when_unknown_name_given
26
- assert_raises ThinReports::Errors::UnsupportedColorName do
26
+ assert_raises Thinreports::Errors::UnsupportedColorName do
27
27
  @parser.parse_color('whitesmoke')
28
28
  end
29
29
  end
@@ -1,15 +1,22 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Generator::PDF::TestConfiguration < Minitest::Test
6
+ include Thinreports::TestHelper
4
7
 
5
- class ThinReports::Generator::PDF::TestConfiguration < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
8
  def setup
9
- @config = ThinReports::Generator::PDF::Configuration.new
9
+ @config = Thinreports::Generator::PDF::Configuration.new
10
+ end
11
+
12
+ def test_eudc_fonts_is_deprecated
13
+ out, err = capture_io do
14
+ @config.eudc_fonts = []
15
+ end
16
+ assert_includes err, '[DEPRECATION]'
10
17
  end
11
-
12
- def test_eudc_fonts_can_only_set_font_of_TTF
18
+
19
+ def test_eudc_fonts_should_be_able_to_set_only_TTF
13
20
  assert_raises ArgumentError do
14
21
  @config.eudc_fonts = '/path/to/eudc'
15
22
  end
@@ -17,8 +24,8 @@ class ThinReports::Generator::PDF::TestConfiguration < MiniTest::Unit::TestCase
17
24
  @config.eudc_fonts = %w( /path/to/eudc1.ttf /path/to/eudc2 )
18
25
  end
19
26
  end
20
-
27
+
21
28
  def test_eudc_fonts_should_return_empty_array_by_default
22
29
  assert_equal @config.eudc_fonts, []
23
30
  end
24
- end
31
+ end
@@ -1,28 +1,20 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Generator::PDF::TestDocument < Minitest::Test
6
+ include Thinreports::TestHelper
4
7
 
5
- class ThinReports::Generator::PDF::TestDocument < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
8
  # Alias
9
- Document = ThinReports::Generator::PDF::Document
10
-
9
+ Document = Thinreports::Generator::PDF::Document
10
+
11
11
  def test_new_without_page_creation
12
12
  pdf = Document.new
13
13
  assert_equal pdf.internal.page_count, 0
14
14
  end
15
-
15
+
16
16
  def test_new_with_zero_margin_canvas
17
17
  pdf = Document.new
18
18
  assert_equal pdf.internal.page.margins.values, [0, 0, 0, 0]
19
19
  end
20
-
21
- def test_new_with_security_settings
22
- flexmock(Prawn::Document).new_instances.
23
- should_receive(:encrypt_document).once.
24
- with(:user_password => 'foo')
25
-
26
- Document.new(:security => {:user_password => 'foo'})
27
- end
28
- end
20
+ end
@@ -1,51 +1,40 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
4
-
5
- class ThinReports::Generator::TestBase < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
- # Alias
9
- Generator = ThinReports::Generator
10
-
11
- class FooHoge < Generator::Base; end
12
-
13
- def test_subcclasses_are_registered_as_generator_when_inherited
14
- assert_same FooHoge, Generator.registry.delete(:foohoge)
15
- end
16
-
17
- def test_initialize_finalize_given_the_report
18
- report = flexmock('report').
19
- should_receive(:finalize).once.
20
- should_receive(:internal).once.mock
21
-
22
- Generator::Base.new(report)
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Generator::TestBase < Minitest::Test
6
+ include Thinreports::TestHelper
7
+
8
+ Generator = Thinreports::Generator
9
+
10
+ class FooGenerator < Generator::Base; end
11
+
12
+ def test_registring_generator
13
+ assert_same FooGenerator, Generator.registry.delete(:foogenerator)
23
14
  end
24
-
25
- def test_generate_is_abstract_method
26
- assert_raises NotImplementedError do
27
- new_generator.generate
28
- end
15
+
16
+ def test_new
17
+ report = new_report 'layout_text1.tlf'
18
+
19
+ refute report.finalized?
20
+ Generator::Base.new report
21
+ assert report.finalized?
29
22
  end
30
-
31
- def test_generate_file_is_abstract_method
23
+
24
+ def test_generate
25
+ report = new_report 'layout_text1.tlf'
26
+
27
+ generator = Generator::Base.new report
32
28
  assert_raises NotImplementedError do
33
- new_generator.generate_file('output.pdf')
29
+ generator.generate
34
30
  end
35
31
  end
36
-
32
+
37
33
  def test_default_layout
38
- generator = new_generator
39
- flexmock(generator.report).
40
- should_receive(:default_layout).and_return(flexmock('default_layout')).once
41
-
42
- assert_equal generator.default_layout.flexmock_name, 'default_layout'
43
- end
44
-
45
- def new_generator
46
- report = flexmock('report').
47
- should_receive(:finalize).
48
- should_receive(:internal).and_return(flexmock('report_internal')).mock
49
- Generator::Base.new(report)
34
+ report = new_report 'layout_text1.tlf'
35
+
36
+ generator = Generator::Base.new report
37
+ assert_equal data_file('layout_text1.tlf'),
38
+ generator.default_layout.filename
50
39
  end
51
- end
40
+ end
@@ -1,16 +1,16 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
4
 
5
- class ThinReports::Generator::TestConfiguration < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
5
+ class Thinreports::Generator::TestConfiguration < Minitest::Test
6
+ include Thinreports::TestHelper
7
7
 
8
8
  def setup
9
- @config = ThinReports::Generator::Configuration.new
9
+ @config = Thinreports::Generator::Configuration.new
10
10
  end
11
11
 
12
12
  def test_pdf_should_return_configuration_of_pdf
13
- assert_instance_of ThinReports::Generator::PDF::Configuration, @config.pdf
13
+ assert_instance_of Thinreports::Generator::PDF::Configuration, @config.pdf
14
14
  end
15
15
 
16
16
  def test_default_should_return_pdf_by_default
@@ -18,7 +18,7 @@ class ThinReports::Generator::TestConfiguration < MiniTest::Unit::TestCase
18
18
  end
19
19
 
20
20
  def test_default_should_raise_when_value_is_unknown_generator_type
21
- assert_raises ThinReports::Errors::UnknownGeneratorType do
21
+ assert_raises Thinreports::Errors::UnknownGeneratorType do
22
22
  @config.default = :unknown
23
23
  end
24
24
  end
@@ -1,20 +1,23 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Generator::TestPDF < Minitest::Test
6
+ include Thinreports::TestHelper
7
+
8
+ PDF = Thinreports::Generator::PDF
4
9
 
5
- class ThinReports::Generator::TestPDF < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
- # Alias
9
- PDF = ThinReports::Generator::PDF
10
-
11
10
  def test_new_should_set_title_as_metadata
12
- report = create_basic_report('basic_layout1.tlf') {|r| r.start_new_page }
13
-
14
- flexmock(PDF::Document).should_receive(:new).
15
- with(Hash, :Title => 'Basic Layout').once
16
-
17
- PDF.new(report, {})
11
+ report = new_report('layout_text1.tlf') {|r| r.start_new_page }
12
+
13
+ actual_pdf_title = nil
14
+ PDF::Document.define_singleton_method(:new) {|options, meta|
15
+ actual_pdf_title = meta[:Title]
16
+ }
17
+ PDF.new report, {}
18
+
19
+ assert_equal 'Basic Layout', actual_pdf_title
20
+ ensure
21
+ PDF::Document.singleton_class.send(:remove_method, :new)
18
22
  end
19
23
  end
20
-