thinreports 0.7.6 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -5
  3. data/.travis.yml +8 -4
  4. data/CHANGELOG.md +220 -0
  5. data/Gemfile +2 -9
  6. data/MIT-LICENSE +1 -1
  7. data/README.md +286 -0
  8. data/Rakefile +38 -8
  9. data/examples/character_spacing/character_spacing.rb +8 -0
  10. data/examples/character_spacing/character_spacing.tlf +1 -0
  11. data/examples/dynamic_image/dynamic_image.rb +31 -0
  12. data/examples/dynamic_image/dynamic_image.tlf +1 -0
  13. data/examples/dynamic_style/dynamic_style.rb +150 -0
  14. data/examples/dynamic_style/dynamic_style.tlf +1 -0
  15. data/examples/dynamic_style/dynamic_style_in_list.tlf +1 -0
  16. data/examples/eudc/eudc.rb +20 -0
  17. data/examples/eudc/eudc.tlf +1 -0
  18. data/examples/helper.rb +50 -0
  19. data/examples/hidden_shapes/hidden_shapes.rb +9 -0
  20. data/examples/hidden_shapes/hidden_shapes.tlf +1 -0
  21. data/examples/list_events/list_events.rb +59 -0
  22. data/examples/list_events/list_events_0_7_7.tlf +1 -0
  23. data/examples/list_events/list_events_0_8.tlf +1 -0
  24. data/examples/list_manual_generation/list_manual_generation.rb +22 -0
  25. data/examples/list_manual_generation/list_manual_generation.tlf +1 -0
  26. data/examples/list_page_number/list_page_number.rb +17 -0
  27. data/examples/list_page_number/list_page_number.tlf +1 -0
  28. data/examples/page_number/page_number.rb +33 -0
  29. data/examples/page_number/page_number.tlf +1 -0
  30. data/examples/password_setting/password_setting.rb +10 -0
  31. data/examples/password_setting/password_setting.tlf +1 -0
  32. data/examples/report_callbacks/report_callbacks.rb +31 -0
  33. data/examples/report_callbacks/report_callbacks.tlf +1 -0
  34. data/examples/single_line_tblock/single_line_tblock.rb +13 -0
  35. data/examples/single_line_tblock/single_line_tblock.tlf +1 -0
  36. data/examples/tblock_overflow/tblock_overflow.rb +20 -0
  37. data/examples/tblock_overflow/tblock_overflow.tlf +1 -0
  38. data/examples/tblock_styles/font_size.tlf +1 -0
  39. data/examples/tblock_styles/tblock_styles.rb +43 -0
  40. data/examples/tblock_styles/tblock_styles.tlf +1 -0
  41. data/examples/text_align/text_align.rb +8 -0
  42. data/examples/text_align/text_align.tlf +1 -0
  43. data/examples/typeB_page_size/B4_ISO.tlf +1 -0
  44. data/examples/typeB_page_size/B4_JIS.tlf +1 -0
  45. data/examples/typeB_page_size/typeB_page_size.rb +17 -0
  46. data/examples/word_wrap/word_wrap.rb +26 -0
  47. data/examples/word_wrap/word_wrap.tlf +1 -0
  48. data/lib/thinreports/config.rb +30 -10
  49. data/lib/thinreports/core/errors.rb +23 -20
  50. data/lib/thinreports/core/events.rb +18 -19
  51. data/lib/thinreports/core/format/base.rb +20 -25
  52. data/lib/thinreports/core/format/builder.rb +19 -27
  53. data/lib/thinreports/core/shape/base/interface.rb +15 -15
  54. data/lib/thinreports/core/shape/base/internal.rb +15 -20
  55. data/lib/thinreports/core/shape/base.rb +4 -5
  56. data/lib/thinreports/core/shape/basic/block_format.rb +3 -4
  57. data/lib/thinreports/core/shape/basic/block_interface.rb +9 -4
  58. data/lib/thinreports/core/shape/basic/block_internal.rb +9 -10
  59. data/lib/thinreports/core/shape/basic/format.rb +11 -10
  60. data/lib/thinreports/core/shape/basic/interface.rb +3 -3
  61. data/lib/thinreports/core/shape/basic/internal.rb +9 -6
  62. data/lib/thinreports/core/shape/basic.rb +1 -1
  63. data/lib/thinreports/core/shape/image_block/format.rb +5 -6
  64. data/lib/thinreports/core/shape/image_block/interface.rb +9 -7
  65. data/lib/thinreports/core/shape/image_block/internal.rb +5 -6
  66. data/lib/thinreports/core/shape/image_block.rb +1 -1
  67. data/lib/thinreports/core/shape/list/configuration.rb +37 -16
  68. data/lib/thinreports/core/shape/list/events.rb +11 -11
  69. data/lib/thinreports/core/shape/list/format.rb +27 -28
  70. data/lib/thinreports/core/shape/list/manager.rb +135 -95
  71. data/lib/thinreports/core/shape/list/page.rb +57 -51
  72. data/lib/thinreports/core/shape/list/page_state.rb +19 -17
  73. data/lib/thinreports/core/shape/list/section_format.rb +14 -15
  74. data/lib/thinreports/core/shape/list/section_interface.rb +15 -16
  75. data/lib/thinreports/core/shape/list/section_internal.rb +7 -8
  76. data/lib/thinreports/core/shape/list/store.rb +10 -11
  77. data/lib/thinreports/core/shape/list.rb +1 -1
  78. data/lib/thinreports/core/shape/manager/format.rb +10 -11
  79. data/lib/thinreports/core/shape/manager/internal.rb +22 -21
  80. data/lib/thinreports/core/shape/manager/target.rb +63 -34
  81. data/lib/thinreports/core/shape/manager.rb +1 -1
  82. data/lib/thinreports/core/shape/page_number/format.rb +25 -0
  83. data/lib/thinreports/core/shape/page_number/interface.rb +27 -0
  84. data/lib/thinreports/core/shape/page_number/internal.rb +57 -0
  85. data/lib/thinreports/core/shape/page_number.rb +15 -0
  86. data/lib/thinreports/core/shape/style/base.rb +29 -29
  87. data/lib/thinreports/core/shape/style/basic.rb +1 -1
  88. data/lib/thinreports/core/shape/style/graphic.rb +10 -25
  89. data/lib/thinreports/core/shape/style/text.rb +41 -31
  90. data/lib/thinreports/core/shape/style.rb +1 -1
  91. data/lib/thinreports/core/shape/text/format.rb +8 -9
  92. data/lib/thinreports/core/shape/text/interface.rb +2 -2
  93. data/lib/thinreports/core/shape/text/internal.rb +6 -7
  94. data/lib/thinreports/core/shape/text.rb +1 -1
  95. data/lib/thinreports/core/shape/text_block/format.rb +17 -17
  96. data/lib/thinreports/core/shape/text_block/formatter/basic.rb +13 -12
  97. data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +8 -9
  98. data/lib/thinreports/core/shape/text_block/formatter/number.rb +11 -12
  99. data/lib/thinreports/core/shape/text_block/formatter/padding.rb +9 -32
  100. data/lib/thinreports/core/shape/text_block/formatter.rb +7 -8
  101. data/lib/thinreports/core/shape/text_block/interface.rb +2 -2
  102. data/lib/thinreports/core/shape/text_block/internal.rb +19 -20
  103. data/lib/thinreports/core/shape/text_block.rb +1 -1
  104. data/lib/thinreports/core/shape.rb +11 -13
  105. data/lib/thinreports/core/utils.rb +33 -32
  106. data/lib/thinreports/generator/base.rb +15 -24
  107. data/lib/thinreports/generator/configuration.rb +10 -9
  108. data/lib/thinreports/generator/pdf/configuration.rb +11 -6
  109. data/lib/thinreports/generator/pdf/document/draw_shape.rb +41 -32
  110. data/lib/thinreports/generator/pdf/document/font.rb +53 -44
  111. data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +34 -25
  112. data/lib/thinreports/generator/pdf/document/graphics/basic.rb +25 -25
  113. data/lib/thinreports/generator/pdf/document/graphics/image.rb +15 -15
  114. data/lib/thinreports/generator/pdf/document/graphics/text.rb +43 -41
  115. data/lib/thinreports/generator/pdf/document/graphics.rb +8 -9
  116. data/lib/thinreports/generator/pdf/document/page.rb +37 -23
  117. data/lib/thinreports/generator/pdf/document/parse_color.rb +9 -10
  118. data/lib/thinreports/generator/pdf/document/parse_svg.rb +14 -15
  119. data/lib/thinreports/generator/pdf/document.rb +28 -28
  120. data/lib/thinreports/generator/pdf/drawer/base.rb +16 -22
  121. data/lib/thinreports/generator/pdf/drawer/list.rb +39 -21
  122. data/lib/thinreports/generator/pdf/drawer/list_section.rb +17 -18
  123. data/lib/thinreports/generator/pdf/drawer/page.rb +37 -26
  124. data/lib/thinreports/generator/pdf/prawn_ext.rb +18 -17
  125. data/lib/thinreports/generator/pdf.rb +28 -31
  126. data/lib/thinreports/generator.rb +6 -8
  127. data/lib/thinreports/layout/base.rb +24 -36
  128. data/lib/thinreports/layout/configuration.rb +11 -9
  129. data/lib/thinreports/layout/format.rb +26 -31
  130. data/lib/thinreports/layout/version.rb +8 -9
  131. data/lib/thinreports/layout.rb +2 -2
  132. data/lib/thinreports/report/base.rb +117 -109
  133. data/lib/thinreports/report/events.rb +5 -5
  134. data/lib/thinreports/report/internal.rb +48 -38
  135. data/lib/thinreports/{core → report}/page.rb +42 -32
  136. data/lib/thinreports/report.rb +10 -14
  137. data/lib/thinreports/version.rb +2 -3
  138. data/lib/thinreports.rb +14 -2
  139. data/test/data/font.ttf +0 -0
  140. data/test/data/layout_block.tlf +1 -0
  141. data/test/data/layout_list.tlf +1 -0
  142. data/test/data/layout_list_noheader.tlf +1 -0
  143. data/test/data/layout_text1.tlf +1 -0
  144. data/test/data/layout_text2.tlf +1 -0
  145. data/test/test_helper.rb +74 -0
  146. data/test/tmp/.gitkeep +0 -0
  147. data/test/unit/core/format/test_base.rb +14 -14
  148. data/test/unit/core/format/test_builder.rb +20 -25
  149. data/test/unit/core/shape/base/test_internal.rb +34 -37
  150. data/test/unit/core/shape/basic/test_basic_format.rb +4 -4
  151. data/test/unit/core/shape/basic/test_basic_interface.rb +15 -13
  152. data/test/unit/core/shape/basic/test_basic_internal.rb +19 -16
  153. data/test/unit/core/shape/basic/test_format.rb +4 -4
  154. data/test/unit/core/shape/basic/test_interface.rb +36 -46
  155. data/test/unit/core/shape/basic/test_internal.rb +29 -18
  156. data/test/unit/core/shape/image_block/test_format.rb +5 -5
  157. data/test/unit/core/shape/image_block/test_interface.rb +17 -16
  158. data/test/unit/core/shape/image_block/test_internal.rb +19 -16
  159. data/test/unit/core/shape/list/test_configuration.rb +50 -33
  160. data/test/unit/core/shape/list/test_events.rb +7 -7
  161. data/test/unit/core/shape/list/test_format.rb +16 -18
  162. data/test/unit/core/shape/list/test_manager.rb +15 -5
  163. data/test/unit/core/shape/list/test_page.rb +80 -22
  164. data/test/unit/core/shape/list/test_page_state.rb +13 -13
  165. data/test/unit/core/shape/list/test_section_format.rb +16 -17
  166. data/test/unit/core/shape/list/test_section_interface.rb +30 -22
  167. data/test/unit/core/shape/list/test_section_internal.rb +21 -19
  168. data/test/unit/core/shape/list/test_store.rb +7 -7
  169. data/test/unit/core/shape/manager/test_format.rb +11 -15
  170. data/test/unit/core/shape/manager/test_internal.rb +9 -9
  171. data/test/unit/core/shape/manager/test_target.rb +85 -57
  172. data/test/unit/core/shape/page_number/test_format.rb +73 -0
  173. data/test/unit/core/shape/page_number/test_interface.rb +33 -0
  174. data/test/unit/core/shape/page_number/test_internal.rb +81 -0
  175. data/test/unit/core/shape/styles/test_base.rb +9 -9
  176. data/test/unit/core/shape/styles/test_basic.rb +5 -5
  177. data/test/unit/core/shape/styles/test_graphic.rb +19 -33
  178. data/test/unit/core/shape/styles/test_text.rb +29 -7
  179. data/test/unit/core/shape/text/test_format.rb +6 -6
  180. data/test/unit/core/shape/text/test_internal.rb +11 -12
  181. data/test/unit/core/shape/text_block/formatter/test_basic.rb +16 -16
  182. data/test/unit/core/shape/text_block/formatter/test_datetime.rb +22 -20
  183. data/test/unit/core/shape/text_block/formatter/test_number.rb +34 -34
  184. data/test/unit/core/shape/text_block/formatter/test_padding.rb +44 -44
  185. data/test/unit/core/shape/text_block/test_format.rb +13 -8
  186. data/test/unit/core/shape/text_block/test_formatter.rb +17 -17
  187. data/test/unit/core/shape/text_block/test_interface.rb +37 -20
  188. data/test/unit/core/shape/text_block/test_internal.rb +38 -38
  189. data/test/unit/core/test_events.rb +10 -8
  190. data/test/unit/core/test_shape.rb +11 -7
  191. data/test/unit/core/test_utils.rb +68 -0
  192. data/test/unit/generator/pdf/document/graphics/test_attributes.rb +10 -4
  193. data/test/unit/generator/pdf/document/graphics/test_text.rb +60 -53
  194. data/test/unit/generator/pdf/document/test_draw_shape.rb +14 -6
  195. data/test/unit/generator/pdf/document/test_font.rb +79 -58
  196. data/test/unit/generator/pdf/document/test_graphics.rb +18 -19
  197. data/test/unit/generator/pdf/document/test_page.rb +68 -43
  198. data/test/unit/generator/pdf/document/test_parse_color.rb +5 -5
  199. data/test/unit/generator/pdf/test_configuration.rb +16 -9
  200. data/test/unit/generator/pdf/test_document.rb +8 -16
  201. data/test/unit/generator/test_base.rb +31 -42
  202. data/test/unit/generator/test_configuration.rb +6 -6
  203. data/test/unit/generator/test_pdf.rb +15 -21
  204. data/test/unit/layout/test_base.rb +34 -79
  205. data/test/unit/layout/test_configuration.rb +12 -37
  206. data/test/unit/layout/test_format.rb +36 -39
  207. data/test/unit/layout/test_version.rb +4 -4
  208. data/test/unit/report/test_base.rb +160 -192
  209. data/test/unit/report/test_events.rb +4 -4
  210. data/test/unit/report/test_internal.rb +102 -82
  211. data/test/unit/test_config.rb +31 -12
  212. data/test/unit/test_layout.rb +7 -7
  213. data/test/unit/test_report.rb +12 -24
  214. data/thinreports.gemspec +23 -26
  215. metadata +118 -181
  216. data/.yardopts +0 -1
  217. data/LICENSE +0 -1
  218. data/README.rdoc +0 -167
  219. data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
  220. data/lib/thinreports/core/ext/array.rb +0 -19
  221. data/lib/thinreports/core/ext/hash.rb +0 -19
  222. data/lib/thinreports/core/ext/object.rb +0 -25
  223. data/lib/thinreports/core/ext.rb +0 -5
  224. data/lib/thinreports/core/format.rb +0 -14
  225. data/lib/thinreports/core/ordered_hash.rb +0 -39
  226. data/lib/thinreports/core.rb +0 -20
  227. data/lib/thinreports/generator/pdf/drawer.rb +0 -16
  228. data/tasks/doc.rake +0 -13
  229. data/tasks/test.rake +0 -56
  230. data/test/benchmark/basic_estimate.tlf +0 -1
  231. data/test/benchmark/bench_basic_estimate.rb +0 -95
  232. data/test/case/character_spacing/character_spacing.rb +0 -7
  233. data/test/case/character_spacing/character_spacing.tlf +0 -1
  234. data/test/case/dynamic_image/dynamic_image.rb +0 -41
  235. data/test/case/dynamic_image/dynamic_image.tlf +0 -1
  236. data/test/case/dynamic_style/dynamic_style.rb +0 -154
  237. data/test/case/dynamic_style/dynamic_style.tlf +0 -1
  238. data/test/case/dynamic_style/dynamic_style_in_list.tlf +0 -1
  239. data/test/case/eudc/eudc.rb +0 -20
  240. data/test/case/eudc/eudc.tlf +0 -1
  241. data/test/case/helper.rb +0 -29
  242. data/test/case/hidden_shapes/hidden_shapes.rb +0 -13
  243. data/test/case/hidden_shapes/hidden_shapes.tlf +0 -1
  244. data/test/case/list_events/list_events.rb +0 -32
  245. data/test/case/list_events/list_events.tlf +0 -1
  246. data/test/case/list_header_inheriting/list_header_inheriting.rb +0 -17
  247. data/test/case/list_header_inheriting/list_header_inheriting.tlf +0 -1
  248. data/test/case/list_manual_generation/list_manual_generation.rb +0 -22
  249. data/test/case/list_manual_generation/list_manual_generation.tlf +0 -1
  250. data/test/case/single_line_tblock/single_line_tblock.rb +0 -15
  251. data/test/case/single_line_tblock/single_line_tblock.tlf +0 -1
  252. data/test/case/tblock_overflow/tblock_overflow.rb +0 -20
  253. data/test/case/tblock_overflow/tblock_overflow.tlf +0 -1
  254. data/test/case/tblock_styles/tblock_styles.rb +0 -27
  255. data/test/case/tblock_styles/tblock_styles.tlf +0 -1
  256. data/test/case/text_align/text_align.rb +0 -9
  257. data/test/case/text_align/text_align.tlf +0 -1
  258. data/test/unit/core/ext/array_spec.rb +0 -29
  259. data/test/unit/core/ext/hash_spec.rb +0 -29
  260. data/test/unit/core/ext/object_spec.rb +0 -30
  261. data/test/unit/core/ordered_hash_spec.rb +0 -51
  262. data/test/unit/core/shape/base/test_interface.rb +0 -52
  263. data/test/unit/core/utils_spec.rb +0 -56
  264. data/test/unit/data/basic_layout1.tlf +0 -1
  265. data/test/unit/data/basic_layout2.tlf +0 -1
  266. data/test/unit/data/basic_list_layout.tlf +0 -1
  267. data/test/unit/data/basic_list_noheader_layout.tlf +0 -1
  268. data/test/unit/helper.rb +0 -65
  269. /data/{test/case → examples}/dynamic_image/img200x100.png +0 -0
  270. /data/{test/case → examples}/dynamic_image/img50x50.png +0 -0
  271. /data/{test/case → examples}/dynamic_style/image.png +0 -0
  272. /data/{test/case → examples}/eudc/eudc.ttf +0 -0
  273. /data/{resources/fonts → fonts}/IPA_Font_License_Agreement_v1.0.txt +0 -0
  274. /data/{resources/fonts → fonts}/ipag.ttf +0 -0
  275. /data/{resources/fonts → fonts}/ipagp.ttf +0 -0
  276. /data/{resources/fonts → fonts}/ipam.ttf +0 -0
  277. /data/{resources/fonts → fonts}/ipamp.ttf +0 -0
@@ -1,10 +1,11 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Core::Shape
5
-
6
- # @private
5
+
7
6
  class Style::Base
7
+ include Utils
8
+
8
9
  class << self
9
10
  # @param [Symbol] style_method
10
11
  # @param [String] style
@@ -13,77 +14,76 @@ module ThinReports
13
14
  style_reader(style_method, style)
14
15
  style_writer(style_method, style)
15
16
  end
16
-
17
+
17
18
  # @see .style_accessor
18
19
  def style_reader(style_method, style)
19
20
  define_method(style_method) do
20
21
  read_internal_style(style)
21
22
  end
22
23
  end
23
-
24
+
24
25
  # @see .style_accessor
25
26
  def style_writer(style_method, style)
26
27
  define_method(:"#{style_method}=") do |value|
27
28
  write_internal_style(style, value)
28
29
  end
29
30
  end
30
-
31
+
31
32
  # @param [Array<Symbol>] style_methods
32
33
  def style_accessible(*style_methods)
33
34
  accessible_styles.concat(style_methods)
34
35
  end
35
-
36
+
36
37
  # @return [Array<Symbol>]
37
38
  def accessible_styles
38
39
  @accessible_styles ||= []
39
40
  end
40
-
41
- # @private
41
+
42
42
  def inherited(s)
43
43
  s.accessible_styles.concat(accessible_styles.dup)
44
44
  end
45
45
  end
46
-
46
+
47
47
  # @return [Hash]
48
48
  attr_accessor :styles
49
49
  # @see .accessible_styles
50
50
  attr_reader :accessible_styles
51
-
52
- # @param [ThinReports::Core::Format::Base] format
51
+
52
+ # @param [Thinreports::Core::Format::Base] format
53
53
  # @param [Hash] default_styles ({})
54
54
  def initialize(format, default_styles = {})
55
55
  @format = format
56
56
  @styles = default_styles
57
57
  @base_styles = format.svg_attrs || {}
58
-
58
+
59
59
  @accessible_styles = self.class.accessible_styles.dup
60
60
  @finalized_svg_attributes = nil
61
61
  end
62
-
62
+
63
63
  # @param [Symbol] style_method
64
64
  # @return [Object]
65
65
  def [](style_method)
66
66
  verify_style_method(style_method)
67
67
  send(style_method.to_sym)
68
68
  end
69
-
69
+
70
70
  # @param [Symbol] style_method
71
71
  # @param [String, Number, Array<String, Number>] value
72
72
  def []=(style_method, value)
73
73
  verify_style_method(style_method)
74
74
  send(:"#{style_method}=", value)
75
75
  end
76
-
76
+
77
77
  # @return [String]
78
78
  def identifier
79
79
  create_identifier(@styles)
80
80
  end
81
-
81
+
82
82
  # @return [self]
83
83
  def copy
84
- self.class.new(@format, @styles.empty? ? {} : @styles.simple_deep_copy)
84
+ self.class.new(@format, @styles.empty? ? {} : deep_copy(@styles))
85
85
  end
86
-
86
+
87
87
  # @return [Hash]
88
88
  def finalized_svg_attributes
89
89
  if @finalized_svg_attributes.nil?
@@ -96,44 +96,44 @@ module ThinReports
96
96
  @finalized_svg_attributes
97
97
  end
98
98
  alias_method :svg_attrs, :finalized_svg_attributes
99
-
99
+
100
100
  # @param [String, Symbol] style
101
101
  # @return [Object]
102
102
  def read_internal_style(style)
103
103
  style = style.to_s
104
104
  @styles.key?(style) ? @styles[style] : @base_styles[style]
105
105
  end
106
-
106
+
107
107
  # @param [String, Symbol] style
108
108
  # @param [Object] value
109
109
  def write_internal_style(style, value)
110
110
  @styles[style.to_s] = value
111
111
  end
112
-
112
+
113
113
  # @param [Symbol] style_method
114
114
  # @return [Boolean]
115
115
  def has_style?(style_method)
116
116
  accessible_styles.include?(style_method)
117
117
  end
118
-
118
+
119
119
  private
120
-
120
+
121
121
  # @param [Hash] s
122
122
  # @return [String]
123
123
  def create_identifier(s)
124
124
  s.empty? ? '' : s.hash.to_s
125
125
  end
126
-
126
+
127
127
  # @param [Symbol] style_method
128
128
  # @return [Boolean]
129
- # @raise ThinReports::Errors::UnknownShapeStyleName
129
+ # @raise Thinreports::Errors::UnknownShapeStyleName
130
130
  def verify_style_method(style_method)
131
131
  unless has_style?(style_method)
132
- raise ThinReports::Errors::UnknownShapeStyleName.new(style_method,
132
+ raise Thinreports::Errors::UnknownShapeStyleName.new(style_method,
133
133
  accessible_styles)
134
134
  end
135
135
  end
136
-
136
+
137
137
  # @param [Object] value
138
138
  # @param [Array<Object>] allows
139
139
  # @param [String] msg (nil)
@@ -144,6 +144,6 @@ module ThinReports
144
144
  end
145
145
  end
146
146
  end
147
-
147
+
148
148
  end
149
149
  end
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Core::Shape
5
5
 
6
6
  class Style::Basic < Style::Base
@@ -1,53 +1,38 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Core::Shape
5
-
5
+
6
6
  class Style::Graphic < Style::Basic
7
- style_accessible :border_color, :border_width, :fill_color, :border,
8
- :fill, :stroke
9
-
7
+ style_accessible :border_color, :border_width, :fill_color, :border
8
+
10
9
  # @method border_color
11
10
  # @return [String]
12
11
  # @method border_color=(color)
13
12
  # @param [String] color
14
13
  style_accessor :border_color, 'stroke'
15
-
14
+
16
15
  # @method border_width
17
16
  # @return [String, Number]
18
17
  style_reader :border_width, 'stroke-width'
19
-
18
+
20
19
  # @method fill_color
21
20
  # @return [String]
22
21
  # @method fill_color=(color)
23
22
  # @param [String] color
24
23
  style_accessor :fill_color, 'fill'
25
-
26
- # @method fill
27
- # @return [String]
28
- # @method fill=(color)
29
- # @param [String] color
30
- # @deprecated Please use the #fill_color method instead.
31
- style_accessor :fill, 'fill'
32
-
33
- # @method stroke
34
- # @return [String, Number]
35
- # @method stroke=(width)
36
- # @param [String, Number] width
37
- # @deprecated Please use the #stroke_width method instead.
38
- style_accessor :stroke, 'stroke-width'
39
-
24
+
40
25
  # @param [String, Number] width
41
26
  def border_width=(width)
42
27
  write_internal_style('stroke-opacity', '1') unless width.to_i.zero?
43
28
  write_internal_style('stroke-width', width)
44
29
  end
45
-
30
+
46
31
  # @return [Array<String, Number>]
47
32
  def border
48
33
  [self.border_width, self.border_color]
49
34
  end
50
-
35
+
51
36
  # @param [Array<String, Number>] width_and_color
52
37
  def border=(width_and_color)
53
38
  w, c = width_and_color
@@ -55,6 +40,6 @@ module ThinReports
55
40
  self.border_color = c
56
41
  end
57
42
  end
58
-
43
+
59
44
  end
60
45
  end
@@ -1,120 +1,130 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Core::Shape
5
-
5
+
6
6
  class Style::Text < Style::Basic
7
- TEXT_ALIGN_NAMES = {:left => 'start',
8
- :center => 'middle',
9
- :right => 'end'}
10
-
7
+ TEXT_ALIGN_NAMES = {left: 'start',
8
+ center: 'middle',
9
+ right: 'end'}
10
+
11
11
  style_accessible :bold, :italic, :underline, :linethrough,
12
- :align, :valign, :color
13
-
12
+ :align, :valign, :color, :font_size
13
+
14
14
  # @method color
15
15
  # @return [String]
16
16
  # @method color=(v)
17
17
  # @param [String] v
18
18
  style_accessor :color, 'fill'
19
-
19
+
20
+ # @method font_size
21
+ # @return [Numeric, String]
22
+ # @method font_size=(v)
23
+ # @param [Numeric, String]
24
+ style_accessor :font_size, 'font-size'
25
+
20
26
  def initialize(*args)
21
27
  super
22
28
  @valign = default_valign
23
29
  end
24
-
30
+
25
31
  def copy
26
32
  new_style = super
27
33
  new_style.valign = self.valign
28
34
  new_style
29
35
  end
30
-
36
+
31
37
  def identifier
32
38
  super + (@valign == default_valign ? '' : @valign.to_s)
33
39
  end
34
-
40
+
35
41
  # @return [Boolean]
36
42
  def bold
37
43
  read_internal_style('font-weight') == 'bold'
38
44
  end
39
-
45
+
40
46
  # @param [Boolean] enable
41
47
  def bold=(enable)
42
48
  write_internal_style('font-weight', enable ? 'bold' : 'normal')
43
49
  end
44
-
50
+
45
51
  # @return [Boolean]
46
52
  def italic
47
53
  read_internal_style('font-style') == 'italic'
48
54
  end
49
-
55
+
50
56
  # @param [Boolean] enable
51
57
  def italic=(enable)
52
58
  write_internal_style('font-style', enable ? 'italic' : 'normal')
53
59
  end
54
-
60
+
55
61
  # @return [Boolean]
56
62
  def underline
57
63
  read_internal_style('text-decoration').include?('underline')
58
64
  end
59
-
65
+
60
66
  # @param [Boolean] enable
61
67
  def underline=(enable)
62
68
  text_decoration(enable, linethrough)
63
69
  end
64
-
70
+
65
71
  # @return [Boolean]
66
72
  def linethrough
67
73
  read_internal_style('text-decoration').include?('line-through')
68
74
  end
69
-
75
+
70
76
  # @param [Boolean] enable
71
77
  def linethrough=(enable)
72
78
  text_decoration(underline, enable)
73
79
  end
74
-
80
+
75
81
  # @return [Symbol]
76
82
  def align
77
83
  interface_text_align(read_internal_style('text-anchor'))
78
84
  end
79
-
85
+
80
86
  # @param [:left, :center, :right] align_name
81
87
  def align=(align_name)
82
88
  verify_style_value(align_name, TEXT_ALIGN_NAMES.keys,
83
89
  'Only :left or :center, :right can be specified as align.')
84
90
  write_internal_style('text-anchor', internal_text_align(align_name))
85
91
  end
86
-
92
+
87
93
  # @return [Symbol]
88
94
  def valign
89
95
  @valign
90
96
  end
91
-
97
+
92
98
  # @param [:top, :center, :bottom] valign_name
93
99
  def valign=(valign_name)
94
100
  verify_style_value(valign_name, [:top, :center, :bottom],
95
101
  'Only :top or :center, :bottom can be specified as valign.')
96
102
  @valign = valign_name
97
103
  end
98
-
104
+
99
105
  private
100
-
101
- # @return [Symbol]
106
+
107
+ # @return [Symbol, nil]
102
108
  def default_valign
103
- @format.valign.blank? ? :top : @format.valign.to_sym
109
+ if accessible_styles.include?(:valign)
110
+ blank_value?(@format.valign) ? :top : @format.valign.to_sym
111
+ else
112
+ :top
113
+ end
104
114
  end
105
-
115
+
106
116
  # @param [Symbol] align The interface align name.
107
117
  # @return [String, nil]
108
118
  def internal_text_align(align)
109
119
  TEXT_ALIGN_NAMES[align]
110
120
  end
111
-
121
+
112
122
  # @param [String] align The internal align name.
113
123
  # @return [Symbol]
114
124
  def interface_text_align(align)
115
125
  TEXT_ALIGN_NAMES.invert[align] || :left
116
126
  end
117
-
127
+
118
128
  # @param [Boolean] u
119
129
  # @param [Boolean] s
120
130
  def text_decoration(u, s)
@@ -131,6 +141,6 @@ module ThinReports
131
141
  write_internal_style('text-decoration', deco)
132
142
  end
133
143
  end
134
-
144
+
135
145
  end
136
146
  end
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Core::Shape
5
5
 
6
6
  module Style
@@ -1,18 +1,17 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Core::Shape
5
-
6
- # @private
5
+
7
6
  class Text::Format < Basic::Format
8
7
  config_reader :text, :box, :valign
9
- config_reader :svg_content => %w( svg content ),
10
- :line_height => %w( line-height )
11
-
8
+ config_reader svg_content: %w( svg content ),
9
+ line_height: %w( line-height )
10
+
12
11
  class << self
13
12
  private
14
-
15
- # @see ThinReports::Core::Shape::Basic::Format#build_internal
13
+
14
+ # @see Thinreports::Core::Shape::Basic::Format#build_internal
16
15
  def build_internal(raw_format)
17
16
  new(raw_format) do |f|
18
17
  clean_with_attributes(f.svg_content)
@@ -20,6 +19,6 @@ module ThinReports
20
19
  end
21
20
  end
22
21
  end
23
-
22
+
24
23
  end
25
24
  end
@@ -1,12 +1,12 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Core::Shape
5
5
 
6
6
  class Text::Interface < Basic::Interface
7
7
  private
8
8
 
9
- # @see ThinReports::Core::Shape::Base::Interface#init_internal
9
+ # @see Thinreports::Core::Shape::Base::Interface#init_internal
10
10
  def init_internal(parent, format)
11
11
  Text::Internal.new(parent, format)
12
12
  end
@@ -1,21 +1,20 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Core::Shape
5
-
6
- # @private
5
+
7
6
  class Text::Internal < Basic::Internal
8
7
  # Delegate to Format's methods
9
8
  format_delegators :svg_content, :text, :box
10
-
9
+
11
10
  def style
12
11
  @style ||= Style::Text.new(format)
13
12
  end
14
-
13
+
15
14
  def type_of?(type_name)
16
15
  type_name == :text
17
16
  end
18
17
  end
19
-
18
+
20
19
  end
21
- end
20
+ end
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Core::Shape
5
5
 
6
6
  module Text
@@ -1,26 +1,26 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Core::Shape
5
-
6
- # @private
5
+
7
6
  class TextBlock::Format < Basic::BlockFormat
8
- config_reader :ref_id => %w( ref-id )
7
+ config_reader ref_id: %w( ref-id )
9
8
  config_reader :valign, :overflow
10
- config_reader :line_height => %w( line-height )
11
- config_reader :format_base => %w( format base ),
12
- :format_type => %w( format type ),
13
- :format_datetime_format => %w( format datetime format ),
14
- :format_number_delimiter => %w( format number delimiter ),
15
- :format_number_precision => %w( format number precision ),
16
- :format_padding_char => %w( format padding char ),
17
- :format_padding_dir => %w( format padding direction )
9
+ config_reader line_height: %w( line-height )
10
+ config_reader format_base: %w( format base ),
11
+ format_type: %w( format type ),
12
+ format_datetime_format: %w( format datetime format ),
13
+ format_number_delimiter: %w( format number delimiter ),
14
+ format_number_precision: %w( format number precision ),
15
+ format_padding_char: %w( format padding char ),
16
+ format_padding_dir: %w( format padding direction )
17
+ config_reader word_wrap: %w( word-wrap )
18
18
 
19
19
  config_checker 'true', :multiple
20
- config_checker 'R', :format_padding_rdir => %w( format padding direction )
20
+ config_checker 'R', format_padding_rdir: %w( format padding direction )
21
21
 
22
- config_reader :format_padding_length => %w( format padding length ) do |len|
23
- len.blank? ? 0 : len.to_i
22
+ config_reader format_padding_length: %w( format padding length ) do |len|
23
+ blank_value?(len) ? 0 : len.to_i
24
24
  end
25
25
 
26
26
  config_reader :has_format? => %w( format type ) do |type|
@@ -28,9 +28,9 @@ module ThinReports
28
28
  end
29
29
 
30
30
  config_reader :has_reference? => %w( ref-id ) do |ref_id|
31
- !ref_id.blank?
31
+ !blank_value?(ref_id)
32
32
  end
33
33
  end
34
-
34
+
35
35
  end
36
36
  end
@@ -1,38 +1,39 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Core::Shape::TextBlock
5
-
6
- # @private
5
+
7
6
  class Formatter::Basic
7
+ include Utils
8
+
8
9
  attr_reader :format
9
-
10
+
10
11
  def initialize(format)
11
12
  @format = format
12
13
  end
13
-
14
+
14
15
  def apply(value)
15
16
  if applicable?(value)
16
17
  value = apply_format_to(value)
17
18
  end
18
-
19
- unless format.format_base.blank?
19
+
20
+ unless blank_value?(format.format_base)
20
21
  format.format_base.gsub(/\{value\}/, value.to_s)
21
22
  else
22
23
  value
23
24
  end
24
25
  end
25
-
26
+
26
27
  private
27
-
28
+
28
29
  def apply_format_to(value)
29
30
  value
30
31
  end
31
-
32
+
32
33
  def applicable?(value)
33
34
  true
34
35
  end
35
36
  end
36
-
37
+
37
38
  end
38
- end
39
+ end
@@ -1,21 +1,20 @@
1
1
  # coding: utf-8
2
2
 
3
- module ThinReports
3
+ module Thinreports
4
4
  module Core::Shape::TextBlock
5
-
6
- # @private
5
+
7
6
  class Formatter::Datetime < Formatter::Basic
8
-
7
+
9
8
  private
10
-
9
+
11
10
  def apply_format_to(value)
12
11
  value.strftime(format.format_datetime_format)
13
12
  end
14
-
13
+
15
14
  def applicable?(value)
16
- !format.format_datetime_format.blank? && value.respond_to?(:strftime)
15
+ !blank_value?(format.format_datetime_format) && value.respond_to?(:strftime)
17
16
  end
18
17
  end
19
-
18
+
20
19
  end
21
- end
20
+ end