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,12 +1,12 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
4
 
5
- class ThinReports::Report::TestEvents < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
5
+ class Thinreports::Report::TestEvents < Minitest::Test
6
+ include Thinreports::TestHelper
7
7
 
8
8
  # Alias
9
- Report = ThinReports::Report
9
+ Report = Thinreports::Report
10
10
 
11
11
  def test_event_types
12
12
  events = Report::Events.new
@@ -1,31 +1,31 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Report::TestInternal < Minitest::Test
6
+ include Thinreports::TestHelper
4
7
 
5
- class ThinReports::Report::TestInternal < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
8
  # Alias
9
- Report = ThinReports::Report
10
-
9
+ Report = Thinreports::Report
10
+
11
11
  def report
12
12
  Report::Base.new
13
13
  end
14
14
 
15
15
  def sample_layout1
16
- data_file('basic_layout1.tlf')
16
+ data_file('layout_text1.tlf')
17
17
  end
18
18
 
19
19
  def sample_layout2
20
- data_file('basic_layout2.tlf')
20
+ data_file('layout_text2.tlf')
21
21
  end
22
22
 
23
23
  def sample_list_layout
24
- data_file('basic_list_layout.tlf')
24
+ data_file('layout_list.tlf')
25
25
  end
26
26
 
27
27
  def test_layout_specified_in_new_method_should_be_defined_as_default_layout
28
- internal = Report::Internal.new(report, :layout => sample_layout1)
28
+ internal = Report::Internal.new(report, layout: sample_layout1)
29
29
  assert_equal internal.default_layout.filename, sample_layout1
30
30
  end
31
31
 
@@ -35,98 +35,98 @@ class ThinReports::Report::TestInternal < MiniTest::Unit::TestCase
35
35
 
36
36
  assert_equal internal.default_layout.filename, sample_layout1
37
37
  end
38
-
38
+
39
39
  def test_register_layout_should_be_set_as_default_layout_when_default_option_is_true
40
40
  internal = Report::Internal.new(report, {})
41
- internal.register_layout(sample_layout1, :default => true)
42
-
41
+ internal.register_layout(sample_layout1, default: true)
42
+
43
43
  assert_equal internal.default_layout.filename, sample_layout1
44
44
  end
45
-
45
+
46
46
  def test_register_layout_should_be_able_to_change_the_default_layout
47
- internal = Report::Internal.new(report, :layout => sample_layout1)
48
- internal.register_layout(sample_layout2, :default => true)
47
+ internal = Report::Internal.new(report, layout: sample_layout1)
48
+ internal.register_layout(sample_layout2, default: true)
49
49
 
50
50
  assert_equal internal.default_layout.filename, sample_layout2
51
51
  end
52
-
52
+
53
53
  def test_register_layout_should_be_set_as_with_id_when_id_option_is_set
54
54
  internal = Report::Internal.new(report, {})
55
- internal.register_layout(sample_layout1, :id => :foo)
55
+ internal.register_layout(sample_layout1, id: :foo)
56
56
 
57
57
  assert_equal internal.layout_registry[:foo].filename, sample_layout1
58
58
  end
59
-
59
+
60
60
  def test_register_layout_should_raise_an_error_when_id_is_already_registered
61
61
  internal = Report::Internal.new(report, {})
62
- internal.register_layout(sample_layout2, :id => :foo)
63
-
62
+ internal.register_layout(sample_layout2, id: :foo)
63
+
64
64
  assert_raises ArgumentError do
65
- internal.register_layout(sample_layout1, :id => :foo)
65
+ internal.register_layout(sample_layout1, id: :foo)
66
66
  end
67
67
  end
68
-
68
+
69
69
  def test_register_layout_should_return_the_instance_of_LayoutConfiguration
70
70
  internal = Report::Internal.new(report, {})
71
71
 
72
- assert_instance_of ThinReports::Layout::Configuration,
72
+ assert_instance_of Thinreports::Layout::Configuration,
73
73
  internal.register_layout(sample_layout1)
74
74
  end
75
75
 
76
76
  def test_register_layout_should_be_able_to_set_list_configuration_without_errors
77
77
  internal = Report::Internal.new(report, {})
78
78
  internal.register_layout(sample_list_layout) do |config|
79
- config.list(:list).use_stores :foo => 0
80
- config.list(:list).use_stores :bar => 1000
79
+ config.list(:list).use_stores foo: 0
80
+ config.list(:list).use_stores bar: 1000
81
81
  end
82
82
  pass
83
83
  end
84
-
84
+
85
85
  def test_add_page_should_finalize_the_current_page
86
- layout = ThinReports::Layout.new(sample_layout1)
86
+ layout = Thinreports::Layout.new(sample_layout1)
87
87
 
88
- internal = Report::Internal.new(report, :layout => sample_layout1)
89
- page = internal.add_page(ThinReports::Core::Page.new(report, layout))
90
- internal.add_page(ThinReports::Core::Page.new(report, layout))
88
+ internal = Report::Internal.new(report, layout: sample_layout1)
89
+ page = internal.add_page(Thinreports::Report::Page.new(report, layout))
90
+ internal.add_page(Thinreports::Report::Page.new(report, layout))
91
91
 
92
92
  assert_equal page.finalized?, true
93
93
  end
94
94
 
95
95
  def test_add_page_should_return_the_current_page
96
- layout = ThinReports::Layout.new(sample_layout1)
97
- new_page = ThinReports::Core::Page.new(report, layout)
96
+ layout = Thinreports::Layout.new(sample_layout1)
97
+ new_page = Thinreports::Report::Page.new(report, layout)
98
98
 
99
- internal = Report::Internal.new(report, :layout => sample_layout1)
99
+ internal = Report::Internal.new(report, layout: sample_layout1)
100
100
 
101
101
  assert_same new_page, internal.add_page(new_page)
102
102
  end
103
103
 
104
104
  def test_add_page_should_add_the_initialized_page
105
- layout = ThinReports::Layout.new(sample_layout1)
106
- new_page = ThinReports::Core::Page.new(report, layout)
105
+ layout = Thinreports::Layout.new(sample_layout1)
106
+ new_page = Thinreports::Report::Page.new(report, layout)
107
107
 
108
- internal = Report::Internal.new(report, :layout => sample_layout1)
108
+ internal = Report::Internal.new(report, layout: sample_layout1)
109
109
  internal.add_page(new_page)
110
110
 
111
111
  assert_same new_page, internal.pages.last
112
112
  end
113
113
 
114
114
  def test_add_page_should_count_up_the_total_page_count
115
- layout = ThinReports::Layout.new(sample_layout1)
116
-
117
- internal = Report::Internal.new(report, :layout => sample_layout1)
118
- internal.add_page(ThinReports::Core::Page.new(report, layout))
115
+ layout = Thinreports::Layout.new(sample_layout1)
116
+
117
+ internal = Report::Internal.new(report, layout: sample_layout1)
118
+ internal.add_page(Thinreports::Report::Page.new(report, layout))
119
119
 
120
120
  assert_equal internal.page_count, 1
121
121
  end
122
-
122
+
123
123
  def test_add_page_should_switch_to_a_reference_to_the_current_page
124
- layout = ThinReports::Layout.new(sample_layout1)
124
+ layout = Thinreports::Layout.new(sample_layout1)
125
125
  new_pages = (1..2).inject([]) do |pages, i|
126
- pages << ThinReports::Core::Page.new(report, layout)
126
+ pages << Thinreports::Report::Page.new(report, layout)
127
127
  end
128
128
 
129
- internal = Report::Internal.new(report, :layout => sample_layout1)
129
+ internal = Report::Internal.new(report, layout: sample_layout1)
130
130
  internal.add_page(new_pages[0])
131
131
 
132
132
  assert_same internal.page, new_pages[0]
@@ -135,51 +135,51 @@ class ThinReports::Report::TestInternal < MiniTest::Unit::TestCase
135
135
 
136
136
  assert_same internal.page, new_pages[1]
137
137
  end
138
-
138
+
139
139
  def test_add_page_should_dispatch_the_event_page_creation
140
140
  dispatched = false
141
- layout = ThinReports::Layout.new(sample_layout1)
141
+ layout = Thinreports::Layout.new(sample_layout1)
142
142
 
143
- internal = Report::Internal.new(report, :layout => sample_layout1)
143
+ internal = Report::Internal.new(report, layout: sample_layout1)
144
144
  internal.events.on(:page_create) {|e| dispatched = true }
145
- internal.add_page(ThinReports::Core::Page.new(report, layout))
145
+ internal.add_page(Thinreports::Report::Page.new(report, layout))
146
146
 
147
147
  assert dispatched
148
148
  end
149
149
 
150
150
  def test_add_blank_page_should_not_dispatch_the_event_page_creation
151
151
  dispatched = false
152
- layout = ThinReports::Layout.new(sample_layout1)
152
+ layout = Thinreports::Layout.new(sample_layout1)
153
153
 
154
- internal = Report::Internal.new(report, :layout => sample_layout1)
154
+ internal = Report::Internal.new(report, layout: sample_layout1)
155
155
  internal.events.on(:page_create) {|e| dispatched = true }
156
- internal.add_page(ThinReports::Core::BlankPage.new)
156
+ internal.add_page(Thinreports::Report::BlankPage.new)
157
157
 
158
158
  refute dispatched
159
159
  end
160
-
160
+
161
161
  def test_add_blank_page_should_not_count_up_the_total_page_count_when_count_is_disabled
162
- layout = ThinReports::Layout.new(sample_layout1)
162
+ layout = Thinreports::Layout.new(sample_layout1)
163
163
 
164
- internal = Report::Internal.new(report, :layout => sample_layout1)
165
- internal.add_page(ThinReports::Core::BlankPage.new(false))
164
+ internal = Report::Internal.new(report, layout: sample_layout1)
165
+ internal.add_page(Thinreports::Report::BlankPage.new(false))
166
166
 
167
167
  assert_equal internal.page_count, 0
168
168
  end
169
169
 
170
170
  def test_add_blank_page_should_count_up_the_total_page_count_when_count_is_enabled
171
- layout = ThinReports::Layout.new(sample_layout1)
171
+ layout = Thinreports::Layout.new(sample_layout1)
172
172
 
173
- internal = Report::Internal.new(report, :layout => sample_layout1)
174
- internal.add_page(ThinReports::Core::BlankPage.new)
173
+ internal = Report::Internal.new(report, layout: sample_layout1)
174
+ internal.add_page(Thinreports::Report::BlankPage.new)
175
175
 
176
176
  assert_equal internal.page_count, 1
177
177
  end
178
-
178
+
179
179
  def test_finalize_should_dispatch_the_event_report_generation
180
180
  dispatched = false
181
181
 
182
- internal = Report::Internal.new(report, :layout => sample_layout1)
182
+ internal = Report::Internal.new(report, layout: sample_layout1)
183
183
  internal.events.on(:generate) {|e| dispatched = true }
184
184
  internal.finalize
185
185
 
@@ -187,49 +187,48 @@ class ThinReports::Report::TestInternal < MiniTest::Unit::TestCase
187
187
  end
188
188
 
189
189
  def test_finalize_should_finalize_the_report
190
- internal = Report::Internal.new(report, :layout => sample_layout1)
190
+ internal = Report::Internal.new(report, layout: sample_layout1)
191
191
  internal.finalize
192
192
 
193
193
  assert internal.finalized?
194
194
  end
195
195
 
196
196
  def test_finalize_should_not_work_when_report_is_already_finalized
197
- internal = Report::Internal.new(report, :layout => sample_layout1)
198
-
199
- flexmock(internal).
200
- should_receive(:finalize_current_page).once
201
-
197
+ internal = Report::Internal.new(report, layout: sample_layout1)
202
198
  internal.finalize
199
+
200
+ # #finalize_current_page must never be called
201
+ internal.expects(:finalize_current_page).never
203
202
  internal.finalize
204
203
  end
205
204
 
206
205
  def test_finalized_should_return_true_when_report_is_already_finalized
207
- internal = Report::Internal.new(report, :layout => sample_layout1)
206
+ internal = Report::Internal.new(report, layout: sample_layout1)
208
207
  internal.finalize
209
208
 
210
209
  assert internal.finalized?
211
210
  end
212
-
211
+
213
212
  def test_load_layout_with_String
214
- internal = Report::Internal.new(report, :layout => sample_layout1)
215
-
216
- assert_equal internal.load_layout(sample_layout2).filename,
213
+ internal = Report::Internal.new(report, layout: sample_layout1)
214
+
215
+ assert_equal internal.load_layout(sample_layout2).filename,
217
216
  sample_layout2
218
217
  end
219
-
218
+
220
219
  def test_load_layout_with_id
221
220
  internal = Report::Internal.new(report, {})
222
- internal.register_layout(sample_layout1, :id => :sample)
221
+ internal.register_layout(sample_layout1, id: :sample)
223
222
 
224
- assert_equal internal.load_layout(:sample).filename,
223
+ assert_equal internal.load_layout(:sample).filename,
225
224
  sample_layout1
226
225
  end
227
-
226
+
228
227
  def test_load_layout_with_unknown_id
229
228
  internal = Report::Internal.new(report, {})
230
229
  assert_nil internal.load_layout(:unknown)
231
230
  end
232
-
231
+
233
232
  def test_load_layout_should_set_default_layout_when_default_layout_is_nil
234
233
  internal = Report::Internal.new(report, {})
235
234
  internal.load_layout(sample_layout1)
@@ -241,29 +240,28 @@ class ThinReports::Report::TestInternal < MiniTest::Unit::TestCase
241
240
  def test_load_layout_should_raise_error_when_invalid_value_set
242
241
  internal = Report::Internal.new(report, {})
243
242
 
244
- assert_raises ThinReports::Errors::LayoutFileNotFound do
243
+ assert_raises Thinreports::Errors::LayoutFileNotFound do
245
244
  internal.load_layout('/path/to/unkown.tlf')
246
245
  end
247
246
  end
248
-
247
+
249
248
  def test_copy_page_should_finalize_current_page
250
- layout = ThinReports::Layout.new(sample_layout1)
249
+ layout = Thinreports::Layout.new(sample_layout1)
251
250
 
252
- internal = Report::Internal.new(report, :layout => sample_layout1)
253
- internal.add_page(page = ThinReports::Core::Page.new(report, layout))
251
+ internal = Report::Internal.new(report, layout: sample_layout1)
252
+ internal.add_page(page = Thinreports::Report::Page.new(report, layout))
254
253
  internal.copy_page
255
254
 
256
255
  assert page.finalized?
257
256
  end
258
257
 
259
258
  def test_copy_page_should_add_the_copied_page
260
- layout = ThinReports::Layout.new(sample_layout1)
259
+ layout = Thinreports::Layout.new(sample_layout1)
261
260
 
262
- internal = Report::Internal.new(report, :layout => sample_layout1)
263
- internal.add_page(page = ThinReports::Core::Page.new(report, layout))
261
+ internal = Report::Internal.new(report, layout: sample_layout1)
262
+ internal.add_page(page = Thinreports::Report::Page.new(report, layout))
264
263
  internal.copy_page
265
264
 
266
265
  assert_equal internal.page_count, 2
267
266
  end
268
267
  end
269
-
@@ -1,22 +1,41 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::TestConfig < Minitest::Test
6
+ include Thinreports::TestHelper
4
7
 
5
- class ThinReports::TestConfig < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
8
  def test_generator_of_Configuration_should_return_configuration_of_generator
9
- config = ThinReports::Configuration.new
10
- assert_instance_of ThinReports::Generator::Configuration, config.generator
9
+ config = Thinreports::Configuration.new
10
+ assert_instance_of Thinreports::Generator::Configuration, config.generator
11
11
  end
12
-
12
+
13
13
  def test_config_should_return_configuration_of_thinreports
14
- assert_instance_of ThinReports::Configuration, ThinReports.config
14
+ assert_instance_of Thinreports::Configuration, Thinreports.config
15
15
  end
16
-
16
+
17
17
  def test_configure_should_exec_an_given_block_with_config_which_instance_of_Configuration
18
- ThinReports.configure do |config|
19
- assert_instance_of ThinReports::Configuration, config
18
+ Thinreports.configure do |config|
19
+ assert_instance_of Thinreports::Configuration, config
20
20
  end
21
21
  end
22
- end
22
+
23
+ def test_fallback_fonts
24
+ config = Thinreports::Configuration.new
25
+
26
+ # should be empty by default
27
+ assert_empty config.fallback_fonts
28
+
29
+ config.fallback_fonts = 'Helvetica'
30
+ assert_equal config.fallback_fonts, ['Helvetica']
31
+
32
+ config.fallback_fonts = ['/path/to/font.ttf', 'Courier New']
33
+ assert_equal config.fallback_fonts, ['/path/to/font.ttf', 'Courier New']
34
+
35
+ config.fallback_fonts = []
36
+ config.fallback_fonts << 'Helvetica'
37
+ config.fallback_fonts << 'IPAMincho'
38
+ config.fallback_fonts.unshift 'Times New Roman'
39
+ assert_equal config.fallback_fonts, ['Times New Roman', 'Helvetica', 'IPAMincho']
40
+ end
41
+ end
@@ -1,12 +1,12 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::TestLayout < Minitest::Test
6
+ include Thinreports::TestHelper
4
7
 
5
- class ThinReports::TestLayout < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
8
  def test_new
9
- flexmock(ThinReports::Layout::Base).should_receive(:new).once
10
- ThinReports::Layout.new('layout.tlf')
9
+ assert_instance_of Thinreports::Layout::Base,
10
+ Thinreports::Layout.new(data_file('layout_text1.tlf'))
11
11
  end
12
- end
12
+ end
@@ -1,30 +1,18 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::TestReport < Minitest::Test
6
+ include Thinreports::TestHelper
4
7
 
5
- class ThinReports::TestReport < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
8
  # Alias
9
- Report = ThinReports::Report
10
-
11
- def test_new_should_delegate_to_Base_new
12
- flexmock(Report::Base).should_receive(:new).once
13
- Report.new
14
- end
15
-
16
- def test_create_should_delegate_to_Base_create
17
- flexmock(Report::Base).should_receive(:create).once
18
- Report.create
19
- end
20
-
21
- def test_generate_should_delegate_to_Base_generate
22
- flexmock(Report::Base).should_receive(:generate).once
23
- Report.generate
9
+ Report = Thinreports::Report
10
+
11
+ def test_new
12
+ assert_instance_of Report::Base, Report.new
24
13
  end
25
-
26
- def test_generate_file_should_delegate_to_Base_generate_file
27
- flexmock(Report::Base).should_receive(:generate_file).once
28
- Report.generate_file
14
+
15
+ def test_create
16
+ assert_instance_of Report::Base, Report.create {}
29
17
  end
30
- end
18
+ end