thinreports 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/test.yml +31 -40
- data/.gitignore +1 -1
- data/CHANGELOG.md +25 -1
- data/Gemfile +11 -0
- data/{MIT-LICENSE → LICENSE.txt} +2 -0
- data/README.md +50 -66
- data/Rakefile +17 -11
- data/lib/thinreports/basic_report/core/errors.rb +62 -0
- data/lib/thinreports/basic_report/core/format/base.rb +91 -0
- data/lib/thinreports/basic_report/core/shape/base/interface.rb +42 -0
- data/lib/thinreports/basic_report/core/shape/base/internal.rb +53 -0
- data/lib/thinreports/basic_report/core/shape/basic/block_format.rb +15 -0
- data/lib/thinreports/basic_report/core/shape/basic/block_interface.rb +34 -0
- data/lib/thinreports/basic_report/core/shape/basic/block_internal.rb +36 -0
- data/lib/thinreports/basic_report/core/shape/basic/format.rb +24 -0
- data/lib/thinreports/basic_report/core/shape/basic/interface.rb +87 -0
- data/lib/thinreports/basic_report/core/shape/basic/internal.rb +28 -0
- data/lib/thinreports/{core → basic_report/core}/shape/basic.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/image_block/format.rb +14 -0
- data/lib/thinreports/basic_report/core/shape/image_block/interface.rb +25 -0
- data/lib/thinreports/basic_report/core/shape/image_block/internal.rb +19 -0
- data/lib/thinreports/{core → basic_report/core}/shape/image_block.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/list/format.rb +92 -0
- data/lib/thinreports/basic_report/core/shape/list/manager.rb +231 -0
- data/lib/thinreports/basic_report/core/shape/list/page.rb +112 -0
- data/lib/thinreports/basic_report/core/shape/list/page_state.rb +50 -0
- data/lib/thinreports/basic_report/core/shape/list/section_format.rb +37 -0
- data/lib/thinreports/basic_report/core/shape/list/section_interface.rb +51 -0
- data/lib/thinreports/basic_report/core/shape/list/section_internal.rb +33 -0
- data/lib/thinreports/{core → basic_report/core}/shape/list.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/manager/format.rb +33 -0
- data/lib/thinreports/basic_report/core/shape/manager/internal.rb +109 -0
- data/lib/thinreports/basic_report/core/shape/manager/target.rb +114 -0
- data/lib/thinreports/basic_report/core/shape/page_number/format.rb +32 -0
- data/lib/thinreports/basic_report/core/shape/page_number/interface.rb +31 -0
- data/lib/thinreports/basic_report/core/shape/page_number/internal.rb +57 -0
- data/lib/thinreports/{core → basic_report/core}/shape/page_number.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/stack_view/format.rb +29 -0
- data/lib/thinreports/basic_report/core/shape/stack_view/interface.rb +19 -0
- data/lib/thinreports/basic_report/core/shape/stack_view/internal.rb +24 -0
- data/lib/thinreports/basic_report/core/shape/stack_view/row_format.rb +41 -0
- data/lib/thinreports/{core → basic_report/core}/shape/stack_view.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/style/base.rb +149 -0
- data/lib/thinreports/basic_report/core/shape/style/basic.rb +24 -0
- data/lib/thinreports/basic_report/core/shape/style/graphic.rb +43 -0
- data/lib/thinreports/basic_report/core/shape/style/text.rb +122 -0
- data/lib/thinreports/basic_report/core/shape/text/format.rb +17 -0
- data/lib/thinreports/basic_report/core/shape/text/interface.rb +20 -0
- data/lib/thinreports/basic_report/core/shape/text/internal.rb +24 -0
- data/lib/thinreports/{core → basic_report/core}/shape/text.rb +6 -4
- data/lib/thinreports/basic_report/core/shape/text_block/format.rb +43 -0
- data/lib/thinreports/basic_report/core/shape/text_block/formatter/basic.rb +41 -0
- data/lib/thinreports/basic_report/core/shape/text_block/formatter/datetime.rb +25 -0
- data/lib/thinreports/basic_report/core/shape/text_block/formatter/number.rb +69 -0
- data/lib/thinreports/basic_report/core/shape/text_block/formatter/padding.rb +27 -0
- data/lib/thinreports/basic_report/core/shape/text_block/formatter.rb +38 -0
- data/lib/thinreports/basic_report/core/shape/text_block/interface.rb +37 -0
- data/lib/thinreports/basic_report/core/shape/text_block/internal.rb +75 -0
- data/lib/thinreports/{core → basic_report/core}/shape/text_block.rb +6 -4
- data/lib/thinreports/basic_report/core/shape.rb +44 -0
- data/lib/thinreports/basic_report/core/utils.rb +47 -0
- data/lib/thinreports/basic_report/generator/pdf/document/draw_shape.rb +108 -0
- data/lib/thinreports/basic_report/generator/pdf/document/draw_template_items.rb +71 -0
- data/lib/thinreports/basic_report/generator/pdf/document/font.rb +90 -0
- data/lib/thinreports/basic_report/generator/pdf/document/graphics/attributes.rb +149 -0
- data/lib/thinreports/basic_report/generator/pdf/document/graphics/basic.rb +137 -0
- data/lib/thinreports/basic_report/generator/pdf/document/graphics/image.rb +99 -0
- data/lib/thinreports/basic_report/generator/pdf/document/graphics/text.rb +180 -0
- data/lib/thinreports/basic_report/generator/pdf/document/graphics.rb +42 -0
- data/lib/thinreports/basic_report/generator/pdf/document/page.rb +96 -0
- data/lib/thinreports/basic_report/generator/pdf/document/parse_color.rb +51 -0
- data/lib/thinreports/basic_report/generator/pdf/document.rb +132 -0
- data/lib/thinreports/basic_report/generator/pdf/drawer/base.rb +50 -0
- data/lib/thinreports/basic_report/generator/pdf/drawer/list.rb +65 -0
- data/lib/thinreports/basic_report/generator/pdf/drawer/list_section.rb +51 -0
- data/lib/thinreports/basic_report/generator/pdf/drawer/page.rb +127 -0
- data/lib/thinreports/basic_report/generator/pdf/prawn_ext/calc_image_dimensions.rb +34 -0
- data/lib/thinreports/basic_report/generator/pdf/prawn_ext/width_of.rb +31 -0
- data/lib/thinreports/basic_report/generator/pdf.rb +66 -0
- data/lib/thinreports/basic_report/layout/base.rb +48 -0
- data/lib/thinreports/basic_report/layout/format.rb +67 -0
- data/lib/thinreports/basic_report/layout/legacy_schema.rb +383 -0
- data/lib/thinreports/basic_report/layout/version.rb +41 -0
- data/lib/thinreports/{layout.rb → basic_report/layout.rb} +6 -4
- data/lib/thinreports/basic_report/report/base.rb +173 -0
- data/lib/thinreports/basic_report/report/internal.rb +107 -0
- data/lib/thinreports/basic_report/report/page.rb +97 -0
- data/lib/thinreports/basic_report/report.rb +26 -0
- data/lib/thinreports/basic_report.rb +15 -0
- data/lib/thinreports/config.rb +1 -1
- data/lib/thinreports/section_report/builder/stack_view_builder.rb +0 -2
- data/lib/thinreports/section_report.rb +12 -0
- data/lib/thinreports/version.rb +1 -1
- data/lib/thinreports.rb +2 -13
- data/thinreports.gemspec +3 -7
- metadata +99 -157
- data/Dockerfile +0 -12
- data/gemfiles/prawn-2.2.gemfile +0 -5
- data/gemfiles/prawn-2.3.gemfile +0 -5
- data/gemfiles/prawn-2.4.gemfile +0 -5
- data/lib/thinreports/core/errors.rb +0 -60
- data/lib/thinreports/core/format/base.rb +0 -89
- data/lib/thinreports/core/shape/base/interface.rb +0 -40
- data/lib/thinreports/core/shape/base/internal.rb +0 -51
- data/lib/thinreports/core/shape/basic/block_format.rb +0 -13
- data/lib/thinreports/core/shape/basic/block_interface.rb +0 -32
- data/lib/thinreports/core/shape/basic/block_internal.rb +0 -34
- data/lib/thinreports/core/shape/basic/format.rb +0 -22
- data/lib/thinreports/core/shape/basic/interface.rb +0 -85
- data/lib/thinreports/core/shape/basic/internal.rb +0 -26
- data/lib/thinreports/core/shape/image_block/format.rb +0 -12
- data/lib/thinreports/core/shape/image_block/interface.rb +0 -23
- data/lib/thinreports/core/shape/image_block/internal.rb +0 -17
- data/lib/thinreports/core/shape/list/format.rb +0 -90
- data/lib/thinreports/core/shape/list/manager.rb +0 -229
- data/lib/thinreports/core/shape/list/page.rb +0 -110
- data/lib/thinreports/core/shape/list/page_state.rb +0 -48
- data/lib/thinreports/core/shape/list/section_format.rb +0 -35
- data/lib/thinreports/core/shape/list/section_interface.rb +0 -49
- data/lib/thinreports/core/shape/list/section_internal.rb +0 -31
- data/lib/thinreports/core/shape/manager/format.rb +0 -31
- data/lib/thinreports/core/shape/manager/internal.rb +0 -107
- data/lib/thinreports/core/shape/manager/target.rb +0 -112
- data/lib/thinreports/core/shape/page_number/format.rb +0 -30
- data/lib/thinreports/core/shape/page_number/interface.rb +0 -29
- data/lib/thinreports/core/shape/page_number/internal.rb +0 -55
- data/lib/thinreports/core/shape/stack_view/format.rb +0 -27
- data/lib/thinreports/core/shape/stack_view/interface.rb +0 -17
- data/lib/thinreports/core/shape/stack_view/internal.rb +0 -22
- data/lib/thinreports/core/shape/stack_view/row_format.rb +0 -39
- data/lib/thinreports/core/shape/style/base.rb +0 -146
- data/lib/thinreports/core/shape/style/basic.rb +0 -22
- data/lib/thinreports/core/shape/style/graphic.rb +0 -41
- data/lib/thinreports/core/shape/style/text.rb +0 -120
- data/lib/thinreports/core/shape/text/format.rb +0 -15
- data/lib/thinreports/core/shape/text/interface.rb +0 -18
- data/lib/thinreports/core/shape/text/internal.rb +0 -22
- data/lib/thinreports/core/shape/text_block/format.rb +0 -41
- data/lib/thinreports/core/shape/text_block/formatter/basic.rb +0 -39
- data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +0 -23
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +0 -67
- data/lib/thinreports/core/shape/text_block/formatter/padding.rb +0 -25
- data/lib/thinreports/core/shape/text_block/formatter.rb +0 -34
- data/lib/thinreports/core/shape/text_block/interface.rb +0 -35
- data/lib/thinreports/core/shape/text_block/internal.rb +0 -73
- data/lib/thinreports/core/shape.rb +0 -42
- data/lib/thinreports/core/utils.rb +0 -45
- data/lib/thinreports/generate.rb +0 -11
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +0 -106
- data/lib/thinreports/generator/pdf/document/draw_template_items.rb +0 -69
- data/lib/thinreports/generator/pdf/document/font.rb +0 -88
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +0 -147
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +0 -135
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +0 -98
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +0 -178
- data/lib/thinreports/generator/pdf/document/graphics.rb +0 -40
- data/lib/thinreports/generator/pdf/document/page.rb +0 -94
- data/lib/thinreports/generator/pdf/document/parse_color.rb +0 -49
- data/lib/thinreports/generator/pdf/document.rb +0 -130
- data/lib/thinreports/generator/pdf/drawer/base.rb +0 -48
- data/lib/thinreports/generator/pdf/drawer/list.rb +0 -63
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +0 -49
- data/lib/thinreports/generator/pdf/drawer/page.rb +0 -125
- data/lib/thinreports/generator/pdf/prawn_ext/calc_image_dimensions.rb +0 -32
- data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +0 -29
- data/lib/thinreports/generator/pdf.rb +0 -63
- data/lib/thinreports/layout/base.rb +0 -46
- data/lib/thinreports/layout/format.rb +0 -65
- data/lib/thinreports/layout/legacy_schema.rb +0 -381
- data/lib/thinreports/layout/version.rb +0 -39
- data/lib/thinreports/report/base.rb +0 -169
- data/lib/thinreports/report/internal.rb +0 -105
- data/lib/thinreports/report/page.rb +0 -95
- data/lib/thinreports/report.rb +0 -24
- data/lib/thinreports/section_report/pdf/renderer/headers_renderer.rb +0 -24
- /data/lib/thinreports/{core → basic_report/core}/shape/base.rb +0 -0
- /data/lib/thinreports/{core → basic_report/core}/shape/manager.rb +0 -0
- /data/lib/thinreports/{core → basic_report/core}/shape/style.rb +0 -0
- /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
|
data/lib/thinreports/report.rb
DELETED
@@ -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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|