thinreports 0.7.7 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -6
- data/.travis.yml +4 -10
- data/CHANGELOG.md +220 -0
- data/Gemfile +3 -3
- data/MIT-LICENSE +1 -1
- data/README.md +286 -0
- data/Rakefile +38 -8
- data/examples/character_spacing/character_spacing.rb +8 -0
- data/examples/character_spacing/character_spacing.tlf +1 -0
- data/examples/dynamic_image/dynamic_image.rb +31 -0
- data/examples/dynamic_image/dynamic_image.tlf +1 -0
- data/{test/case → examples}/dynamic_image/img200x100.png +0 -0
- data/{test/case → examples}/dynamic_image/img50x50.png +0 -0
- data/examples/dynamic_style/dynamic_style.rb +150 -0
- data/examples/dynamic_style/dynamic_style.tlf +1 -0
- data/examples/dynamic_style/dynamic_style_in_list.tlf +1 -0
- data/{test/case → examples}/dynamic_style/image.png +0 -0
- data/examples/eudc/eudc.rb +20 -0
- data/examples/eudc/eudc.tlf +1 -0
- data/{test/case → examples}/eudc/eudc.ttf +0 -0
- data/{test/case → examples}/helper.rb +14 -12
- data/examples/hidden_shapes/hidden_shapes.rb +9 -0
- data/examples/hidden_shapes/hidden_shapes.tlf +1 -0
- data/examples/list_events/list_events.rb +59 -0
- data/examples/list_events/list_events_0_7_7.tlf +1 -0
- data/examples/list_events/list_events_0_8.tlf +1 -0
- data/{test/case → examples}/list_manual_generation/list_manual_generation.rb +4 -4
- data/examples/list_manual_generation/list_manual_generation.tlf +1 -0
- data/{test/case → examples}/list_page_number/list_page_number.rb +3 -3
- data/examples/list_page_number/list_page_number.tlf +1 -0
- data/examples/page_number/page_number.rb +33 -0
- data/examples/page_number/page_number.tlf +1 -0
- data/examples/password_setting/password_setting.rb +10 -0
- data/examples/password_setting/password_setting.tlf +1 -0
- data/examples/report_callbacks/report_callbacks.rb +31 -0
- data/examples/report_callbacks/report_callbacks.tlf +1 -0
- data/{test/case → examples}/single_line_tblock/single_line_tblock.rb +2 -2
- data/examples/single_line_tblock/single_line_tblock.tlf +1 -0
- data/examples/tblock_overflow/tblock_overflow.rb +20 -0
- data/examples/tblock_overflow/tblock_overflow.tlf +1 -0
- data/examples/tblock_styles/font_size.tlf +1 -0
- data/examples/tblock_styles/tblock_styles.rb +43 -0
- data/examples/tblock_styles/tblock_styles.tlf +1 -0
- data/examples/text_align/text_align.rb +8 -0
- data/examples/text_align/text_align.tlf +1 -0
- data/examples/typeB_page_size/B4_ISO.tlf +1 -0
- data/examples/typeB_page_size/B4_JIS.tlf +1 -0
- data/{test/case → examples}/typeB_page_size/typeB_page_size.rb +3 -3
- data/examples/word_wrap/word_wrap.rb +26 -0
- data/examples/word_wrap/word_wrap.tlf +1 -0
- data/{resources/fonts → fonts}/IPA_Font_License_Agreement_v1.0.txt +0 -0
- data/{resources/fonts → fonts}/ipag.ttf +0 -0
- data/{resources/fonts → fonts}/ipagp.ttf +0 -0
- data/{resources/fonts → fonts}/ipam.ttf +0 -0
- data/{resources/fonts → fonts}/ipamp.ttf +0 -0
- data/lib/thinreports.rb +14 -2
- data/lib/thinreports/config.rb +30 -10
- data/lib/thinreports/core/errors.rb +23 -20
- data/lib/thinreports/core/events.rb +18 -19
- data/lib/thinreports/core/format/base.rb +20 -20
- data/lib/thinreports/core/format/builder.rb +14 -22
- data/lib/thinreports/core/shape.rb +9 -13
- data/lib/thinreports/core/shape/base.rb +4 -5
- data/lib/thinreports/core/shape/base/interface.rb +15 -15
- data/lib/thinreports/core/shape/base/internal.rb +15 -20
- data/lib/thinreports/core/shape/basic.rb +1 -1
- data/lib/thinreports/core/shape/basic/block_format.rb +3 -4
- data/lib/thinreports/core/shape/basic/block_interface.rb +9 -4
- data/lib/thinreports/core/shape/basic/block_internal.rb +9 -10
- data/lib/thinreports/core/shape/basic/format.rb +11 -10
- data/lib/thinreports/core/shape/basic/interface.rb +3 -3
- data/lib/thinreports/core/shape/basic/internal.rb +4 -5
- data/lib/thinreports/core/shape/image_block.rb +1 -1
- data/lib/thinreports/core/shape/image_block/format.rb +5 -6
- data/lib/thinreports/core/shape/image_block/interface.rb +9 -7
- data/lib/thinreports/core/shape/image_block/internal.rb +5 -6
- data/lib/thinreports/core/shape/list.rb +1 -1
- data/lib/thinreports/core/shape/list/configuration.rb +30 -15
- data/lib/thinreports/core/shape/list/events.rb +11 -11
- data/lib/thinreports/core/shape/list/format.rb +27 -28
- data/lib/thinreports/core/shape/list/manager.rb +128 -95
- data/lib/thinreports/core/shape/list/page.rb +54 -50
- data/lib/thinreports/core/shape/list/page_state.rb +15 -16
- data/lib/thinreports/core/shape/list/section_format.rb +14 -15
- data/lib/thinreports/core/shape/list/section_interface.rb +15 -16
- data/lib/thinreports/core/shape/list/section_internal.rb +7 -8
- data/lib/thinreports/core/shape/list/store.rb +10 -11
- data/lib/thinreports/core/shape/manager.rb +1 -1
- data/lib/thinreports/core/shape/manager/format.rb +10 -11
- data/lib/thinreports/core/shape/manager/internal.rb +21 -20
- data/lib/thinreports/core/shape/manager/target.rb +63 -34
- data/lib/thinreports/core/shape/page_number.rb +1 -1
- data/lib/thinreports/core/shape/page_number/format.rb +3 -3
- data/lib/thinreports/core/shape/page_number/interface.rb +2 -2
- data/lib/thinreports/core/shape/page_number/internal.rb +3 -3
- data/lib/thinreports/core/shape/style.rb +1 -1
- data/lib/thinreports/core/shape/style/base.rb +29 -29
- data/lib/thinreports/core/shape/style/basic.rb +1 -1
- data/lib/thinreports/core/shape/style/graphic.rb +10 -25
- data/lib/thinreports/core/shape/style/text.rb +36 -30
- data/lib/thinreports/core/shape/text.rb +1 -1
- data/lib/thinreports/core/shape/text/format.rb +8 -9
- data/lib/thinreports/core/shape/text/interface.rb +2 -2
- data/lib/thinreports/core/shape/text/internal.rb +6 -7
- data/lib/thinreports/core/shape/text_block.rb +1 -1
- data/lib/thinreports/core/shape/text_block/format.rb +17 -18
- data/lib/thinreports/core/shape/text_block/formatter.rb +7 -8
- data/lib/thinreports/core/shape/text_block/formatter/basic.rb +13 -12
- data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +8 -9
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +11 -12
- data/lib/thinreports/core/shape/text_block/formatter/padding.rb +9 -32
- data/lib/thinreports/core/shape/text_block/interface.rb +2 -2
- data/lib/thinreports/core/shape/text_block/internal.rb +19 -20
- data/lib/thinreports/core/utils.rb +33 -32
- data/lib/thinreports/generator.rb +6 -8
- data/lib/thinreports/generator/base.rb +15 -24
- data/lib/thinreports/generator/configuration.rb +10 -9
- data/lib/thinreports/generator/pdf.rb +27 -30
- data/lib/thinreports/generator/pdf/configuration.rb +11 -6
- data/lib/thinreports/generator/pdf/document.rb +28 -28
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +30 -31
- data/lib/thinreports/generator/pdf/document/font.rb +53 -44
- data/lib/thinreports/generator/pdf/document/graphics.rb +8 -9
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +25 -25
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +25 -25
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +15 -15
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +40 -41
- data/lib/thinreports/generator/pdf/document/page.rb +20 -21
- data/lib/thinreports/generator/pdf/document/parse_color.rb +9 -10
- data/lib/thinreports/generator/pdf/document/parse_svg.rb +14 -15
- data/lib/thinreports/generator/pdf/drawer/base.rb +13 -14
- data/lib/thinreports/generator/pdf/drawer/list.rb +13 -14
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +13 -14
- data/lib/thinreports/generator/pdf/drawer/page.rb +16 -17
- data/lib/thinreports/generator/pdf/prawn_ext.rb +17 -33
- data/lib/thinreports/layout.rb +2 -2
- data/lib/thinreports/layout/base.rb +22 -36
- data/lib/thinreports/layout/configuration.rb +11 -9
- data/lib/thinreports/layout/format.rb +26 -27
- data/lib/thinreports/layout/version.rb +8 -9
- data/lib/thinreports/report.rb +10 -14
- data/lib/thinreports/report/base.rb +104 -126
- data/lib/thinreports/report/events.rb +5 -5
- data/lib/thinreports/report/internal.rb +41 -33
- data/lib/thinreports/{core → report}/page.rb +38 -30
- data/lib/thinreports/version.rb +2 -3
- data/test/data/font.ttf +0 -0
- data/test/data/layout_block.tlf +1 -0
- data/test/data/layout_list.tlf +1 -0
- data/test/data/layout_list_noheader.tlf +1 -0
- data/test/data/layout_text1.tlf +1 -0
- data/test/data/layout_text2.tlf +1 -0
- data/test/test_helper.rb +74 -0
- data/test/{unit/tmp → tmp}/.gitkeep +0 -0
- data/test/unit/core/format/test_base.rb +14 -14
- data/test/unit/core/format/test_builder.rb +19 -23
- data/test/unit/core/shape/base/test_internal.rb +34 -37
- data/test/unit/core/shape/basic/test_basic_format.rb +4 -4
- data/test/unit/core/shape/basic/test_basic_interface.rb +15 -13
- data/test/unit/core/shape/basic/test_basic_internal.rb +19 -16
- data/test/unit/core/shape/basic/test_format.rb +4 -4
- data/test/unit/core/shape/basic/test_interface.rb +36 -46
- data/test/unit/core/shape/basic/test_internal.rb +23 -20
- data/test/unit/core/shape/image_block/test_format.rb +5 -5
- data/test/unit/core/shape/image_block/test_interface.rb +17 -16
- data/test/unit/core/shape/image_block/test_internal.rb +19 -16
- data/test/unit/core/shape/list/test_configuration.rb +45 -33
- data/test/unit/core/shape/list/test_events.rb +7 -7
- data/test/unit/core/shape/list/test_format.rb +16 -18
- data/test/unit/core/shape/list/test_manager.rb +5 -5
- data/test/unit/core/shape/list/test_page.rb +80 -22
- data/test/unit/core/shape/list/test_page_state.rb +12 -12
- data/test/unit/core/shape/list/test_section_format.rb +16 -17
- data/test/unit/core/shape/list/test_section_interface.rb +30 -22
- data/test/unit/core/shape/list/test_section_internal.rb +21 -19
- data/test/unit/core/shape/list/test_store.rb +7 -7
- data/test/unit/core/shape/manager/test_format.rb +11 -15
- data/test/unit/core/shape/manager/test_internal.rb +9 -9
- data/test/unit/core/shape/manager/test_target.rb +85 -57
- data/test/unit/core/shape/page_number/test_format.rb +4 -4
- data/test/unit/core/shape/page_number/test_interface.rb +11 -8
- data/test/unit/core/shape/page_number/test_internal.rb +5 -5
- data/test/unit/core/shape/styles/test_base.rb +9 -9
- data/test/unit/core/shape/styles/test_basic.rb +5 -5
- data/test/unit/core/shape/styles/test_graphic.rb +19 -33
- data/test/unit/core/shape/styles/test_text.rb +18 -7
- data/test/unit/core/shape/text/test_format.rb +6 -6
- data/test/unit/core/shape/text/test_internal.rb +11 -12
- data/test/unit/core/shape/text_block/formatter/test_basic.rb +16 -16
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +4 -4
- data/test/unit/core/shape/text_block/formatter/test_number.rb +34 -34
- data/test/unit/core/shape/text_block/formatter/test_padding.rb +44 -44
- data/test/unit/core/shape/text_block/test_format.rb +8 -8
- data/test/unit/core/shape/text_block/test_formatter.rb +17 -17
- data/test/unit/core/shape/text_block/test_interface.rb +37 -20
- data/test/unit/core/shape/text_block/test_internal.rb +38 -38
- data/test/unit/core/test_events.rb +5 -5
- data/test/unit/core/test_shape.rb +6 -6
- data/test/unit/core/test_utils.rb +68 -0
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +4 -4
- data/test/unit/generator/pdf/document/graphics/test_text.rb +60 -53
- data/test/unit/generator/pdf/document/test_draw_shape.rb +9 -7
- data/test/unit/generator/pdf/document/test_font.rb +79 -58
- data/test/unit/generator/pdf/document/test_graphics.rb +18 -19
- data/test/unit/generator/pdf/document/test_page.rb +44 -45
- data/test/unit/generator/pdf/document/test_parse_color.rb +5 -5
- data/test/unit/generator/pdf/test_configuration.rb +16 -9
- data/test/unit/generator/pdf/test_document.rb +8 -16
- data/test/unit/generator/test_base.rb +31 -42
- data/test/unit/generator/test_configuration.rb +6 -6
- data/test/unit/generator/test_pdf.rb +17 -14
- data/test/unit/layout/test_base.rb +34 -79
- data/test/unit/layout/test_configuration.rb +12 -37
- data/test/unit/layout/test_format.rb +36 -39
- data/test/unit/layout/test_version.rb +4 -4
- data/test/unit/report/test_base.rb +134 -213
- data/test/unit/report/test_events.rb +4 -4
- data/test/unit/report/test_internal.rb +84 -86
- data/test/unit/test_config.rb +31 -12
- data/test/unit/test_layout.rb +7 -7
- data/test/unit/test_report.rb +12 -24
- data/thinreports.gemspec +18 -22
- metadata +101 -200
- data/LICENSE +0 -1
- data/README.rdoc +0 -166
- data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
- data/lib/thinreports/core.rb +0 -20
- data/lib/thinreports/core/ext.rb +0 -5
- data/lib/thinreports/core/ext/array.rb +0 -19
- data/lib/thinreports/core/ext/hash.rb +0 -19
- data/lib/thinreports/core/ext/object.rb +0 -25
- data/lib/thinreports/core/format.rb +0 -14
- data/lib/thinreports/core/ordered_hash.rb +0 -39
- data/lib/thinreports/generator/pdf/drawer.rb +0 -16
- data/tasks/doc.rake +0 -12
- data/tasks/test.rake +0 -56
- data/test/benchmark/basic_estimate.tlf +0 -1
- data/test/benchmark/bench_basic_estimate.rb +0 -95
- data/test/case/character_spacing/character_spacing.rb +0 -8
- data/test/case/character_spacing/character_spacing.tlf +0 -1
- data/test/case/dynamic_image/dynamic_image.rb +0 -41
- data/test/case/dynamic_image/dynamic_image.tlf +0 -1
- data/test/case/dynamic_style/dynamic_style.rb +0 -154
- data/test/case/dynamic_style/dynamic_style.tlf +0 -1
- data/test/case/dynamic_style/dynamic_style_in_list.tlf +0 -1
- data/test/case/eudc/eudc.rb +0 -20
- data/test/case/eudc/eudc.tlf +0 -1
- data/test/case/hidden_shapes/hidden_shapes.rb +0 -9
- data/test/case/hidden_shapes/hidden_shapes.tlf +0 -1
- data/test/case/list_events/list_events.rb +0 -32
- data/test/case/list_events/list_events.tlf +0 -1
- data/test/case/list_manual_generation/list_manual_generation.tlf +0 -1
- data/test/case/list_page_number/list_page_number.tlf +0 -1
- data/test/case/page_number/page_number.rb +0 -33
- data/test/case/page_number/page_number.tlf +0 -1
- data/test/case/password_setting/password_setting.rb +0 -10
- data/test/case/password_setting/password_setting.tlf +0 -1
- data/test/case/single_line_tblock/single_line_tblock.tlf +0 -1
- data/test/case/tblock_overflow/tblock_overflow.rb +0 -20
- data/test/case/tblock_overflow/tblock_overflow.tlf +0 -1
- data/test/case/tblock_styles/tblock_styles.rb +0 -27
- data/test/case/tblock_styles/tblock_styles.tlf +0 -1
- data/test/case/text_align/text_align.rb +0 -8
- data/test/case/text_align/text_align.tlf +0 -1
- data/test/case/typeB_page_size/B4_ISO.tlf +0 -1
- data/test/case/typeB_page_size/B4_JIS.tlf +0 -1
- data/test/case/word_wrap/word_wrap.rb +0 -26
- data/test/case/word_wrap/word_wrap.tlf +0 -1
- data/test/unit/core/ext/array_spec.rb +0 -29
- data/test/unit/core/ext/hash_spec.rb +0 -29
- data/test/unit/core/ext/object_spec.rb +0 -30
- data/test/unit/core/ordered_hash_spec.rb +0 -51
- data/test/unit/core/shape/base/test_interface.rb +0 -52
- data/test/unit/core/utils_spec.rb +0 -56
- data/test/unit/data/basic_layout1.tlf +0 -1
- data/test/unit/data/basic_layout2.tlf +0 -1
- data/test/unit/data/basic_list_layout.tlf +0 -1
- data/test/unit/data/basic_list_noheader_layout.tlf +0 -1
- data/test/unit/helper.rb +0 -87
@@ -1,27 +1,28 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Core
|
5
|
-
|
5
|
+
|
6
6
|
class Events
|
7
|
+
include Utils
|
8
|
+
|
7
9
|
Event = ::Struct.new(:type, :target)
|
8
|
-
|
9
|
-
# @return [Hash<Symbol,
|
10
|
-
# @private
|
10
|
+
|
11
|
+
# @return [Hash<Symbol, Thinreports::Core::Events::Event>]
|
11
12
|
attr_accessor :events
|
12
|
-
|
13
|
+
|
13
14
|
# @param [Symbol] types
|
14
15
|
def initialize(*types)
|
15
16
|
@events = {}
|
16
17
|
@types = types
|
17
18
|
end
|
18
|
-
|
19
|
+
|
19
20
|
# @param [Symbol] type
|
20
21
|
# @yield [e]
|
21
|
-
# @yieldparam [
|
22
|
+
# @yieldparam [Thinreports::Core::Events::Event] e
|
22
23
|
def listen(type, &block)
|
23
24
|
verify_event_type(type)
|
24
|
-
|
25
|
+
|
25
26
|
if block_given?
|
26
27
|
events[type] = block
|
27
28
|
else
|
@@ -29,14 +30,13 @@ module ThinReports
|
|
29
30
|
end
|
30
31
|
end
|
31
32
|
alias_method :on, :listen
|
32
|
-
|
33
|
+
|
33
34
|
# @param [Symbol] type
|
34
35
|
def unlisten(type)
|
35
36
|
events.delete(type)
|
36
37
|
end
|
37
38
|
alias_method :un, :unlisten
|
38
|
-
|
39
|
-
# @private
|
39
|
+
|
40
40
|
def dispatch(e)
|
41
41
|
unless e.type
|
42
42
|
raise ArgumentError, 'Event#type attribute is required'
|
@@ -47,22 +47,21 @@ module ThinReports
|
|
47
47
|
event.call(e)
|
48
48
|
end
|
49
49
|
end
|
50
|
-
|
51
|
-
# @private
|
50
|
+
|
52
51
|
def copy
|
53
52
|
new_events = self.dup
|
54
|
-
new_events.events = events
|
53
|
+
new_events.events = deep_copy(events)
|
55
54
|
new_events
|
56
55
|
end
|
57
|
-
|
56
|
+
|
58
57
|
private
|
59
|
-
|
58
|
+
|
60
59
|
# @param [Symbol] type
|
61
60
|
def verify_event_type(type)
|
62
61
|
return if @types.empty?
|
63
|
-
|
62
|
+
|
64
63
|
unless @types.include?(type)
|
65
|
-
raise
|
64
|
+
raise Thinreports::Errors::UnknownEventType
|
66
65
|
end
|
67
66
|
end
|
68
67
|
end
|
@@ -1,52 +1,52 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
require 'thinreports/core/format/builder'
|
3
|
+
|
4
|
+
module Thinreports::Core
|
5
|
+
module Format
|
2
6
|
|
3
|
-
module ThinReports
|
4
|
-
module Core::Format
|
5
|
-
|
6
7
|
# @abstract
|
7
|
-
# @private
|
8
8
|
class Base
|
9
|
+
extend Format::Builder
|
10
|
+
|
9
11
|
class << self
|
10
|
-
include Core::Format::Builder
|
11
|
-
|
12
12
|
def config_reader(*configs, &block)
|
13
13
|
each_configs(*configs) do |m, location|
|
14
14
|
define_read_method(m, location, &block)
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def config_checker(check, *configs)
|
19
19
|
checker = lambda {|val| val == check}
|
20
20
|
each_configs(*configs) do |m, location|
|
21
21
|
define_read_method(:"#{m}?", location, &checker)
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def config_writer(*configs)
|
26
26
|
each_configs(*configs) do |m, location|
|
27
27
|
define_write_method(m, location)
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
def config_accessor(*configs, &block)
|
32
32
|
config_reader(*configs, &block)
|
33
33
|
config_writer(*configs)
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
private
|
37
|
-
|
37
|
+
|
38
38
|
def define_read_method(m, location = nil, &block)
|
39
39
|
define_method(m) do
|
40
40
|
read(*location, &block)
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def define_write_method(m, location = nil)
|
45
45
|
define_method(:"#{m}=") do |value|
|
46
46
|
write(value, *location)
|
47
47
|
end
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
def each_configs(*configs, &block)
|
51
51
|
c = configs.first.is_a?(::Hash) ? configs.first : (configs || [])
|
52
52
|
c.each do |m, location|
|
@@ -54,14 +54,14 @@ module ThinReports
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
def initialize(config, &block)
|
59
59
|
@config = config
|
60
60
|
block.call(self) if ::Kernel.block_given?
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
private
|
64
|
-
|
64
|
+
|
65
65
|
def find(*keys)
|
66
66
|
if keys.empty?
|
67
67
|
@config
|
@@ -71,18 +71,18 @@ module ThinReports
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
def write(value, *keys)
|
76
76
|
key = keys.pop
|
77
77
|
owner = find(*keys)
|
78
78
|
owner[key] = value
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
def read(*keys, &block)
|
82
82
|
value = find(*keys)
|
83
83
|
::Kernel.block_given? ? block.call(value) : value
|
84
84
|
end
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
end
|
88
|
-
end
|
88
|
+
end
|
@@ -1,33 +1,25 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
'Please `gem install json` and try again.'
|
8
|
-
end
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Thinreports::Core
|
6
|
+
module Format
|
9
7
|
|
10
|
-
module ThinReports
|
11
|
-
module Core::Format
|
12
|
-
|
13
|
-
# @private
|
14
8
|
module Builder
|
15
9
|
def build(*args)
|
16
10
|
build_internal(*args)
|
17
|
-
rescue
|
11
|
+
rescue Thinreports::Errors::Basic => e
|
18
12
|
raise
|
19
13
|
rescue => e
|
20
|
-
raise
|
14
|
+
raise Thinreports::Errors::InvalidLayoutFormat
|
21
15
|
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
16
|
+
|
25
17
|
# @abstract
|
26
18
|
def build_internal(*args)
|
27
19
|
raise NotImplementedError
|
28
20
|
end
|
29
21
|
|
30
|
-
# @param [
|
22
|
+
# @param [Thinreports::Core::Format::Base] format
|
31
23
|
# @param [Hash] options
|
32
24
|
def build_layout(format, options = {}, &block)
|
33
25
|
level = '-' * ((options[:level] || 1 ) - 1)
|
@@ -39,23 +31,23 @@ module ThinReports
|
|
39
31
|
end
|
40
32
|
format.layout.gsub!(pattern, '')
|
41
33
|
end
|
42
|
-
|
34
|
+
|
43
35
|
# @param [String] svg
|
44
36
|
def clean(svg)
|
45
37
|
svg.gsub!(/<!--.*?-->/, '')
|
46
38
|
end
|
47
|
-
|
39
|
+
|
48
40
|
# @param [String] svg
|
49
41
|
def clean_with_attributes(svg)
|
50
42
|
clean(svg)
|
51
43
|
svg.gsub!(/ x\-[a-z\d\-]+?=".*?"/, '')
|
52
|
-
svg.gsub!(/ class=".*?"/, '')
|
44
|
+
svg.gsub!(/ class=".*?"/, '')
|
53
45
|
end
|
54
|
-
|
46
|
+
|
55
47
|
def shape_tag(format)
|
56
48
|
%{<%= r(:"#{format.id}")%>}
|
57
49
|
end
|
58
|
-
|
50
|
+
|
59
51
|
def parsed_format_and_shape_type(json_string)
|
60
52
|
f = parse_json(json_string)
|
61
53
|
[ f['type'], f ]
|
@@ -65,6 +57,6 @@ module ThinReports
|
|
65
57
|
JSON.parse(json_string)
|
66
58
|
end
|
67
59
|
end
|
68
|
-
|
60
|
+
|
69
61
|
end
|
70
62
|
end
|
@@ -1,31 +1,27 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Core
|
5
|
-
|
5
|
+
|
6
6
|
module Shape
|
7
|
-
# @private
|
8
7
|
def Interface(parent, format)
|
9
8
|
find_by_type(format.type)::Interface.new(parent, format)
|
10
9
|
end
|
11
|
-
|
12
|
-
# @private
|
10
|
+
|
13
11
|
def Format(type)
|
14
12
|
find_by_type(type)::Format
|
15
13
|
end
|
16
|
-
|
17
|
-
# @private
|
14
|
+
|
18
15
|
def Configuration(type)
|
19
16
|
klass = find_by_type(type)
|
20
17
|
unless klass.const_defined?(:Configuration)
|
21
|
-
raise
|
18
|
+
raise Thinreports::Errors::NoConfigurationFound, type
|
22
19
|
end
|
23
20
|
klass.const_get(:Configuration)
|
24
21
|
end
|
25
|
-
|
22
|
+
|
26
23
|
module_function :Interface, :Format, :Configuration
|
27
|
-
|
28
|
-
# @private
|
24
|
+
|
29
25
|
def self.find_by_type(type)
|
30
26
|
case type
|
31
27
|
when TextBlock::TYPE_NAME then TextBlock
|
@@ -35,11 +31,11 @@ module ThinReports
|
|
35
31
|
when PageNumber::TYPE_NAME then PageNumber
|
36
32
|
when *Basic::TYPE_NAMES then Basic
|
37
33
|
else
|
38
|
-
raise
|
34
|
+
raise Thinreports::Errors::UnknownShapeType
|
39
35
|
end
|
40
36
|
end
|
41
37
|
end
|
42
|
-
|
38
|
+
|
43
39
|
end
|
44
40
|
end
|
45
41
|
|
@@ -2,15 +2,14 @@
|
|
2
2
|
|
3
3
|
require 'forwardable'
|
4
4
|
|
5
|
-
module
|
5
|
+
module Thinreports
|
6
6
|
module Core::Shape
|
7
|
-
|
8
|
-
# @private
|
7
|
+
|
9
8
|
module Base
|
10
9
|
end
|
11
|
-
|
10
|
+
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
15
14
|
require 'thinreports/core/shape/base/internal'
|
16
|
-
require 'thinreports/core/shape/base/interface'
|
15
|
+
require 'thinreports/core/shape/base/interface'
|
@@ -1,38 +1,38 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Core::Shape
|
5
|
-
|
6
|
-
# @private
|
5
|
+
|
7
6
|
# @abstract
|
8
7
|
class Base::Interface
|
9
|
-
|
10
|
-
|
8
|
+
include Utils
|
9
|
+
extend Forwardable
|
10
|
+
|
11
11
|
def self.internal_delegators(*args)
|
12
12
|
def_delegators :internal, *args
|
13
13
|
end
|
14
14
|
private_class_method :internal_delegators
|
15
|
-
|
15
|
+
|
16
16
|
attr_reader :internal
|
17
|
-
|
17
|
+
|
18
18
|
def initialize(parent, format, internal = nil)
|
19
19
|
@internal = internal || init_internal(parent, format)
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def copy(parent)
|
23
23
|
self.class.new(parent, internal.format, internal.copy(parent))
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
private
|
27
|
-
|
28
|
-
# @param [
|
29
|
-
# @param [
|
30
|
-
# @return [
|
27
|
+
|
28
|
+
# @param [Thinreports::Report::Page, Thinreports::Core::Shape::List::SectionInterface] parent
|
29
|
+
# @param [Thinreports::Core::Shape::Basic::Format] format
|
30
|
+
# @return [Thinreports::Core::Shape::Basic::Internal]
|
31
31
|
# @abstract
|
32
32
|
def init_internal(parent, format)
|
33
33
|
raise NotImplementedError
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
end
|
38
|
-
end
|
38
|
+
end
|
@@ -1,54 +1,49 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Core::Shape
|
5
|
-
|
6
|
-
# @private
|
5
|
+
|
7
6
|
# @abstract
|
8
7
|
class Base::Internal
|
9
|
-
|
10
|
-
|
8
|
+
include Utils
|
9
|
+
extend Forwardable
|
10
|
+
|
11
11
|
def self.format_delegators(*args)
|
12
12
|
def_delegators :format, *args
|
13
13
|
end
|
14
14
|
private_class_method :format_delegators
|
15
|
-
|
15
|
+
|
16
16
|
attr_reader :parent
|
17
17
|
attr_reader :format
|
18
18
|
attr_writer :style
|
19
19
|
attr_accessor :states
|
20
|
-
|
20
|
+
|
21
21
|
def initialize(parent, format)
|
22
22
|
@parent = parent
|
23
23
|
@format = format
|
24
24
|
@states = {}
|
25
25
|
@style = nil
|
26
|
-
|
26
|
+
|
27
27
|
@finalized_attributes = nil
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def style
|
31
31
|
raise NotImplementedError
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
def copy(new_parent, &block)
|
35
35
|
new_internal = self.class.new(new_parent, format)
|
36
36
|
new_internal.style = style.copy
|
37
|
-
new_internal.states = states
|
38
|
-
|
37
|
+
new_internal.states = deep_copy(states)
|
38
|
+
|
39
39
|
block.call(new_internal) if block_given?
|
40
40
|
new_internal
|
41
41
|
end
|
42
|
-
|
43
|
-
def switch_parent!(new_parent)
|
44
|
-
@parent = new_parent
|
45
|
-
self
|
46
|
-
end
|
47
|
-
|
42
|
+
|
48
43
|
def type_of?(type_name)
|
49
44
|
raise NotImplementedError
|
50
45
|
end
|
51
46
|
end
|
52
|
-
|
47
|
+
|
53
48
|
end
|
54
|
-
end
|
49
|
+
end
|