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,49 +1,48 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Generator::PDF::Drawer
5
-
5
+
6
6
  # @abstract
7
- # @private
8
7
  class Base
9
- # @param [ThinReports::Generator::PDF::Document] pdf
10
- # @param [ThinReports::Core::Shape::Manager::Format] format
8
+ # @param [Thinreports::Generator::PDF::Document] pdf
9
+ # @param [Thinreports::Core::Shape::Manager::Format] format
11
10
  def initialize(pdf, format)
12
11
  @pdf = pdf
13
12
  @format = format
14
13
  @stamps = []
15
14
  @draw_at = nil
16
15
  end
17
-
16
+
18
17
  # @abstract
19
18
  def draw
20
19
  raise NotImplementedError
21
20
  end
22
-
21
+
23
22
  private
24
-
25
- # @param [ThinReports::Core::Shape::Base::Internal] shape
23
+
24
+ # @param [Thinreports::Core::Shape::Base::Internal] shape
26
25
  # @return [String]
27
26
  def pdf_stamp_id(shape)
28
27
  "#{@format.identifier}#{shape.identifier}"
29
28
  end
30
-
29
+
31
30
  # @overload pdf_stamp(shape_id)
32
31
  # @param [String] shape_id
33
32
  # @overload pdf_stamp(shape)
34
- # @param [ThinReports::Core::Shape::Base::Internal] shape
33
+ # @param [Thinreports::Core::Shape::Base::Internal] shape
35
34
  def pdf_stamp(shape)
36
35
  unless shape.is_a?(::String)
37
36
  shape = pdf_stamp_id(shape)
38
37
  end
39
38
  @pdf.stamp(shape, @draw_at)
40
39
  end
41
-
42
- # @param [ThinReports::Core::Shape::Base::Internal] shape
40
+
41
+ # @param [Thinreports::Core::Shape::Base::Internal] shape
43
42
  def create_pdf_stamp(shape, &block)
44
43
  @pdf.create_stamp(pdf_stamp_id(shape), &block)
45
44
  end
46
45
  end
47
-
46
+
48
47
  end
49
48
  end
@@ -1,24 +1,23 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Generator::PDF::Drawer
5
-
6
- # @private
5
+
7
6
  class List < Base
8
7
  # @param (see PDF::Drawer::Base#initialize)
9
8
  def initialize(pdf, format)
10
9
  super
11
10
  @sections = {}
12
11
  end
13
-
14
- # @param [ThinReports::Core::Shape::List::PageState] list_page
12
+
13
+ # @param [Thinreports::Core::Shape::List::PageState] list_page
15
14
  def draw(list_page)
16
15
  draw_section(list_page.header) if list_page.header
17
16
  list_page.rows.each do |row|
18
17
  draw_section(row)
19
18
  end
20
19
 
21
- # Returns ThinReports::Core::Page object
20
+ # Returns Thinreports::Report::Page object
22
21
  manager = list_page.parent.manager
23
22
 
24
23
  list_id = list_page.id.to_s
@@ -26,7 +25,7 @@ module ThinReports
26
25
  next unless list_pageno?(list_id, shape)
27
26
 
28
27
  shape = manager.final_shape(id)
29
- @pdf.draw_shape_pageno(shape.internal,
28
+ @pdf.draw_shape_pageno(shape.internal,
30
29
  list_page.no, list_page.manager.page_count)
31
30
  end
32
31
  end
@@ -34,25 +33,25 @@ module ThinReports
34
33
  private
35
34
 
36
35
  # @param [String] list_id
37
- # @param [ThinReports::Core::Shape::Base::Format] shape
36
+ # @param [Thinreports::Core::Shape::Base::Format] shape
38
37
  # @return [Boolean]
39
38
  def list_pageno?(list_id, shape)
40
- shape.type == ThinReports::Core::Shape::PageNumber::TYPE_NAME &&
39
+ shape.type == Thinreports::Core::Shape::PageNumber::TYPE_NAME &&
41
40
  shape.target == list_id
42
41
  end
43
42
 
44
- # @param [ThinReports::Core::Shape::List::SectionInterface] section
43
+ # @param [Thinreports::Core::Shape::List::SectionInterface] section
45
44
  def draw_section(section)
46
45
  internal = section.internal
47
46
  drawer(internal).draw(section, internal.relative_position)
48
47
  end
49
-
50
- # @param [ThinReports::Core::Shape::List::SectionInternal] section
51
- # @return [ThinReports::Generator::PDF::Drawer::ListSection]
48
+
49
+ # @param [Thinreports::Core::Shape::List::SectionInternal] section
50
+ # @return [Thinreports::Generator::PDF::Drawer::ListSection]
52
51
  def drawer(section)
53
52
  @sections[section.section_name] ||= ListSection.new(@pdf, section)
54
53
  end
55
54
  end
56
-
55
+
57
56
  end
58
57
  end
@@ -1,31 +1,30 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Generator::PDF::Drawer
5
-
6
- # @private
5
+
7
6
  class ListSection < Page
8
7
  # @param pdf (see PDF::Drawer::Page#initialize)
9
- # @param section [ThinReports::Core::Shape::List::SectionInternal] section
8
+ # @param section [Thinreports::Core::Shape::List::SectionInternal] section
10
9
  def initialize(pdf, section)
11
10
  super(pdf, section.format)
12
11
  @section = section
13
12
  @stamp_created = false
14
13
  end
15
-
16
- # @param [ThinReports::Core::Shape::List::SectionInternal] section
14
+
15
+ # @param [Thinreports::Core::Shape::List::SectionInternal] section
17
16
  # @param [Array<Numeric>] at
18
17
  def draw(section, at)
19
18
  @draw_at = at
20
19
  draw_section
21
20
  super(section)
22
21
  end
23
-
22
+
24
23
  private
25
-
24
+
26
25
  def draw_section
27
26
  id = @format.identifier.to_s
28
-
27
+
29
28
  unless @stamp_created
30
29
  @pdf.create_stamp(id) do
31
30
  @pdf.parse_svg('<svg xmlns:xlink="http://www.w3.org/1999/xlink">' +
@@ -35,17 +34,17 @@ module ThinReports
35
34
  end
36
35
  pdf_stamp(id)
37
36
  end
38
-
39
- # @see ThinReports::Generator::PDF::Drawer::Page#draw_tblock_shape
37
+
38
+ # @see Thinreports::Generator::PDF::Drawer::Page#draw_tblock_shape
40
39
  def draw_tblock_shape(shape)
41
40
  @pdf.translate(*@draw_at) { super }
42
41
  end
43
-
44
- # @see ThinReports::Generator::PDF::Drawer::Page#draw_iblock_shape
42
+
43
+ # @see Thinreports::Generator::PDF::Drawer::Page#draw_iblock_shape
45
44
  def draw_iblock_shape(shape)
46
45
  @pdf.translate(*@draw_at) { super }
47
46
  end
48
47
  end
49
-
48
+
50
49
  end
51
50
  end
@@ -1,17 +1,16 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Generator::PDF::Drawer
5
-
6
- # @private
5
+
7
6
  class Page < Base
8
7
  # @param (see PDF::Drawer::Base#initialize)
9
8
  def initialize(pdf, format)
10
9
  super
11
10
  @lists = {}
12
11
  end
13
-
14
- # @param [ThinReports::Core::Page] page
12
+
13
+ # @param [Thinreports::Report::Page] page
15
14
  def draw(page)
16
15
  manager = page.manager
17
16
 
@@ -28,7 +27,7 @@ module ThinReports
28
27
  end
29
28
  end
30
29
  end
31
-
30
+
32
31
  private
33
32
 
34
33
  def draw_shape(shape)
@@ -48,7 +47,7 @@ module ThinReports
48
47
  pdf_stamp(shape)
49
48
  end
50
49
  end
51
-
50
+
52
51
  def draw_pageno_shape(shape, page)
53
52
  @pdf.draw_shape_pageno(shape, page.no, page.report.page_count)
54
53
  end
@@ -58,18 +57,18 @@ module ThinReports
58
57
  drawer = @lists[shape.id] ||= List.new(@pdf, shape.format)
59
58
  drawer.draw(shape)
60
59
  end
61
-
60
+
62
61
  # @see #draw_shape
63
62
  def draw_tblock_shape(shape)
64
63
  @pdf.draw_shape_tblock(shape)
65
64
  end
66
-
65
+
67
66
  # @see #draw_shape
68
67
  def draw_iblock_shape(shape)
69
68
  @pdf.draw_shape_iblock(shape)
70
69
  end
71
-
72
- # @param [ThinReports::Core::Shape::Base::Internal] shape
70
+
71
+ # @param [Thinreports::Core::Shape::Base::Internal] shape
73
72
  def create_basic_shape_stamp(shape)
74
73
  case
75
74
  when shape.type_of?(:text) then create_text_stamp(shape)
@@ -79,35 +78,35 @@ module ThinReports
79
78
  when shape.type_of?(:line) then create_line_stamp(shape)
80
79
  end
81
80
  end
82
-
81
+
83
82
  # @see #create_basic_shape_stamp
84
83
  def create_image_stamp(shape)
85
84
  create_pdf_stamp(shape) do
86
85
  @pdf.draw_shape_image(shape)
87
86
  end
88
87
  end
89
-
88
+
90
89
  # @see #create_basic_shape_stamp
91
90
  def create_rect_stamp(shape)
92
91
  create_pdf_stamp(shape) do
93
92
  @pdf.draw_shape_rect(shape)
94
93
  end
95
94
  end
96
-
95
+
97
96
  # @see #create_basic_shape_stamp
98
97
  def create_ellipse_stamp(shape)
99
98
  create_pdf_stamp(shape) do
100
99
  @pdf.draw_shape_ellipse(shape)
101
100
  end
102
101
  end
103
-
102
+
104
103
  # @see #create_basic_shape_stamp
105
104
  def create_line_stamp(shape)
106
105
  create_pdf_stamp(shape) do
107
106
  @pdf.draw_shape_line(shape)
108
107
  end
109
108
  end
110
-
109
+
111
110
  # @see #create_basic_shape_stamp
112
111
  def create_text_stamp(shape)
113
112
  create_pdf_stamp(shape) do
@@ -115,6 +114,6 @@ module ThinReports
115
114
  end
116
115
  end
117
116
  end
118
-
117
+
119
118
  end
120
119
  end
@@ -1,47 +1,31 @@
1
1
  # coding: utf-8
2
2
 
3
- # @private
4
3
  module Prawn
5
4
  class Document
6
- # Create around alias.
7
5
  alias_method :original_width_of, :width_of
8
-
6
+
9
7
  def width_of(string, options={})
10
8
  font.compute_width_of(string, options) +
11
9
  (character_spacing * (font.character_count(string) - 1))
12
10
  end
13
-
14
- private
15
- # Create around alias.
16
- alias_method :original_calc_image_dimensions, :calc_image_dimensions
17
-
18
- def calc_image_dimensions(info, options)
19
- if options[:auto_fit]
20
- w, h = info.width, info.height
21
- sw, sh = options.delete(:auto_fit)
22
-
23
- if w > sw || h > sh
24
- options[:fit] = [sw, sh]
25
- end
26
- end
27
- original_calc_image_dimensions(info, options)
28
- end
29
11
  end
30
12
 
31
- # Patch: https://github.com/prawnpdf/prawn/commit/34039d13b7886692debca11e85b9a572a20d57ee
32
- module Core
33
- class Reference
34
- def <<(data)
35
- (@stream ||= "") << data
36
- @data[:Length] = @stream.length
37
- @stream
38
- end
39
-
40
- def compress_stream
41
- @stream = Zlib::Deflate.deflate(@stream)
42
- @data[:Filter] = :FlateDecode
43
- @data[:Length] = @stream.length
44
- @compressed = true
13
+ module Images
14
+ class Image
15
+ alias_method :original_calc_image_dimensions, :calc_image_dimensions
16
+
17
+ def calc_image_dimensions(options)
18
+ if options[:auto_fit]
19
+ w = options[:width] || width
20
+ h = options[:height] || height
21
+
22
+ box_width, box_height = options.delete(:auto_fit)
23
+
24
+ if w > box_width || h > box_height
25
+ options[:fit] = [box_width, box_height]
26
+ end
27
+ end
28
+ original_calc_image_dimensions(options)
45
29
  end
46
30
  end
47
31
  end
@@ -1,9 +1,9 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
 
5
5
  module Layout
6
- # @see ThinReports::Layout::Base#initialize
6
+ # @see Thinreports::Layout::Base#initialize
7
7
  def self.new(filename, options = {})
8
8
  Base.new(filename, options)
9
9
  end
@@ -1,49 +1,36 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Layout
5
-
5
+
6
6
  class Base
7
7
  EXT_NAME = 'tlf'
8
-
8
+ include Utils
9
+
9
10
  class << self
10
11
  # @param [String] filename
11
- # @return [ThinReports::Layout::Format]
12
- # @raise [ThinReports::Errors::InvalidLayoutFormat]
13
- # @raise [ThinReports::Errors::IncompatibleLayoutFormat]
14
- # @private
12
+ # @return [Thinreports::Layout::Format]
13
+ # @raise [Thinreports::Errors::InvalidLayoutFormat]
14
+ # @raise [Thinreports::Errors::IncompatibleLayoutFormat]
15
15
  def load_format(filename)
16
16
  filename += ".#{EXT_NAME}" unless filename =~/\.#{EXT_NAME}$/
17
-
17
+
18
18
  unless File.exists?(filename)
19
- raise ThinReports::Errors::LayoutFileNotFound
19
+ raise Thinreports::Errors::LayoutFileNotFound
20
20
  end
21
21
  # Build format.
22
- ThinReports::Layout::Format.build(filename)
23
- end
24
-
25
- # @private
26
- def Page
27
- const_defined?(:Page) ? Page : Core::Page
28
- end
29
-
30
- private
31
-
32
- # @private
33
- def PageHelpers(&block)
34
- const_set(:Page, ::Class.new(Core::Page, &block))
22
+ Thinreports::Layout::Format.build(filename)
35
23
  end
36
24
  end
37
-
38
- # @private
25
+
39
26
  attr_reader :format
40
-
27
+
41
28
  # @return [String]
42
29
  attr_reader :filename
43
-
30
+
44
31
  # @return [Symbol]
45
32
  attr_reader :id
46
-
33
+
47
34
  # @param [String] filename
48
35
  # @param [Hash] options
49
36
  # @option options [Symbol] :id (nil)
@@ -52,29 +39,28 @@ module ThinReports
52
39
  @format = self.class.load_format(filename)
53
40
  @id = options[:id]
54
41
  end
55
-
42
+
56
43
  # @return [Boolean] Return the true if is default layout.
57
44
  def default?
58
45
  @id.nil?
59
46
  end
60
-
47
+
61
48
  # @yield [config]
62
49
  # @yieldparam [List::Configuration] config
63
50
  # @return [List::Configuration]
64
51
  def config(&block)
65
52
  @config ||= Layout::Configuration.new(self)
66
- block_exec_on(@config, &block)
53
+ call_block_in(@config, &block)
67
54
  end
68
-
69
- # @param [ThinReports::Report::Base] parent
55
+
56
+ # @param [Thinreports::Report::Base] parent
70
57
  # @param [Hash] options ({})
71
58
  # @option option [Boolean] :count (true)
72
59
  # @return [Page]
73
- # @private
74
- def init_new_page(parent, options = {})
75
- self.class.Page.new(parent, self, options)
60
+ def new_page(parent, options = {})
61
+ Report::Page.new(parent, self, options)
76
62
  end
77
63
  end
78
-
64
+
79
65
  end
80
66
  end