thinreports 0.6.0.pre3
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.
- data/.yardopts +1 -0
- data/README.rdoc +100 -0
- data/Rakefile +10 -0
- data/doc/yardoc_templates/default/layout/html/footer.erb +10 -0
- data/lib/thinreports.rb +11 -0
- data/lib/thinreports/core.rb +20 -0
- data/lib/thinreports/core/errors.rb +58 -0
- data/lib/thinreports/core/events.rb +71 -0
- data/lib/thinreports/core/ext.rb +5 -0
- data/lib/thinreports/core/ext/array.rb +19 -0
- data/lib/thinreports/core/ext/hash.rb +19 -0
- data/lib/thinreports/core/ext/object.rb +25 -0
- data/lib/thinreports/core/format.rb +14 -0
- data/lib/thinreports/core/format/base.rb +93 -0
- data/lib/thinreports/core/format/builder.rb +65 -0
- data/lib/thinreports/core/ordered_hash.rb +39 -0
- data/lib/thinreports/core/page.rb +91 -0
- data/lib/thinreports/core/shape.rb +53 -0
- data/lib/thinreports/core/shape/base.rb +16 -0
- data/lib/thinreports/core/shape/base/interface.rb +38 -0
- data/lib/thinreports/core/shape/base/internal.rb +60 -0
- data/lib/thinreports/core/shape/basic.rb +15 -0
- data/lib/thinreports/core/shape/basic/format.rb +26 -0
- data/lib/thinreports/core/shape/basic/interface.rb +57 -0
- data/lib/thinreports/core/shape/basic/internal.rb +29 -0
- data/lib/thinreports/core/shape/list.rb +25 -0
- data/lib/thinreports/core/shape/list/configuration.rb +33 -0
- data/lib/thinreports/core/shape/list/events.rb +30 -0
- data/lib/thinreports/core/shape/list/format.rb +72 -0
- data/lib/thinreports/core/shape/list/manager.rb +209 -0
- data/lib/thinreports/core/shape/list/page.rb +118 -0
- data/lib/thinreports/core/shape/list/page_state.rb +40 -0
- data/lib/thinreports/core/shape/list/section_format.rb +32 -0
- data/lib/thinreports/core/shape/list/section_interface.rb +48 -0
- data/lib/thinreports/core/shape/list/section_internal.rb +29 -0
- data/lib/thinreports/core/shape/list/store.rb +34 -0
- data/lib/thinreports/core/shape/manager.rb +14 -0
- data/lib/thinreports/core/shape/manager/format.rb +28 -0
- data/lib/thinreports/core/shape/manager/internal.rb +87 -0
- data/lib/thinreports/core/shape/manager/target.rb +85 -0
- data/lib/thinreports/core/shape/tblock.rb +16 -0
- data/lib/thinreports/core/shape/tblock/format.rb +36 -0
- data/lib/thinreports/core/shape/tblock/formatter.rb +32 -0
- data/lib/thinreports/core/shape/tblock/formatter/basic.rb +38 -0
- data/lib/thinreports/core/shape/tblock/formatter/datetime.rb +21 -0
- data/lib/thinreports/core/shape/tblock/formatter/number.rb +49 -0
- data/lib/thinreports/core/shape/tblock/formatter/padding.rb +43 -0
- data/lib/thinreports/core/shape/tblock/interface.rb +52 -0
- data/lib/thinreports/core/shape/tblock/internal.rb +70 -0
- data/lib/thinreports/core/shape/text.rb +15 -0
- data/lib/thinreports/core/shape/text/format.rb +25 -0
- data/lib/thinreports/core/shape/text/interface.rb +16 -0
- data/lib/thinreports/core/shape/text/internal.rb +17 -0
- data/lib/thinreports/core/utils.rb +48 -0
- data/lib/thinreports/generator.rb +30 -0
- data/lib/thinreports/generator/base.rb +49 -0
- data/lib/thinreports/generator/pdf.rb +63 -0
- data/lib/thinreports/generator/pdf/document.rb +171 -0
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +74 -0
- data/lib/thinreports/generator/pdf/document/font.rb +59 -0
- data/lib/thinreports/generator/pdf/document/graphics.rb +42 -0
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +92 -0
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +132 -0
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +51 -0
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +130 -0
- data/lib/thinreports/generator/pdf/document/parse_color.rb +51 -0
- data/lib/thinreports/generator/pdf/document/parse_svg.rb +102 -0
- data/lib/thinreports/generator/pdf/drawer.rb +16 -0
- data/lib/thinreports/generator/pdf/drawer/base.rb +56 -0
- data/lib/thinreports/generator/pdf/drawer/list.rb +39 -0
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +46 -0
- data/lib/thinreports/generator/pdf/drawer/page.rb +101 -0
- data/lib/thinreports/generator/pdf/prawn_ext.rb +36 -0
- data/lib/thinreports/generator/pxd.rb +75 -0
- data/lib/thinreports/generator/pxd/helper.rb +33 -0
- data/lib/thinreports/generator/pxd/list_renderer.rb +58 -0
- data/lib/thinreports/generator/pxd/page_renderer.rb +75 -0
- data/lib/thinreports/layout.rb +17 -0
- data/lib/thinreports/layout/base.rb +78 -0
- data/lib/thinreports/layout/configuration.rb +27 -0
- data/lib/thinreports/layout/format.rb +77 -0
- data/lib/thinreports/layout/version.rb +43 -0
- data/lib/thinreports/report.rb +31 -0
- data/lib/thinreports/report/base.rb +160 -0
- data/lib/thinreports/report/events.rb +32 -0
- data/lib/thinreports/report/internal.rb +131 -0
- data/resources/fonts/IPA_Font_License_Agreement_v1.0.txt +117 -0
- data/resources/fonts/ipag.ttf +0 -0
- data/resources/fonts/ipagp.ttf +0 -0
- data/resources/fonts/ipam.ttf +0 -0
- data/resources/fonts/ipamp.ttf +0 -0
- data/tasks/clean.rake +6 -0
- data/tasks/doc.rake +13 -0
- data/tasks/test.rake +18 -0
- data/test/unit/core/ext/array_spec.rb +29 -0
- data/test/unit/core/ext/hash_spec.rb +29 -0
- data/test/unit/core/ext/object_spec.rb +30 -0
- data/test/unit/core/format/test_base.rb +148 -0
- data/test/unit/core/format/test_builder.rb +114 -0
- data/test/unit/core/ordered_hash_spec.rb +51 -0
- data/test/unit/core/shape/base/test_interface.rb +52 -0
- data/test/unit/core/shape/base/test_internal.rb +109 -0
- data/test/unit/core/shape/basic/test_format.rb +59 -0
- data/test/unit/core/shape/basic/test_interface.rb +70 -0
- data/test/unit/core/shape/basic/test_internal.rb +42 -0
- data/test/unit/core/shape/list/test_configuration.rb +52 -0
- data/test/unit/core/shape/list/test_events.rb +28 -0
- data/test/unit/core/shape/list/test_format.rb +71 -0
- data/test/unit/core/shape/list/test_page.rb +10 -0
- data/test/unit/core/shape/list/test_page_state.rb +31 -0
- data/test/unit/core/shape/list/test_section_format.rb +46 -0
- data/test/unit/core/shape/list/test_section_interface.rb +52 -0
- data/test/unit/core/shape/list/test_section_internal.rb +30 -0
- data/test/unit/core/shape/list/test_store.rb +41 -0
- data/test/unit/core/shape/manager/test_format.rb +40 -0
- data/test/unit/core/shape/manager/test_internal.rb +137 -0
- data/test/unit/core/shape/manager/test_target.rb +109 -0
- data/test/unit/core/shape/tblock/formatter/test_basic.rb +24 -0
- data/test/unit/core/shape/tblock/formatter/test_datetime.rb +47 -0
- data/test/unit/core/shape/tblock/formatter/test_number.rb +76 -0
- data/test/unit/core/shape/tblock/formatter/test_padding.rb +72 -0
- data/test/unit/core/shape/tblock/test_format.rb +125 -0
- data/test/unit/core/shape/tblock/test_formatter.rb +28 -0
- data/test/unit/core/shape/tblock/test_interface.rb +40 -0
- data/test/unit/core/shape/tblock/test_internal.rb +139 -0
- data/test/unit/core/shape/text/test_format.rb +73 -0
- data/test/unit/core/shape/text/test_internal.rb +21 -0
- data/test/unit/core/test_events.rb +91 -0
- data/test/unit/core/test_shape.rb +35 -0
- data/test/unit/core/utils_spec.rb +56 -0
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +103 -0
- data/test/unit/generator/pdf/document/test_font.rb +54 -0
- data/test/unit/generator/pdf/document/test_graphics.rb +43 -0
- data/test/unit/generator/pdf/document/test_parse_color.rb +30 -0
- data/test/unit/generator/test_base.rb +51 -0
- data/test/unit/helper.rb +37 -0
- data/test/unit/layout/test_base.rb +92 -0
- data/test/unit/layout/test_configuration.rb +46 -0
- data/test/unit/layout/test_format.rb +104 -0
- data/test/unit/layout/test_version.rb +62 -0
- data/test/unit/report/test_base.rb +187 -0
- data/test/unit/report/test_events.rb +22 -0
- data/test/unit/report/test_internal.rb +234 -0
- data/test/unit/test_layout.rb +12 -0
- data/test/unit/test_report.rb +30 -0
- metadata +218 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ThinReports
|
|
4
|
+
module Core::Shape::Tblock
|
|
5
|
+
|
|
6
|
+
# @private
|
|
7
|
+
module Formatter
|
|
8
|
+
# @param [ThinReports::Core::Shape::Tblock::Format] format
|
|
9
|
+
# @return [ThinReports::Core::Shape::Tblock::Formatter::Base]
|
|
10
|
+
def self.setup(format)
|
|
11
|
+
klass = if format.format_type.blank?
|
|
12
|
+
Basic
|
|
13
|
+
else
|
|
14
|
+
case format.format_type
|
|
15
|
+
when 'number' then Number
|
|
16
|
+
when 'datetime' then Datetime
|
|
17
|
+
when 'padding' then Padding
|
|
18
|
+
else
|
|
19
|
+
raise ThinReports::Errors::UnknownFormatterType
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
klass.new(format)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
require 'thinreports/core/shape/tblock/formatter/basic'
|
|
30
|
+
require 'thinreports/core/shape/tblock/formatter/datetime'
|
|
31
|
+
require 'thinreports/core/shape/tblock/formatter/padding'
|
|
32
|
+
require 'thinreports/core/shape/tblock/formatter/number'
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ThinReports
|
|
4
|
+
module Core::Shape::Tblock
|
|
5
|
+
|
|
6
|
+
# @private
|
|
7
|
+
class Formatter::Basic
|
|
8
|
+
attr_reader :format
|
|
9
|
+
|
|
10
|
+
def initialize(format)
|
|
11
|
+
@format = format
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def apply(value)
|
|
15
|
+
if applicable?(value)
|
|
16
|
+
value = apply_format_to(value)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
unless format.format_base.blank?
|
|
20
|
+
format.format_base.gsub(/\{value\}/, value.to_s)
|
|
21
|
+
else
|
|
22
|
+
value
|
|
23
|
+
end
|
|
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
|
+
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ThinReports
|
|
4
|
+
module Core::Shape::Tblock
|
|
5
|
+
|
|
6
|
+
# @private
|
|
7
|
+
class Formatter::Datetime < Formatter::Basic
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
def apply_format_to(value)
|
|
12
|
+
value.strftime(format.format_datetime_format)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def applicable?(value)
|
|
16
|
+
!format.format_datetime_format.blank? && value.respond_to?(:strftime)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'bigdecimal'
|
|
4
|
+
|
|
5
|
+
module ThinReports
|
|
6
|
+
module Core::Shape::Tblock
|
|
7
|
+
|
|
8
|
+
# @private
|
|
9
|
+
class Formatter::Number < Formatter::Basic
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def apply_format_to(value)
|
|
14
|
+
precision = format.format_number_precision
|
|
15
|
+
delimiter = format.format_number_delimiter
|
|
16
|
+
|
|
17
|
+
if_applicable value do |val|
|
|
18
|
+
unless precision.blank?
|
|
19
|
+
val = number_with_precision(val, precision)
|
|
20
|
+
end
|
|
21
|
+
unless delimiter.blank?
|
|
22
|
+
val = number_with_delimiter(val, delimiter)
|
|
23
|
+
end
|
|
24
|
+
val
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def if_applicable(value, &block)
|
|
29
|
+
val = case value
|
|
30
|
+
when Numeric then value
|
|
31
|
+
when String
|
|
32
|
+
(Integer(value) rescue nil) || (Float(value) rescue nil)
|
|
33
|
+
else nil
|
|
34
|
+
end
|
|
35
|
+
val.nil? ? value : block.call(val)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def number_with_delimiter(value, delimiter = ',')
|
|
39
|
+
value.to_s.gsub(/(\d)(?=(\d{3})+(?!\d))/){ "#{$1}#{delimiter}" }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def number_with_precision(value, precision = 3)
|
|
43
|
+
value = BigDecimal(value.to_s).round(precision)
|
|
44
|
+
sprintf("%.#{precision}f", value)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ThinReports
|
|
4
|
+
module Core::Shape::Tblock
|
|
5
|
+
|
|
6
|
+
# @private
|
|
7
|
+
class Formatter::Padding < Formatter::Basic
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
ruby_18 do
|
|
12
|
+
def apply_format_to(value)
|
|
13
|
+
strs = in_utf8 { value.to_s.split(//) }
|
|
14
|
+
pad_len = format.format_padding_length
|
|
15
|
+
|
|
16
|
+
if pad_len > strs.size
|
|
17
|
+
pad_strs = format.format_padding_char * (pad_len - strs.size)
|
|
18
|
+
if format.format_padding_rdir?
|
|
19
|
+
strs.to_s + pad_strs
|
|
20
|
+
else
|
|
21
|
+
pad_strs + strs.to_s
|
|
22
|
+
end
|
|
23
|
+
else
|
|
24
|
+
value.to_s
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
ruby_19 do
|
|
30
|
+
def apply_format_to(value)
|
|
31
|
+
value.to_s.send(format.format_padding_rdir? ? :ljust : :rjust,
|
|
32
|
+
format.format_padding_length,
|
|
33
|
+
format.format_padding_char)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def applicable?(value)
|
|
38
|
+
!format.format_padding_char.blank? && format.format_padding_length > 0
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ThinReports
|
|
4
|
+
module Core::Shape
|
|
5
|
+
|
|
6
|
+
class Tblock::Interface < Basic::Interface
|
|
7
|
+
internal_delegators :format_enabled?
|
|
8
|
+
|
|
9
|
+
# @param [Boolean] enabled
|
|
10
|
+
# @return [self]
|
|
11
|
+
def format_enabled(enabled)
|
|
12
|
+
internal.format_enabled(enabled)
|
|
13
|
+
self
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# @overload value(val)
|
|
17
|
+
# Set a val
|
|
18
|
+
# @param [Object] val
|
|
19
|
+
# @return [self]
|
|
20
|
+
# @overload value
|
|
21
|
+
# Return the value
|
|
22
|
+
# @return [Object]
|
|
23
|
+
def value(*args)
|
|
24
|
+
case args.size
|
|
25
|
+
when 0
|
|
26
|
+
internal.read_value
|
|
27
|
+
when 1
|
|
28
|
+
internal.write_value(args.first)
|
|
29
|
+
self
|
|
30
|
+
else
|
|
31
|
+
raise ArgumentError, '#value can take 0 or 1 argument.'
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# @param [Object] val
|
|
36
|
+
# @param [Hash<Symbol, Object>] style_settings
|
|
37
|
+
# @return [self]
|
|
38
|
+
def set(val, style_settings = {})
|
|
39
|
+
value(val)
|
|
40
|
+
styles(style_settings) #=> self
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
# @see ThinReports::Core::Shape::Base::Interface#init_internal
|
|
46
|
+
def init_internal(parent, format)
|
|
47
|
+
Tblock::Internal.new(parent, format)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ThinReports
|
|
4
|
+
module Core::Shape
|
|
5
|
+
|
|
6
|
+
# @private
|
|
7
|
+
class Tblock::Internal < Basic::Internal
|
|
8
|
+
format_delegators :multiple?, :box
|
|
9
|
+
|
|
10
|
+
def initialize(*args)
|
|
11
|
+
super(*args)
|
|
12
|
+
|
|
13
|
+
@reference = nil
|
|
14
|
+
@formatter = nil
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def read_value
|
|
18
|
+
if format.has_reference?
|
|
19
|
+
@reference ||= parent.item(format.ref_id)
|
|
20
|
+
@reference.value
|
|
21
|
+
else
|
|
22
|
+
states.key?(:value) ? states[:value] : format.value
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
alias_method :value, :read_value
|
|
26
|
+
|
|
27
|
+
def write_value(val)
|
|
28
|
+
if format.has_reference?
|
|
29
|
+
warn 'The set value is not reflected, ' +
|
|
30
|
+
"Because '#{format.id}' refers to '#{format.ref_id}'."
|
|
31
|
+
else
|
|
32
|
+
states[:value] = val
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def real_value
|
|
37
|
+
if format_enabled?
|
|
38
|
+
formatter.apply(read_value)
|
|
39
|
+
else
|
|
40
|
+
read_value
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def format_enabled(enabled)
|
|
45
|
+
states[:format_enabled] = enabled
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def format_enabled?
|
|
49
|
+
return false if multiple?
|
|
50
|
+
|
|
51
|
+
if states.key?(:format_enabled)
|
|
52
|
+
states[:format_enabled]
|
|
53
|
+
else
|
|
54
|
+
format.has_format?
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def type_of?(type_name)
|
|
59
|
+
type_name == :tblock
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
private
|
|
63
|
+
|
|
64
|
+
def formatter
|
|
65
|
+
@formatter ||= Tblock::Formatter.setup(format)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ThinReports
|
|
4
|
+
module Core::Shape
|
|
5
|
+
|
|
6
|
+
module Text
|
|
7
|
+
TYPE_NAME = 's-text'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
require 'thinreports/core/shape/text/format'
|
|
14
|
+
require 'thinreports/core/shape/text/internal'
|
|
15
|
+
require 'thinreports/core/shape/text/interface'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ThinReports
|
|
4
|
+
module Core::Shape
|
|
5
|
+
|
|
6
|
+
# @private
|
|
7
|
+
class Text::Format < Basic::Format
|
|
8
|
+
config_reader :text, :box, :valign
|
|
9
|
+
config_reader :svg_content => %w( svg content ),
|
|
10
|
+
:line_height => %w( line-height )
|
|
11
|
+
|
|
12
|
+
class << self
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
# @see ThinReports::Core::Shape::Basic::Format#build_internal
|
|
16
|
+
def build_internal(raw_format)
|
|
17
|
+
new(raw_format) do |f|
|
|
18
|
+
clean_with_attributes(f.svg_content)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ThinReports
|
|
4
|
+
module Core::Shape
|
|
5
|
+
|
|
6
|
+
class Text::Interface < Basic::Interface
|
|
7
|
+
private
|
|
8
|
+
|
|
9
|
+
# @see ThinReports::Core::Shape::Base::Interface#init_internal
|
|
10
|
+
def init_internal(parent, format)
|
|
11
|
+
Text::Internal.new(parent, format)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ThinReports
|
|
4
|
+
module Core::Shape
|
|
5
|
+
|
|
6
|
+
# @private
|
|
7
|
+
class Text::Internal < Basic::Internal
|
|
8
|
+
# Delegate to Format's methods
|
|
9
|
+
format_delegators :svg_content, :text, :box
|
|
10
|
+
|
|
11
|
+
def type_of?(type_name)
|
|
12
|
+
type_name == :text
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ThinReports
|
|
4
|
+
module Core
|
|
5
|
+
|
|
6
|
+
# @private
|
|
7
|
+
module Utils
|
|
8
|
+
def in_utf8(&block)
|
|
9
|
+
original = $KCODE
|
|
10
|
+
$KCODE = 'u'
|
|
11
|
+
block.call
|
|
12
|
+
ensure
|
|
13
|
+
$KCODE = original
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def block_exec_on(context, &block)
|
|
17
|
+
return context unless block_given?
|
|
18
|
+
|
|
19
|
+
if block.arity == 1
|
|
20
|
+
block.call(context)
|
|
21
|
+
else
|
|
22
|
+
context.instance_eval(&block)
|
|
23
|
+
end
|
|
24
|
+
context
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
if RUBY_VERSION < '1.9'
|
|
28
|
+
def ruby_18
|
|
29
|
+
yield
|
|
30
|
+
end
|
|
31
|
+
def ruby_19
|
|
32
|
+
false
|
|
33
|
+
end
|
|
34
|
+
else
|
|
35
|
+
def ruby_18
|
|
36
|
+
false
|
|
37
|
+
end
|
|
38
|
+
def ruby_19
|
|
39
|
+
yield
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Include global methods.
|
|
48
|
+
include ThinReports::Core::Utils
|