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,14 +1,14 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Core::Format::TestBuilder < Minitest::Test
6
+ include Thinreports::TestHelper
4
7
 
5
- class ThinReports::Core::Format::TestBuilder < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
8
  TEST_RAW_FORMAT = <<-'EOS'
9
9
  {
10
- "node1":"\u3042\u6f22\u5b57\uff20\u3231\u2160\u30ab\u30ca\uff76\uff85",
11
- "node2":{"node2_child":"node2_child value"},
10
+ "node1": "あ漢字@㈱Ⅰカナカナ",
11
+ "node2": { "node2_child":"node2_child value" },
12
12
  "layout":
13
13
  "<svg width=\"595.2\" height=\"841.8\">
14
14
  <g class=\"canvas\">
@@ -19,22 +19,17 @@ class ThinReports::Core::Format::TestBuilder < MiniTest::Unit::TestCase
19
19
  </svg>"
20
20
  }
21
21
  EOS
22
-
23
- class TestFormat < ThinReports::Core::Format::Base
24
- extend ::ThinReports::Core::Format::Builder
25
-
22
+
23
+ class TestFormat < Thinreports::Core::Format::Base
24
+ extend ::Thinreports::Core::Format::Builder
26
25
  config_reader :layout
27
26
  config_accessor :shapes
28
-
29
- # For test
30
- public_class_method :parse_json, :build_layout, :clean,
31
- :clean_with_attributes, :shape_tag
32
27
  end
33
-
28
+
34
29
  def setup
35
30
  @raw_format = clean_whitespaces(TEST_RAW_FORMAT)
36
31
  end
37
-
32
+
38
33
  def test_parse_json
39
34
  expected_format = {
40
35
  "node1" => "あ漢字@㈱Ⅰカナカナ",
@@ -53,15 +48,15 @@ class ThinReports::Core::Format::TestBuilder < MiniTest::Unit::TestCase
53
48
  }
54
49
  assert_equal TestFormat.parse_json(@raw_format), expected_format
55
50
  end
56
-
51
+
57
52
  def test_build_layout
58
53
  format = TestFormat.new(TestFormat.parse_json(@raw_format))
59
54
  format.shapes = {}
60
55
 
61
56
  TestFormat.build_layout(format) do |type, f|
62
- flexmock(:id => f['id'])
57
+ Thinreports::Core::Shape::Format(type).build(f)
63
58
  end
64
-
59
+
65
60
  assert_equal format.layout, clean_whitespaces(<<-'EOS')
66
61
  <svg width="595.2" height="841.8">
67
62
  <g class="canvas">
@@ -72,7 +67,7 @@ class ThinReports::Core::Format::TestBuilder < MiniTest::Unit::TestCase
72
67
  EOS
73
68
  assert_includes format.shapes.keys, :t1
74
69
  end
75
-
70
+
76
71
  def test_clean
77
72
  source = clean_whitespaces(<<-'EOS')
78
73
  <svg width="595.2" height="841.8">
@@ -89,7 +84,7 @@ class ThinReports::Core::Format::TestBuilder < MiniTest::Unit::TestCase
89
84
  </svg>
90
85
  EOS
91
86
  end
92
-
87
+
93
88
  def test_clean_with_attributes
94
89
  source = clean_whitespaces(<<-'EOS')
95
90
  <svg width="595.2" height="841.8">
@@ -106,8 +101,9 @@ class ThinReports::Core::Format::TestBuilder < MiniTest::Unit::TestCase
106
101
  </svg>
107
102
  EOS
108
103
  end
109
-
104
+
110
105
  def test_shape_tag
111
- assert_equal TestFormat.shape_tag(flexmock(:id => :foo)), '<%= r(:"foo")%>'
106
+ shape_format = stub(id: :foo)
107
+ assert_equal TestFormat.shape_tag(shape_format), '<%= r(:"foo")%>'
112
108
  end
113
109
  end
@@ -1,89 +1,86 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Core::Shape::Base::TestInternal < Minitest::Test
6
+ include Thinreports::TestHelper
7
+
8
+ def setup
9
+ @report = Thinreports::Report.new layout: data_file('layout_text1.tlf')
10
+ @report.start_new_page
11
+ end
4
12
 
5
- class ThinReports::Core::Shape::Base::TestInternal < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
13
  def create_internal(format_config = {}, &block)
9
14
  format = unless format_config.empty?
10
- format_klass = ::Class.new(ThinReports::Core::Shape::Basic::Format) {
15
+ format_klass = Class.new(Thinreports::Core::Shape::Basic::Format) {
11
16
  config_reader(*format_config.keys.map {|k| k.to_sym })
12
17
  }
13
18
  format_klass.new(format_config)
14
19
  else
15
- ThinReports::Core::Shape::Basic::Format.new({})
20
+ Thinreports::Core::Shape::Basic::Format.new({})
16
21
  end
17
-
18
- klass = ::Class.new(ThinReports::Core::Shape::Base::Internal, &block)
19
- klass.new(flexmock('parent'), format)
22
+
23
+ klass = Class.new(Thinreports::Core::Shape::Base::Internal, &block)
24
+ klass.new(@report.page, format)
20
25
  end
21
-
26
+
22
27
  def test_self_format_delegators_should_defines_method_delegated_from_format
23
28
  internal = create_internal('m1' => 'm1_value') {
24
29
  format_delegators :m1
25
30
  }
26
31
  assert_respond_to internal, :m1
27
32
  end
28
-
33
+
29
34
  def test_method_delegated_from_format_should_return_same_value_as_an_format
30
35
  internal = create_internal('m1' => 'm1 value') {
31
36
  format_delegators :m1
32
37
  }
33
38
  assert_same internal.m1, internal.format.m1
34
39
  end
35
-
36
- def test_switch_parent_should_replace_a_parent_property_to_the_specified_new_parent
37
- new_parent = flexmock('new_parent')
38
-
39
- internal = create_internal
40
- internal.switch_parent!(new_parent)
41
-
42
- assert_same internal.parent, new_parent
43
- end
44
-
40
+
45
41
  def test_copied_internal_should_have_the_new_value_specified_as_a_parent_property
46
- new_parent = flexmock('new_parent')
42
+ new_page = @report.start_new_page
47
43
  internal = create_internal {
48
44
  def style
49
- @style ||= ThinReports::Core::Shape::Style::Base.new(format)
45
+ @style ||= Thinreports::Core::Shape::Style::Base.new(format)
50
46
  end
51
47
  }
52
- assert_same internal.copy(new_parent).parent, new_parent
48
+
49
+ assert_same internal.copy(new_page).parent, new_page
53
50
  end
54
-
51
+
55
52
  def test_copied_internal_should_have_style_copied_from_original
56
53
  internal = create_internal {
57
54
  def style
58
- @style ||= ThinReports::Core::Shape::Style::Base.new(format)
55
+ @style ||= Thinreports::Core::Shape::Style::Base.new(format)
59
56
  end
60
57
  }
61
58
  internal.style.write_internal_style(:foo, 'bar')
62
- new_internal = internal.copy(flexmock('new_parent'))
63
-
59
+ new_internal = internal.copy(@report.start_new_page)
60
+
64
61
  assert_equal new_internal.style.read_internal_style(:foo), 'bar'
65
62
  end
66
-
63
+
67
64
  def test_copied_internal_should_have_states_property_copied_from_original
68
65
  internal = create_internal {
69
66
  def style
70
- @style ||= ThinReports::Core::Shape::Style::Base.new(format)
67
+ @style ||= Thinreports::Core::Shape::Style::Base.new(format)
71
68
  end
72
69
  }
73
70
  internal.states[:foo] = 'bar'
74
- new_internal = internal.copy(flexmock('new_parent'))
75
-
71
+ new_internal = internal.copy(@report.start_new_page)
72
+
76
73
  assert_equal new_internal.states[:foo], 'bar'
77
74
  end
78
-
75
+
79
76
  def test_copy_should_execute_block_with_new_internal_as_argument
80
77
  internal = create_internal {
81
78
  def style
82
- @style ||= ThinReports::Core::Shape::Style::Base.new(format)
79
+ @style ||= Thinreports::Core::Shape::Style::Base.new(format)
83
80
  end
84
81
  }
85
- internal.copy(flexmock('new_parent')) do |new_internal|
86
- assert_equal new_internal.is_a?(ThinReports::Core::Shape::Base::Internal), true
82
+ internal.copy(@report.start_new_page) do |new_internal|
83
+ assert_equal new_internal.is_a?(Thinreports::Core::Shape::Base::Internal), true
87
84
  end
88
85
  end
89
- end
86
+ end
@@ -1,9 +1,9 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
4
 
5
- class ThinReports::Core::Shape::Basic::TestBlockFormat < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
5
+ class Thinreports::Core::Shape::Basic::TestBlockFormat < Minitest::Test
6
+ include Thinreports::TestHelper
7
7
 
8
8
  TEST_BLOCK_FORMAT = {
9
9
  "value" => "default value",
@@ -25,6 +25,6 @@ class ThinReports::Core::Shape::Basic::TestBlockFormat < MiniTest::Unit::TestCas
25
25
  end
26
26
 
27
27
  def format
28
- ThinReports::Core::Shape::Basic::BlockFormat.new(TEST_BLOCK_FORMAT)
28
+ Thinreports::Core::Shape::Basic::BlockFormat.new(TEST_BLOCK_FORMAT)
29
29
  end
30
30
  end
@@ -1,27 +1,29 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Core::Shape::Basic::TestBlockInterface < Minitest::Test
6
+ include Thinreports::TestHelper
7
+
8
+ Basic = Thinreports::Core::Shape::Basic
4
9
 
5
- class ThinReports::Core::Shape::Basic::TestBlockInterface < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
- Basic = ThinReports::Core::Shape::Basic
9
-
10
10
  def setup
11
- parent = flexmock('parent')
11
+ report = Thinreports::Report.new layout: data_file('layout_text1')
12
+ parent = report.start_new_page
13
+
12
14
  format = Basic::BlockFormat.new({})
13
- internal = Basic::BlockInternal.new(parent, Basic::BlockFormat.new({}))
14
-
15
- @interface = Basic::BlockInterface.new(parent, format, internal)
15
+ internal = Basic::BlockInternal.new parent, format
16
+
17
+ @interface = Basic::BlockInterface.new parent, format, internal
16
18
  end
17
-
19
+
18
20
  def test_value_should_work_as_reader_with_no_arguments
19
21
  @interface.internal.write_value('new value')
20
22
  assert_equal @interface.value, 'new value'
21
23
  end
22
-
24
+
23
25
  def test_value_should_work_as_writer_with_arguments
24
26
  @interface.value('new value')
25
27
  assert_equal @interface.internal.read_value, 'new value'
26
28
  end
27
- end
29
+ end
@@ -1,55 +1,58 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
+
5
+ class Thinreports::Core::Shape::Basic::TestBlockInternal < Minitest::Test
6
+ include Thinreports::TestHelper
7
+
8
+ Basic = Thinreports::Core::Shape::Basic
4
9
 
5
- class ThinReports::Core::Shape::Basic::TestBlockInternal < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
7
-
8
- Basic = ThinReports::Core::Shape::Basic
9
-
10
10
  def test_box_should_return_value_of_format
11
11
  internal = init_internal('box' => 'box of format')
12
12
  assert_equal internal.box, 'box of format'
13
13
  end
14
-
14
+
15
15
  def test_read_value_should_return_value_from_format
16
16
  internal = init_internal('value' => 'default value')
17
17
  assert_equal internal.read_value, 'default value'
18
18
  end
19
-
19
+
20
20
  def test_read_value_should_return_value_from_state_with_value_key
21
21
  internal = init_internal
22
22
  internal.states[:value] = 'new value'
23
23
  assert_equal internal.read_value, 'new value'
24
24
  end
25
-
25
+
26
26
  def test_real_value_should_return_the_same_value_as_a_read_value_method
27
27
  internal = init_internal
28
28
  internal.states[:value] = 'foo'
29
29
  assert_same internal.real_value, internal.read_value
30
30
  end
31
-
31
+
32
32
  def test_write_value_should_save_value_to_states_store_as_value
33
33
  internal = init_internal
34
34
  internal.write_value('new value')
35
35
  assert_equal internal.states[:value], 'new value'
36
36
  end
37
-
37
+
38
38
  def test_type_of_asker_should_return_true_when_given_the_block_value
39
39
  assert_equal init_internal.type_of?(:block), true
40
40
  end
41
-
41
+
42
42
  def test_value_should_works_the_same_as_read_value_method
43
43
  internal = init_internal
44
44
  internal.write_value('new value')
45
45
  assert_same internal.read_value, internal.value
46
46
  end
47
-
47
+
48
48
  def test_type_of_asker_should_return_false_otherwise
49
49
  assert_equal [:iblock, :tblock, :text, :list].all? {|t| !init_internal.type_of?(t)}, true
50
50
  end
51
-
51
+
52
52
  def init_internal(format = {})
53
- Basic::BlockInternal.new(flexmock('parent'), Basic::BlockFormat.new(format))
53
+ report = Thinreports::Report.new layout: data_file('layout_text1')
54
+ parent = report.start_new_page
55
+
56
+ Basic::BlockInternal.new(parent, Basic::BlockFormat.new(format))
54
57
  end
55
- end
58
+ end
@@ -1,9 +1,9 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
4
 
5
- class ThinReports::Core::Shape::Basic::TestFormat < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
5
+ class Thinreports::Core::Shape::Basic::TestFormat < Minitest::Test
6
+ include Thinreports::TestHelper
7
7
 
8
8
  TEST_BASIC_FORMAT = {
9
9
  "type" => "s-rect",
@@ -28,7 +28,7 @@ class ThinReports::Core::Shape::Basic::TestFormat < MiniTest::Unit::TestCase
28
28
  }
29
29
 
30
30
  # Alias
31
- Format = ThinReports::Core::Shape::Basic::Format
31
+ Format = Thinreports::Core::Shape::Basic::Format
32
32
 
33
33
  def test_build_basic_format
34
34
  build_basic_format
@@ -1,118 +1,108 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'test/unit/helper'
3
+ require 'test_helper'
4
4
 
5
- class ThinReports::Core::Shape::Basic::TestInterface < MiniTest::Unit::TestCase
6
- include ThinReports::TestHelpers
5
+ class Thinreports::Core::Shape::Basic::TestInterface < Minitest::Test
6
+ include Thinreports::TestHelper
7
7
 
8
8
  # Alias
9
- Basic = ThinReports::Core::Shape::Basic
10
-
9
+ Basic = Thinreports::Core::Shape::Basic
10
+
11
11
  def create_interface(format_config = {})
12
- Basic::Interface.new(flexmock('parent'),
13
- Basic::Format.new(format_config))
14
- end
15
-
16
- def setup
17
- format = flexmock('format')
18
- format.should_receive(:display? => true)
19
-
20
- @basic = Basic::Interface.new(flexmock('parent'), format)
12
+ report = Thinreports::Report.new layout: data_file('layout_text1')
13
+ parent = report.start_new_page
14
+
15
+ Basic::Interface.new parent, Basic::Format.new(format_config)
21
16
  end
22
-
17
+
23
18
  def test_id_should_return_id_with_reference_to_internal
24
19
  basic = create_interface('id' => 'foo')
25
20
  assert_equal basic.id, basic.internal.id
26
21
  end
27
-
22
+
28
23
  def test_id_should_return_cloned_id
29
24
  basic = create_interface('id' => 'basic-id')
30
25
  refute_same basic.id, basic.internal.id
31
26
  end
32
-
27
+
33
28
  def test_type_should_operate_as_delegator_of_internal
34
29
  basic = create_interface('type' => 's-rect')
35
30
  assert_same basic.type, basic.internal.type
36
31
  end
37
-
32
+
38
33
  def test_visible_asker_should_return_result_with_reference_to_style_of_internal
39
34
  basic = create_interface('display' => 'false')
40
35
  assert_equal basic.visible?, basic.internal.style.visible
41
36
  end
42
-
37
+
43
38
  def test_visible_should_properly_set_visibility_to_style_of_internal
44
39
  basic = create_interface('display' => 'false')
45
40
  basic.visible(true)
46
-
41
+
47
42
  assert_equal basic.internal.style.visible, true
48
43
  end
49
-
44
+
50
45
  def test_style_should_operate_as_reader_when_one_argument_is_given
51
46
  basic = create_interface('svg' => {'attrs' => {'fill' => '#ff0000'}})
52
-
47
+
53
48
  assert_equal basic.style(:fill_color), '#ff0000'
54
49
  end
55
-
50
+
56
51
  def test_style_should_operate_as_writer_when_two_arguments_are_given
57
52
  basic = create_interface
58
53
  basic.style(:border_color, '#000000')
59
-
54
+
60
55
  assert_equal basic.style(:border_color), '#000000'
61
56
  end
62
-
57
+
63
58
  def test_style_should_operate_as_writer_for_border_style_when_three_arguments_are_given
64
59
  basic = create_interface
65
60
  basic.style(:border, 1, '#ffffff')
66
-
61
+
67
62
  assert_equal basic.style(:border), [1, '#ffffff']
68
63
  end
69
-
64
+
70
65
  def test_style_should_return_self_when_two_arguments_are_given
71
66
  assert_instance_of Basic::Interface, create_interface.style(:border_width, 1)
72
67
  end
73
-
68
+
74
69
  def test_style_should_return_self_when_three_arguments_are_given
75
70
  assert_instance_of Basic::Interface, create_interface.style(:border, 1, '#000000')
76
71
  end
77
-
72
+
78
73
  def test_styles_should_properly_set_the_specified_styles_as_Hash
79
74
  basic = create_interface
80
- basic.styles(:fill_color => '#ff0000',
81
- :border_color => '#000000',
82
- :border_width => 5,
83
- :visible => false)
84
-
75
+ basic.styles(fill_color: '#ff0000',
76
+ border_color: '#000000',
77
+ border_width: 5,
78
+ visible: false)
79
+
85
80
  assert_equal [basic.style(:fill_color),
86
81
  basic.style(:border_color),
87
82
  basic.style(:border_width),
88
83
  basic.style(:visible)],
89
84
  ['#ff0000', '#000000', 5, false]
90
85
  end
91
-
92
- def test_styles_should_return_self
93
- basic = create_interface
94
- assert_instance_of Basic::Interface, basic.styles(:fill => '#ff0000')
95
- end
96
-
86
+
97
87
  def test_hide_should_properly_set_false_to_visibility
98
88
  basic = create_interface
99
89
  basic.hide
100
-
90
+
101
91
  assert_equal basic.visible?, false
102
92
  end
103
-
93
+
104
94
  def test_hide_should_return_self
105
95
  assert_instance_of Basic::Interface, create_interface.hide
106
96
  end
107
-
97
+
108
98
  def test_show_should_properly_set_true_to_visibility
109
99
  basic = create_interface
110
100
  basic.show
111
-
101
+
112
102
  assert_equal basic.visible?, true
113
103
  end
114
-
104
+
115
105
  def test_show_should_return_self
116
106
  assert_instance_of Basic::Interface, create_interface.show
117
107
  end
118
- end
108
+ end