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
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Thinreports
|
4
|
+
module BasicReport
|
5
|
+
module Core
|
6
|
+
module Shape
|
7
|
+
module StackView
|
8
|
+
class Format < Basic::Format
|
9
|
+
attr_reader :rows
|
10
|
+
|
11
|
+
def initialize(*)
|
12
|
+
super
|
13
|
+
initialize_rows
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def initialize_rows
|
19
|
+
@rows = []
|
20
|
+
attributes['rows'].each do |row|
|
21
|
+
@rows << StackView::RowFormat.new(row)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Thinreports
|
4
|
+
module BasicReport
|
5
|
+
module Core
|
6
|
+
module Shape
|
7
|
+
module StackView
|
8
|
+
class Interface < Basic::Interface
|
9
|
+
private
|
10
|
+
|
11
|
+
def init_internal(parent, format)
|
12
|
+
StackView::Internal.new(parent, format)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Thinreports
|
4
|
+
module BasicReport
|
5
|
+
module Core
|
6
|
+
module Shape
|
7
|
+
module StackView
|
8
|
+
class Internal < Basic::Internal
|
9
|
+
def initialize(parent, format)
|
10
|
+
super
|
11
|
+
@rows = []
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_accessor :rows
|
15
|
+
|
16
|
+
def type_of?(type_name)
|
17
|
+
type_name == StackView::TYPE_NAME
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Thinreports
|
4
|
+
module BasicReport
|
5
|
+
module Core
|
6
|
+
module Shape
|
7
|
+
module StackView
|
8
|
+
class RowFormat < Core::Format::Base
|
9
|
+
config_reader :id
|
10
|
+
config_reader :height
|
11
|
+
config_checker true, :display
|
12
|
+
config_checker true, auto_stretch: 'auto-stretch'
|
13
|
+
|
14
|
+
attr_reader :items
|
15
|
+
|
16
|
+
def initialize(*)
|
17
|
+
super
|
18
|
+
@items = []
|
19
|
+
@item_with_ids = {}
|
20
|
+
initialize_items(attributes['items'])
|
21
|
+
end
|
22
|
+
|
23
|
+
def find_item(id)
|
24
|
+
@item_with_ids[id.to_sym]
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def initialize_items(item_schemas)
|
30
|
+
item_schemas.each do |item_schema|
|
31
|
+
item = Core::Shape::Format(item_schema['type']).new(item_schema)
|
32
|
+
@items << item
|
33
|
+
@item_with_ids[item.id.to_sym] = item unless item.id.empty?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Thinreports
|
4
|
-
module
|
5
|
-
module
|
6
|
-
module
|
7
|
-
|
4
|
+
module BasicReport
|
5
|
+
module Core
|
6
|
+
module Shape
|
7
|
+
module StackView
|
8
|
+
TYPE_NAME = 'stack-view'.freeze
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
10
12
|
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Thinreports
|
4
|
+
module BasicReport
|
5
|
+
module Core
|
6
|
+
module Shape
|
7
|
+
module Style
|
8
|
+
class Base
|
9
|
+
include Utils
|
10
|
+
|
11
|
+
class << self
|
12
|
+
# @param [Symbol] style_method
|
13
|
+
# @param [String] style
|
14
|
+
# @return [void]
|
15
|
+
def style_accessor(style_method, style)
|
16
|
+
style_reader(style_method, style)
|
17
|
+
style_writer(style_method, style)
|
18
|
+
end
|
19
|
+
|
20
|
+
# @see .style_accessor
|
21
|
+
def style_reader(style_method, style)
|
22
|
+
define_method(style_method) do
|
23
|
+
read_internal_style(style)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# @see .style_accessor
|
28
|
+
def style_writer(style_method, style)
|
29
|
+
define_method(:"#{style_method}=") do |value|
|
30
|
+
write_internal_style(style, value)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# @param [Array<Symbol>] style_methods
|
35
|
+
def style_accessible(*style_methods)
|
36
|
+
accessible_styles.concat(style_methods)
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [Array<Symbol>]
|
40
|
+
def accessible_styles
|
41
|
+
@accessible_styles ||= []
|
42
|
+
end
|
43
|
+
|
44
|
+
def inherited(s)
|
45
|
+
s.accessible_styles.concat(accessible_styles.dup)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [Hash]
|
50
|
+
attr_accessor :styles
|
51
|
+
# @see .accessible_styles
|
52
|
+
attr_reader :accessible_styles
|
53
|
+
|
54
|
+
# @param [Thinreports::BasicReport::Core::Format::Base] format
|
55
|
+
# @param [Hash] default_styles ({})
|
56
|
+
def initialize(format, default_styles = {})
|
57
|
+
@format = format
|
58
|
+
@styles = default_styles
|
59
|
+
@base_styles = format.style || {}
|
60
|
+
|
61
|
+
@accessible_styles = self.class.accessible_styles.dup
|
62
|
+
end
|
63
|
+
|
64
|
+
# @param [Symbol] style_method
|
65
|
+
# @return [Object]
|
66
|
+
def [](style_method)
|
67
|
+
verify_style_method(style_method)
|
68
|
+
send(style_method.to_sym)
|
69
|
+
end
|
70
|
+
|
71
|
+
# @param [Symbol] style_method
|
72
|
+
# @param [String, Number, Array<String, Number>] value
|
73
|
+
def []=(style_method, value)
|
74
|
+
verify_style_method(style_method)
|
75
|
+
send(:"#{style_method}=", value)
|
76
|
+
end
|
77
|
+
|
78
|
+
# @return [String]
|
79
|
+
def identifier
|
80
|
+
create_identifier(@styles)
|
81
|
+
end
|
82
|
+
|
83
|
+
# @return [self]
|
84
|
+
def copy
|
85
|
+
self.class.new(@format, @styles.empty? ? {} : deep_copy(@styles))
|
86
|
+
end
|
87
|
+
|
88
|
+
# @param [String, Symbol] style
|
89
|
+
# @return [Object]
|
90
|
+
def read_internal_style(style)
|
91
|
+
style = style.to_s
|
92
|
+
@styles.key?(style) ? @styles[style] : @base_styles[style]
|
93
|
+
end
|
94
|
+
|
95
|
+
# @param [String, Symbol] style
|
96
|
+
# @param [Object] value
|
97
|
+
def write_internal_style(style, value)
|
98
|
+
@styles[style.to_s] = value
|
99
|
+
end
|
100
|
+
|
101
|
+
# @param [Symbol] style_method
|
102
|
+
# @return [Boolean]
|
103
|
+
def has_style?(style_method)
|
104
|
+
accessible_styles.include?(style_method)
|
105
|
+
end
|
106
|
+
|
107
|
+
# @return [Hash]
|
108
|
+
def finalized_styles
|
109
|
+
@finalized_styles ||=
|
110
|
+
if @styles.empty?
|
111
|
+
@base_styles.dup
|
112
|
+
else
|
113
|
+
@base_styles.merge(@styles)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
private
|
118
|
+
|
119
|
+
# @param [Hash] s
|
120
|
+
# @return [String]
|
121
|
+
def create_identifier(s)
|
122
|
+
s.empty? ? '' : s.hash.to_s
|
123
|
+
end
|
124
|
+
|
125
|
+
# @param [Symbol] style_method
|
126
|
+
# @raise Thinreports::BasicReport::Errors::UnknownShapeStyleName
|
127
|
+
def verify_style_method(style_method)
|
128
|
+
return if has_style?(style_method)
|
129
|
+
|
130
|
+
raise Thinreports::BasicReport::Errors::UnknownShapeStyleName.new(
|
131
|
+
style_method,
|
132
|
+
accessible_styles
|
133
|
+
)
|
134
|
+
end
|
135
|
+
|
136
|
+
# @param [Object] value
|
137
|
+
# @param [Array<Object>] allows
|
138
|
+
# @param [String] msg (nil)
|
139
|
+
# @raise ArgumentError
|
140
|
+
def verify_style_value(value, allows, msg = nil)
|
141
|
+
raise ArgumentError, msg unless allows.include?(value)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Thinreports
|
4
|
+
module BasicReport
|
5
|
+
module Core
|
6
|
+
module Shape
|
7
|
+
module Style
|
8
|
+
class Basic < Style::Base
|
9
|
+
style_accessible :visible, :offset_x, :offset_y
|
10
|
+
attr_accessor :visible
|
11
|
+
|
12
|
+
style_accessor :offset_x, 'offset-x'
|
13
|
+
style_accessor :offset_y, 'offset-y'
|
14
|
+
|
15
|
+
def initialize(*args)
|
16
|
+
super
|
17
|
+
@visible = @format.display?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Thinreports
|
4
|
+
module BasicReport
|
5
|
+
module Core
|
6
|
+
module Shape
|
7
|
+
module Style
|
8
|
+
class Graphic < Style::Basic
|
9
|
+
style_accessible :border_color, :border_width, :fill_color, :border
|
10
|
+
|
11
|
+
# @method border_color
|
12
|
+
# @return [String]
|
13
|
+
# @method border_color=(color)
|
14
|
+
# @param [String] color
|
15
|
+
style_accessor :border_color, 'border-color'
|
16
|
+
|
17
|
+
# @method border_width
|
18
|
+
# @return [Number]
|
19
|
+
style_accessor :border_width, 'border-width'
|
20
|
+
|
21
|
+
# @method fill_color
|
22
|
+
# @return [String]
|
23
|
+
# @method fill_color=(color)
|
24
|
+
# @param [String] color
|
25
|
+
style_accessor :fill_color, 'fill-color'
|
26
|
+
|
27
|
+
# @return [Array<String, Number>]
|
28
|
+
def border
|
29
|
+
[border_width, border_color]
|
30
|
+
end
|
31
|
+
|
32
|
+
# @param [Array<String, Number>] width_and_color
|
33
|
+
def border=(width_and_color)
|
34
|
+
w, c = width_and_color
|
35
|
+
self.border_width = w
|
36
|
+
self.border_color = c
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Thinreports
|
4
|
+
module BasicReport
|
5
|
+
module Core
|
6
|
+
module Shape
|
7
|
+
module Style
|
8
|
+
class Text < Style::Basic
|
9
|
+
style_accessible :bold, :italic, :underline, :linethrough,
|
10
|
+
:align, :valign, :color, :font_size
|
11
|
+
|
12
|
+
# @method color
|
13
|
+
# @return [String]
|
14
|
+
# @method color=(v)
|
15
|
+
# @param [String] v
|
16
|
+
style_accessor :color, 'color'
|
17
|
+
|
18
|
+
# @method font_size
|
19
|
+
# @return [Numeric, String]
|
20
|
+
# @method font_size=(v)
|
21
|
+
# @param [Numeric, String] v
|
22
|
+
style_accessor :font_size, 'font-size'
|
23
|
+
|
24
|
+
def initialize(*)
|
25
|
+
super
|
26
|
+
initialize_font_style
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Boolean]
|
30
|
+
def bold
|
31
|
+
read_internal_style('font-style').include?('bold')
|
32
|
+
end
|
33
|
+
|
34
|
+
# @param [Boolean] enable
|
35
|
+
def bold=(enable)
|
36
|
+
write_font_style('bold', enable)
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [Boolean]
|
40
|
+
def italic
|
41
|
+
read_internal_style('font-style').include?('italic')
|
42
|
+
end
|
43
|
+
|
44
|
+
# @param [Boolean] enable
|
45
|
+
def italic=(enable)
|
46
|
+
write_font_style('italic', enable)
|
47
|
+
end
|
48
|
+
|
49
|
+
# @return [Boolean]
|
50
|
+
def underline
|
51
|
+
read_internal_style('font-style').include?('underline')
|
52
|
+
end
|
53
|
+
|
54
|
+
# @param [Boolean] enable
|
55
|
+
def underline=(enable)
|
56
|
+
write_font_style('underline', enable)
|
57
|
+
end
|
58
|
+
|
59
|
+
# @return [Boolean]
|
60
|
+
def linethrough
|
61
|
+
read_internal_style('font-style').include?('linethrough')
|
62
|
+
end
|
63
|
+
|
64
|
+
# @param [Boolean] enable
|
65
|
+
def linethrough=(enable)
|
66
|
+
write_font_style('linethrough', enable)
|
67
|
+
end
|
68
|
+
|
69
|
+
# @return [:left, :center, :right]
|
70
|
+
def align
|
71
|
+
read_internal_style('text-align').to_sym
|
72
|
+
end
|
73
|
+
|
74
|
+
# @param [:left, :center, :right] align_name
|
75
|
+
def align=(align_name)
|
76
|
+
verify_style_value(align_name, %i[left center right],
|
77
|
+
'Only :left or :center, :right can be specified as align.')
|
78
|
+
write_internal_style('text-align', align_name.to_s)
|
79
|
+
end
|
80
|
+
|
81
|
+
# @return [:top, :middle, :bottom]
|
82
|
+
def valign
|
83
|
+
vertical_align = read_internal_style('vertical-align')
|
84
|
+
blank_value?(vertical_align) ? :top : vertical_align.to_sym
|
85
|
+
end
|
86
|
+
|
87
|
+
# @param [:top, :center, :middle, :bottom] valign_name
|
88
|
+
def valign=(valign_name)
|
89
|
+
if valign_name == :center
|
90
|
+
warn '[DEPRECATION] :center value for valign style is deprecated' \
|
91
|
+
' and will be removed in thinreports-generator 1.0.' \
|
92
|
+
' Please use :middle instead of :center.'
|
93
|
+
valign_name = :middle
|
94
|
+
end
|
95
|
+
|
96
|
+
verify_style_value(
|
97
|
+
valign_name,
|
98
|
+
%i[top middle bottom],
|
99
|
+
'Only :top or :middle (:center), :bottom can be specified as valign.'
|
100
|
+
)
|
101
|
+
write_internal_style('vertical-align', valign_name.to_s)
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
def initialize_font_style
|
107
|
+
styles['font-style'] ||= (@base_styles['font-style'] || []).dup
|
108
|
+
end
|
109
|
+
|
110
|
+
def write_font_style(style_name, enable)
|
111
|
+
if enable
|
112
|
+
styles['font-style'].push(style_name).uniq!
|
113
|
+
else
|
114
|
+
styles['font-style'].delete(style_name)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Thinreports
|
4
|
+
module BasicReport
|
5
|
+
module Core
|
6
|
+
module Shape
|
7
|
+
module Text
|
8
|
+
class Format < Basic::Format
|
9
|
+
config_reader :texts
|
10
|
+
config_reader valign: %w[style vertical-align]
|
11
|
+
config_reader line_height: %w[style line-height]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Thinreports
|
4
|
+
module BasicReport
|
5
|
+
module Core
|
6
|
+
module Shape
|
7
|
+
module Text
|
8
|
+
class Interface < Basic::Interface
|
9
|
+
private
|
10
|
+
|
11
|
+
# @see Thinreports::BasicReport::Core::Shape::Base::Interface#init_internal
|
12
|
+
def init_internal(parent, format)
|
13
|
+
Text::Internal.new(parent, format)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Thinreports
|
4
|
+
module BasicReport
|
5
|
+
module Core
|
6
|
+
module Shape
|
7
|
+
module Text
|
8
|
+
class Internal < Basic::Internal
|
9
|
+
# Delegate to Format's methods
|
10
|
+
format_delegators :texts, :box
|
11
|
+
|
12
|
+
def style
|
13
|
+
@style ||= Style::Text.new(format)
|
14
|
+
end
|
15
|
+
|
16
|
+
def type_of?(type_name)
|
17
|
+
type_name == Text::TYPE_NAME
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Thinreports
|
4
|
+
module BasicReport
|
5
|
+
module Core
|
6
|
+
module Shape
|
7
|
+
module TextBlock
|
8
|
+
class Format < Basic::BlockFormat
|
9
|
+
# For saving compatible 0.8.x format API
|
10
|
+
config_reader ref_id: %w[reference-id]
|
11
|
+
config_reader valign: %w[style vertical-align]
|
12
|
+
config_reader overflow: %w[style overflow]
|
13
|
+
config_reader line_height: %w[style line-height]
|
14
|
+
|
15
|
+
config_reader format_base: %w[format base],
|
16
|
+
format_type: %w[format type],
|
17
|
+
format_datetime_format: %w[format datetime format],
|
18
|
+
format_number_delimiter: %w[format number delimiter],
|
19
|
+
format_number_precision: %w[format number precision],
|
20
|
+
format_padding_char: %w[format padding char],
|
21
|
+
format_padding_dir: %w[format padding direction]
|
22
|
+
|
23
|
+
config_checker true, multiple: %w[multiple-line]
|
24
|
+
config_checker 'R', format_padding_rdir: %w[format padding direction]
|
25
|
+
|
26
|
+
config_reader format_padding_length: %w[format padding length] do |len|
|
27
|
+
blank_value?(len) ? 0 : len.to_i
|
28
|
+
end
|
29
|
+
|
30
|
+
config_reader has_format?: %w[format type] do |type|
|
31
|
+
%w[datetime number padding].include?(type)
|
32
|
+
end
|
33
|
+
|
34
|
+
# For saving compatible 0.8.x format API
|
35
|
+
def has_reference?
|
36
|
+
!blank_value?(ref_id)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Thinreports
|
4
|
+
module BasicReport
|
5
|
+
module Core
|
6
|
+
module Shape
|
7
|
+
module TextBlock
|
8
|
+
module Formatter
|
9
|
+
class Basic
|
10
|
+
include Utils
|
11
|
+
|
12
|
+
attr_reader :format
|
13
|
+
|
14
|
+
def initialize(format)
|
15
|
+
@format = format
|
16
|
+
end
|
17
|
+
|
18
|
+
def apply(value)
|
19
|
+
value = apply_format_to(value) if applicable?(value)
|
20
|
+
|
21
|
+
return value if blank_value?(format.format_base)
|
22
|
+
|
23
|
+
format.format_base.gsub(/\{value\}/, value.to_s)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def apply_format_to(value)
|
29
|
+
value
|
30
|
+
end
|
31
|
+
|
32
|
+
def applicable?(_value)
|
33
|
+
true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Thinreports
|
4
|
+
module BasicReport
|
5
|
+
module Core
|
6
|
+
module Shape
|
7
|
+
module TextBlock
|
8
|
+
module Formatter
|
9
|
+
class Datetime < Formatter::Basic
|
10
|
+
private
|
11
|
+
|
12
|
+
def apply_format_to(value)
|
13
|
+
value.strftime(format.format_datetime_format)
|
14
|
+
end
|
15
|
+
|
16
|
+
def applicable?(value)
|
17
|
+
!blank_value?(format.format_datetime_format) && value.respond_to?(:strftime)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|