thinreports 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +11 -0
  3. data/.github/workflows/test.yml +31 -40
  4. data/.gitignore +1 -1
  5. data/CHANGELOG.md +25 -1
  6. data/Gemfile +11 -0
  7. data/{MIT-LICENSE → LICENSE.txt} +2 -0
  8. data/README.md +50 -66
  9. data/Rakefile +17 -11
  10. data/lib/thinreports/basic_report/core/errors.rb +62 -0
  11. data/lib/thinreports/basic_report/core/format/base.rb +91 -0
  12. data/lib/thinreports/basic_report/core/shape/base/interface.rb +42 -0
  13. data/lib/thinreports/basic_report/core/shape/base/internal.rb +53 -0
  14. data/lib/thinreports/basic_report/core/shape/basic/block_format.rb +15 -0
  15. data/lib/thinreports/basic_report/core/shape/basic/block_interface.rb +34 -0
  16. data/lib/thinreports/basic_report/core/shape/basic/block_internal.rb +36 -0
  17. data/lib/thinreports/basic_report/core/shape/basic/format.rb +24 -0
  18. data/lib/thinreports/basic_report/core/shape/basic/interface.rb +87 -0
  19. data/lib/thinreports/basic_report/core/shape/basic/internal.rb +28 -0
  20. data/lib/thinreports/{core → basic_report/core}/shape/basic.rb +6 -4
  21. data/lib/thinreports/basic_report/core/shape/image_block/format.rb +14 -0
  22. data/lib/thinreports/basic_report/core/shape/image_block/interface.rb +25 -0
  23. data/lib/thinreports/basic_report/core/shape/image_block/internal.rb +19 -0
  24. data/lib/thinreports/{core → basic_report/core}/shape/image_block.rb +6 -4
  25. data/lib/thinreports/basic_report/core/shape/list/format.rb +92 -0
  26. data/lib/thinreports/basic_report/core/shape/list/manager.rb +231 -0
  27. data/lib/thinreports/basic_report/core/shape/list/page.rb +112 -0
  28. data/lib/thinreports/basic_report/core/shape/list/page_state.rb +50 -0
  29. data/lib/thinreports/basic_report/core/shape/list/section_format.rb +37 -0
  30. data/lib/thinreports/basic_report/core/shape/list/section_interface.rb +51 -0
  31. data/lib/thinreports/basic_report/core/shape/list/section_internal.rb +33 -0
  32. data/lib/thinreports/{core → basic_report/core}/shape/list.rb +6 -4
  33. data/lib/thinreports/basic_report/core/shape/manager/format.rb +33 -0
  34. data/lib/thinreports/basic_report/core/shape/manager/internal.rb +109 -0
  35. data/lib/thinreports/basic_report/core/shape/manager/target.rb +114 -0
  36. data/lib/thinreports/basic_report/core/shape/page_number/format.rb +32 -0
  37. data/lib/thinreports/basic_report/core/shape/page_number/interface.rb +31 -0
  38. data/lib/thinreports/basic_report/core/shape/page_number/internal.rb +57 -0
  39. data/lib/thinreports/{core → basic_report/core}/shape/page_number.rb +6 -4
  40. data/lib/thinreports/basic_report/core/shape/stack_view/format.rb +29 -0
  41. data/lib/thinreports/basic_report/core/shape/stack_view/interface.rb +19 -0
  42. data/lib/thinreports/basic_report/core/shape/stack_view/internal.rb +24 -0
  43. data/lib/thinreports/basic_report/core/shape/stack_view/row_format.rb +41 -0
  44. data/lib/thinreports/{core → basic_report/core}/shape/stack_view.rb +6 -4
  45. data/lib/thinreports/basic_report/core/shape/style/base.rb +149 -0
  46. data/lib/thinreports/basic_report/core/shape/style/basic.rb +24 -0
  47. data/lib/thinreports/basic_report/core/shape/style/graphic.rb +43 -0
  48. data/lib/thinreports/basic_report/core/shape/style/text.rb +122 -0
  49. data/lib/thinreports/basic_report/core/shape/text/format.rb +17 -0
  50. data/lib/thinreports/basic_report/core/shape/text/interface.rb +20 -0
  51. data/lib/thinreports/basic_report/core/shape/text/internal.rb +24 -0
  52. data/lib/thinreports/{core → basic_report/core}/shape/text.rb +6 -4
  53. data/lib/thinreports/basic_report/core/shape/text_block/format.rb +43 -0
  54. data/lib/thinreports/basic_report/core/shape/text_block/formatter/basic.rb +41 -0
  55. data/lib/thinreports/basic_report/core/shape/text_block/formatter/datetime.rb +25 -0
  56. data/lib/thinreports/basic_report/core/shape/text_block/formatter/number.rb +69 -0
  57. data/lib/thinreports/basic_report/core/shape/text_block/formatter/padding.rb +27 -0
  58. data/lib/thinreports/basic_report/core/shape/text_block/formatter.rb +38 -0
  59. data/lib/thinreports/basic_report/core/shape/text_block/interface.rb +37 -0
  60. data/lib/thinreports/basic_report/core/shape/text_block/internal.rb +75 -0
  61. data/lib/thinreports/{core → basic_report/core}/shape/text_block.rb +6 -4
  62. data/lib/thinreports/basic_report/core/shape.rb +44 -0
  63. data/lib/thinreports/basic_report/core/utils.rb +47 -0
  64. data/lib/thinreports/basic_report/generator/pdf/document/draw_shape.rb +108 -0
  65. data/lib/thinreports/basic_report/generator/pdf/document/draw_template_items.rb +71 -0
  66. data/lib/thinreports/basic_report/generator/pdf/document/font.rb +90 -0
  67. data/lib/thinreports/basic_report/generator/pdf/document/graphics/attributes.rb +149 -0
  68. data/lib/thinreports/basic_report/generator/pdf/document/graphics/basic.rb +137 -0
  69. data/lib/thinreports/basic_report/generator/pdf/document/graphics/image.rb +99 -0
  70. data/lib/thinreports/basic_report/generator/pdf/document/graphics/text.rb +180 -0
  71. data/lib/thinreports/basic_report/generator/pdf/document/graphics.rb +42 -0
  72. data/lib/thinreports/basic_report/generator/pdf/document/page.rb +96 -0
  73. data/lib/thinreports/basic_report/generator/pdf/document/parse_color.rb +51 -0
  74. data/lib/thinreports/basic_report/generator/pdf/document.rb +132 -0
  75. data/lib/thinreports/basic_report/generator/pdf/drawer/base.rb +50 -0
  76. data/lib/thinreports/basic_report/generator/pdf/drawer/list.rb +65 -0
  77. data/lib/thinreports/basic_report/generator/pdf/drawer/list_section.rb +51 -0
  78. data/lib/thinreports/basic_report/generator/pdf/drawer/page.rb +127 -0
  79. data/lib/thinreports/basic_report/generator/pdf/prawn_ext/calc_image_dimensions.rb +34 -0
  80. data/lib/thinreports/basic_report/generator/pdf/prawn_ext/width_of.rb +31 -0
  81. data/lib/thinreports/basic_report/generator/pdf.rb +66 -0
  82. data/lib/thinreports/basic_report/layout/base.rb +48 -0
  83. data/lib/thinreports/basic_report/layout/format.rb +67 -0
  84. data/lib/thinreports/basic_report/layout/legacy_schema.rb +383 -0
  85. data/lib/thinreports/basic_report/layout/version.rb +41 -0
  86. data/lib/thinreports/{layout.rb → basic_report/layout.rb} +6 -4
  87. data/lib/thinreports/basic_report/report/base.rb +173 -0
  88. data/lib/thinreports/basic_report/report/internal.rb +107 -0
  89. data/lib/thinreports/basic_report/report/page.rb +97 -0
  90. data/lib/thinreports/basic_report/report.rb +26 -0
  91. data/lib/thinreports/basic_report.rb +15 -0
  92. data/lib/thinreports/config.rb +1 -1
  93. data/lib/thinreports/section_report/builder/stack_view_builder.rb +0 -2
  94. data/lib/thinreports/section_report.rb +12 -0
  95. data/lib/thinreports/version.rb +1 -1
  96. data/lib/thinreports.rb +2 -13
  97. data/thinreports.gemspec +3 -7
  98. metadata +99 -157
  99. data/Dockerfile +0 -12
  100. data/gemfiles/prawn-2.2.gemfile +0 -5
  101. data/gemfiles/prawn-2.3.gemfile +0 -5
  102. data/gemfiles/prawn-2.4.gemfile +0 -5
  103. data/lib/thinreports/core/errors.rb +0 -60
  104. data/lib/thinreports/core/format/base.rb +0 -89
  105. data/lib/thinreports/core/shape/base/interface.rb +0 -40
  106. data/lib/thinreports/core/shape/base/internal.rb +0 -51
  107. data/lib/thinreports/core/shape/basic/block_format.rb +0 -13
  108. data/lib/thinreports/core/shape/basic/block_interface.rb +0 -32
  109. data/lib/thinreports/core/shape/basic/block_internal.rb +0 -34
  110. data/lib/thinreports/core/shape/basic/format.rb +0 -22
  111. data/lib/thinreports/core/shape/basic/interface.rb +0 -85
  112. data/lib/thinreports/core/shape/basic/internal.rb +0 -26
  113. data/lib/thinreports/core/shape/image_block/format.rb +0 -12
  114. data/lib/thinreports/core/shape/image_block/interface.rb +0 -23
  115. data/lib/thinreports/core/shape/image_block/internal.rb +0 -17
  116. data/lib/thinreports/core/shape/list/format.rb +0 -90
  117. data/lib/thinreports/core/shape/list/manager.rb +0 -229
  118. data/lib/thinreports/core/shape/list/page.rb +0 -110
  119. data/lib/thinreports/core/shape/list/page_state.rb +0 -48
  120. data/lib/thinreports/core/shape/list/section_format.rb +0 -35
  121. data/lib/thinreports/core/shape/list/section_interface.rb +0 -49
  122. data/lib/thinreports/core/shape/list/section_internal.rb +0 -31
  123. data/lib/thinreports/core/shape/manager/format.rb +0 -31
  124. data/lib/thinreports/core/shape/manager/internal.rb +0 -107
  125. data/lib/thinreports/core/shape/manager/target.rb +0 -112
  126. data/lib/thinreports/core/shape/page_number/format.rb +0 -30
  127. data/lib/thinreports/core/shape/page_number/interface.rb +0 -29
  128. data/lib/thinreports/core/shape/page_number/internal.rb +0 -55
  129. data/lib/thinreports/core/shape/stack_view/format.rb +0 -27
  130. data/lib/thinreports/core/shape/stack_view/interface.rb +0 -17
  131. data/lib/thinreports/core/shape/stack_view/internal.rb +0 -22
  132. data/lib/thinreports/core/shape/stack_view/row_format.rb +0 -39
  133. data/lib/thinreports/core/shape/style/base.rb +0 -146
  134. data/lib/thinreports/core/shape/style/basic.rb +0 -22
  135. data/lib/thinreports/core/shape/style/graphic.rb +0 -41
  136. data/lib/thinreports/core/shape/style/text.rb +0 -120
  137. data/lib/thinreports/core/shape/text/format.rb +0 -15
  138. data/lib/thinreports/core/shape/text/interface.rb +0 -18
  139. data/lib/thinreports/core/shape/text/internal.rb +0 -22
  140. data/lib/thinreports/core/shape/text_block/format.rb +0 -41
  141. data/lib/thinreports/core/shape/text_block/formatter/basic.rb +0 -39
  142. data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +0 -23
  143. data/lib/thinreports/core/shape/text_block/formatter/number.rb +0 -67
  144. data/lib/thinreports/core/shape/text_block/formatter/padding.rb +0 -25
  145. data/lib/thinreports/core/shape/text_block/formatter.rb +0 -34
  146. data/lib/thinreports/core/shape/text_block/interface.rb +0 -35
  147. data/lib/thinreports/core/shape/text_block/internal.rb +0 -73
  148. data/lib/thinreports/core/shape.rb +0 -42
  149. data/lib/thinreports/core/utils.rb +0 -45
  150. data/lib/thinreports/generate.rb +0 -11
  151. data/lib/thinreports/generator/pdf/document/draw_shape.rb +0 -106
  152. data/lib/thinreports/generator/pdf/document/draw_template_items.rb +0 -69
  153. data/lib/thinreports/generator/pdf/document/font.rb +0 -88
  154. data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +0 -147
  155. data/lib/thinreports/generator/pdf/document/graphics/basic.rb +0 -135
  156. data/lib/thinreports/generator/pdf/document/graphics/image.rb +0 -98
  157. data/lib/thinreports/generator/pdf/document/graphics/text.rb +0 -178
  158. data/lib/thinreports/generator/pdf/document/graphics.rb +0 -40
  159. data/lib/thinreports/generator/pdf/document/page.rb +0 -94
  160. data/lib/thinreports/generator/pdf/document/parse_color.rb +0 -49
  161. data/lib/thinreports/generator/pdf/document.rb +0 -130
  162. data/lib/thinreports/generator/pdf/drawer/base.rb +0 -48
  163. data/lib/thinreports/generator/pdf/drawer/list.rb +0 -63
  164. data/lib/thinreports/generator/pdf/drawer/list_section.rb +0 -49
  165. data/lib/thinreports/generator/pdf/drawer/page.rb +0 -125
  166. data/lib/thinreports/generator/pdf/prawn_ext/calc_image_dimensions.rb +0 -32
  167. data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +0 -29
  168. data/lib/thinreports/generator/pdf.rb +0 -63
  169. data/lib/thinreports/layout/base.rb +0 -46
  170. data/lib/thinreports/layout/format.rb +0 -65
  171. data/lib/thinreports/layout/legacy_schema.rb +0 -381
  172. data/lib/thinreports/layout/version.rb +0 -39
  173. data/lib/thinreports/report/base.rb +0 -169
  174. data/lib/thinreports/report/internal.rb +0 -105
  175. data/lib/thinreports/report/page.rb +0 -95
  176. data/lib/thinreports/report.rb +0 -24
  177. data/lib/thinreports/section_report/pdf/renderer/headers_renderer.rb +0 -24
  178. /data/lib/thinreports/{core → basic_report/core}/shape/base.rb +0 -0
  179. /data/lib/thinreports/{core → basic_report/core}/shape/manager.rb +0 -0
  180. /data/lib/thinreports/{core → basic_report/core}/shape/style.rb +0 -0
  181. /data/lib/thinreports/{generator → basic_report/generator}/pdf/prawn_ext.rb +0 -0
@@ -1,105 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Thinreports
4
- module Report
5
- class Internal
6
- attr_reader :pages
7
- attr_reader :page
8
- attr_reader :page_count
9
- attr_reader :default_layout
10
- attr_reader :layout_registry
11
-
12
- attr_accessor :page_create_handler
13
-
14
- # @param [Thinreports::Report::Base] report
15
- # @param options (see Thinreports::Report::Base#initialize)
16
- def initialize(report, options)
17
- @report = report
18
- @default_layout = options[:layout] ? init_layout(options[:layout]) : nil
19
-
20
- @layout_registry = {}
21
- @finalized = false
22
- @pages = []
23
- @page = nil
24
- @page_count = 0
25
-
26
- @page_create_handler = nil
27
- end
28
-
29
- # @see Thinreports::Report::Base#use_layout
30
- def register_layout(layout, options = {})
31
- if options.empty? || options[:default]
32
- @default_layout = init_layout(layout)
33
- else
34
- id = options[:id].to_sym
35
-
36
- raise ArgumentError, "Id :#{id} is already in use." if layout_registry.key?(id)
37
- layout_registry[id] = init_layout(layout, id)
38
- end
39
- end
40
-
41
- def add_page(new_page)
42
- finalize_current_page
43
- insert_page(new_page)
44
- end
45
-
46
- def copy_page
47
- finalize_current_page(at: :copy)
48
- insert_page(page.copy)
49
- end
50
-
51
- def finalize
52
- return if finalized?
53
-
54
- finalize_current_page
55
- @finalized = true
56
- end
57
-
58
- def finalized?
59
- @finalized
60
- end
61
-
62
- def load_layout(id_or_filename)
63
- return @default_layout if id_or_filename.nil?
64
-
65
- layout =
66
- case id_or_filename
67
- when Symbol
68
- layout_registry[id_or_filename]
69
- when String
70
- init_layout(id_or_filename)
71
- else
72
- raise ArgumentError, 'Invalid argument for layout.'
73
- end
74
-
75
- @default_layout ||= layout
76
- layout
77
- end
78
-
79
- private
80
-
81
- def insert_page(new_page)
82
- @pages << new_page
83
-
84
- if new_page.count?
85
- @page_count += 1
86
- new_page.no = @page_count
87
- end
88
-
89
- @page_create_handler.call(new_page) if !new_page.blank? && @page_create_handler
90
- @page = new_page
91
- end
92
-
93
- # @param (see Thinreports::Report::Page#finalize)
94
- def finalize_current_page(options = {})
95
- page.finalize(options) unless page.nil? || page.blank?
96
- end
97
-
98
- def init_layout(filename, id = nil)
99
- filename = filename.to_path if filename.is_a?(Pathname)
100
-
101
- Thinreports::Layout.new(filename, id: id)
102
- end
103
- end
104
- end
105
- end
@@ -1,95 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Thinreports
4
- module Report
5
- class BlankPage
6
- # @example
7
- # 3.times do
8
- # page = report.start_new_page
9
- # puts page.no
10
- # end
11
- # # => 1, 2, 3
12
- # @return [Integer]
13
- attr_accessor :no
14
-
15
- # @param [Boolean] count (nil)
16
- def initialize(count = nil)
17
- @count = count.nil? ? true : count
18
- end
19
-
20
- # @example
21
- # page = report.start_new_page
22
- # page.count? # => true
23
- #
24
- # page = report.start_new_page count: false
25
- # page.count? # => false
26
- # @return [Boolean]
27
- def count?
28
- @count
29
- end
30
-
31
- # @return [Boolean] (true)
32
- def blank?
33
- true
34
- end
35
- end
36
-
37
- class Page < BlankPage
38
- include Core::Shape::Manager::Target
39
-
40
- # @return [Thinreports::Report::Base]
41
- attr_reader :report
42
-
43
- # @return [Thinreports::Layout::Base]
44
- attr_reader :layout
45
-
46
- # @param [Thinreports::Report::Base] report
47
- # @param [Thinreports::Layout::Base] layout
48
- # @param [Hash] options ({})
49
- # @option options [Boolean] :count (true)
50
- def initialize(report, layout, options = {})
51
- super(options.key?(:count) ? options[:count] : true)
52
-
53
- @report = report
54
- @layout = layout
55
- @finalized = false
56
-
57
- initialize_manager(layout.format) do |f|
58
- Core::Shape::Interface(self, f)
59
- end
60
- end
61
-
62
- # @return [Boolean] (false)
63
- def blank?
64
- false
65
- end
66
-
67
- def copy
68
- new_page = self.class.new(report, layout, count: count?)
69
-
70
- manager.shapes.each do |id, shape|
71
- new_shape = shape.copy(new_page)
72
- new_page.manager.shapes[id] = new_shape
73
-
74
- new_page.manager.lists[id] = new_shape if new_shape.internal.type_of?(Core::Shape::List::TYPE_NAME)
75
- end
76
- new_page
77
- end
78
-
79
- # @param [Hash] options
80
- # @option options [:create, :copy] :at (:create)
81
- def finalize(options = {})
82
- at = options[:at] || :create
83
-
84
- # For list shapes.
85
- manager.lists.each_value { |list| list.manager.finalize } if at == :create
86
-
87
- @finalized = true
88
- end
89
-
90
- def finalized?
91
- @finalized
92
- end
93
- end
94
- end
95
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Thinreports
4
- module Report
5
- # @see Thinreports::Report::Base#initialize
6
- def self.new(*args)
7
- Base.new(*args)
8
- end
9
-
10
- # @see Thinreports::Report::Base#create
11
- def self.create(*args, &block)
12
- Base.create(*args, &block)
13
- end
14
-
15
- # @see Thinreports::Report::Base#generate
16
- def self.generate(*args, &block)
17
- Base.generate(*args, &block)
18
- end
19
- end
20
- end
21
-
22
- require_relative 'report/base'
23
- require_relative 'report/internal'
24
- require_relative 'report/page'
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Thinreports
4
- module SectionReport
5
- module Renderer
6
- class HeadersRenderer
7
- def initialize(pdf)
8
- @pdf = pdf
9
- @section_renderer = Renderer::SectionRenderer.new(pdf)
10
- end
11
-
12
- def render(headers)
13
- headers.each do |header|
14
- section_renderer.render(header)
15
- end
16
- end
17
-
18
- private
19
-
20
- attr_reader :pdf, :section_renderer
21
- end
22
- end
23
- end
24
- end