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,6 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Report
|
5
5
|
|
6
6
|
class Events < Core::Events
|
@@ -9,14 +9,14 @@ module ThinReports
|
|
9
9
|
:generate)
|
10
10
|
end
|
11
11
|
|
12
|
-
class Event <
|
13
|
-
# @return [
|
12
|
+
class Event < Thinreports::Core::Events::Event
|
13
|
+
# @return [Thinreports::Report::Page, nil]
|
14
14
|
attr_reader :page
|
15
15
|
|
16
|
-
# @return [Array<
|
16
|
+
# @return [Array<Thinreports::Report::Page>]
|
17
17
|
attr_reader :pages
|
18
18
|
|
19
|
-
# @return [
|
19
|
+
# @return [Thinreports::Report::Base]
|
20
20
|
alias_method :report, :target
|
21
21
|
|
22
22
|
def initialize(type, target, page = nil, pages = nil)
|
@@ -1,9 +1,8 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
3
|
+
module Thinreports
|
4
4
|
module Report
|
5
|
-
|
6
|
-
# @private
|
5
|
+
|
7
6
|
class Internal
|
8
7
|
attr_reader :pages
|
9
8
|
attr_reader :page
|
@@ -11,9 +10,12 @@ module ThinReports
|
|
11
10
|
attr_reader :default_layout
|
12
11
|
attr_reader :layout_registry
|
13
12
|
attr_reader :events
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
|
14
|
+
attr_accessor :page_create_handler
|
15
|
+
attr_accessor :generate_handler
|
16
|
+
|
17
|
+
# @param [Thinreports::Report::Base] report
|
18
|
+
# @param options (see Thinreports::Report::Base#initialize)
|
17
19
|
def initialize(report, options)
|
18
20
|
@report = report
|
19
21
|
# Default layout
|
@@ -24,17 +26,20 @@ module ThinReports
|
|
24
26
|
@pages = []
|
25
27
|
@page = nil
|
26
28
|
@page_count = 0
|
27
|
-
|
29
|
+
|
30
|
+
@page_create_handler = nil
|
31
|
+
@generate_handler = nil
|
32
|
+
|
28
33
|
@events = Report::Events.new
|
29
34
|
end
|
30
|
-
|
31
|
-
# @see
|
35
|
+
|
36
|
+
# @see Thinreports::Report::Base#use_layout
|
32
37
|
def register_layout(layout, options = {}, &block)
|
33
38
|
layout = if options.empty? || options[:default]
|
34
39
|
@default_layout = init_layout(layout)
|
35
40
|
else
|
36
41
|
id = options[:id].to_sym
|
37
|
-
|
42
|
+
|
38
43
|
if layout_registry.key?(id)
|
39
44
|
raise ArgumentError, "Id :#{id} is already in use."
|
40
45
|
end
|
@@ -42,35 +47,37 @@ module ThinReports
|
|
42
47
|
end
|
43
48
|
layout.config(&block)
|
44
49
|
end
|
45
|
-
|
50
|
+
|
46
51
|
def add_page(new_page)
|
47
52
|
finalize_current_page
|
48
53
|
insert_page(new_page)
|
49
54
|
end
|
50
|
-
|
55
|
+
|
51
56
|
def copy_page
|
52
|
-
finalize_current_page(:
|
57
|
+
finalize_current_page(at: :copy)
|
53
58
|
insert_page(page.copy)
|
54
59
|
end
|
55
|
-
|
60
|
+
|
56
61
|
def finalize
|
57
62
|
unless finalized?
|
58
63
|
finalize_current_page
|
59
64
|
@finalized = true
|
60
|
-
|
61
|
-
#
|
65
|
+
|
66
|
+
# [DEPRECATION] Please use Report::Base#on_generate callback instead.
|
62
67
|
events.dispatch(Report::Events::Event.new(:generate,
|
63
68
|
@report, nil, pages))
|
69
|
+
|
70
|
+
@generate_handler.call(pages) if @generate_handler
|
64
71
|
end
|
65
72
|
end
|
66
|
-
|
73
|
+
|
67
74
|
def finalized?
|
68
75
|
@finalized
|
69
76
|
end
|
70
|
-
|
77
|
+
|
71
78
|
def load_layout(id_or_filename)
|
72
79
|
return @default_layout if id_or_filename.nil?
|
73
|
-
|
80
|
+
|
74
81
|
layout = case id_or_filename
|
75
82
|
when Symbol
|
76
83
|
layout_registry[id_or_filename]
|
@@ -82,49 +89,50 @@ module ThinReports
|
|
82
89
|
@default_layout = layout unless @default_layout
|
83
90
|
layout
|
84
91
|
end
|
85
|
-
|
92
|
+
|
86
93
|
private
|
87
|
-
|
94
|
+
|
88
95
|
def insert_page(new_page)
|
89
96
|
@pages << new_page
|
90
|
-
|
97
|
+
|
91
98
|
if new_page.count?
|
92
99
|
@page_count += 1
|
93
100
|
new_page.no = @page_count
|
94
101
|
end
|
95
|
-
|
96
|
-
# But do not dispatch if page is blank-page.
|
102
|
+
|
97
103
|
unless new_page.blank?
|
104
|
+
# [DEPRECATION] Please use #on_page_create callback instead.
|
98
105
|
events.dispatch(Report::Events::Event.new(:page_create,
|
99
106
|
@report,
|
100
107
|
new_page))
|
108
|
+
@page_create_handler.call(new_page) if @page_create_handler
|
101
109
|
end
|
102
110
|
@page = new_page
|
103
111
|
end
|
104
|
-
|
105
|
-
# @param (see
|
112
|
+
|
113
|
+
# @param (see Thinreports::Report::Page#finalize)
|
106
114
|
def finalize_current_page(options = {})
|
107
|
-
page.finalize(options) unless page.blank?
|
115
|
+
page.finalize(options) unless page.nil? || page.blank?
|
108
116
|
end
|
109
|
-
|
117
|
+
|
110
118
|
def prepare_layout(layout)
|
111
119
|
return nil if layout.nil?
|
112
|
-
|
120
|
+
|
113
121
|
case layout
|
114
122
|
when String
|
115
123
|
init_layout(layout)
|
116
124
|
# @note Currently not used. Since 0.6.0?
|
117
|
-
when
|
125
|
+
when Thinreports::Layout::Base
|
118
126
|
layout
|
119
127
|
else
|
120
128
|
raise ArgumentError, 'Invalid argument for layout.'
|
121
129
|
end
|
122
130
|
end
|
123
|
-
|
131
|
+
|
124
132
|
def init_layout(filename, id = nil)
|
125
|
-
|
133
|
+
Thinreports::Layout.new(filename, id: id)
|
126
134
|
end
|
127
135
|
end
|
128
|
-
|
136
|
+
|
129
137
|
end
|
130
138
|
end
|
@@ -1,93 +1,101 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
module
|
4
|
-
module
|
5
|
-
|
3
|
+
module Thinreports
|
4
|
+
module Report
|
5
|
+
|
6
6
|
class BlankPage
|
7
|
+
# @example
|
8
|
+
# 3.times do
|
9
|
+
# page = report.start_new_page
|
10
|
+
# puts page.no
|
11
|
+
# end
|
12
|
+
# # => 1, 2, 3
|
7
13
|
# @return [Integer]
|
8
14
|
attr_accessor :no
|
9
|
-
|
15
|
+
|
10
16
|
# @param [Boolean] count (nil)
|
11
17
|
def initialize(count = nil)
|
12
18
|
@count = count.nil? ? true : count
|
13
19
|
end
|
14
|
-
|
20
|
+
|
21
|
+
# @example
|
22
|
+
# page = report.start_new_page
|
23
|
+
# page.count? # => true
|
24
|
+
#
|
25
|
+
# page = report.start_new_page count: false
|
26
|
+
# page.count? # => false
|
15
27
|
# @return [Boolean]
|
16
28
|
def count?
|
17
29
|
@count
|
18
30
|
end
|
19
|
-
|
31
|
+
|
20
32
|
# @return [Boolean] (true)
|
21
33
|
def blank?
|
22
34
|
true
|
23
35
|
end
|
24
36
|
end
|
25
|
-
|
37
|
+
|
26
38
|
class Page < BlankPage
|
27
39
|
include Core::Shape::Manager::Target
|
28
|
-
|
29
|
-
# @return [
|
30
|
-
# @private
|
40
|
+
|
41
|
+
# @return [Thinreports::Report::Base]
|
31
42
|
attr_reader :report
|
32
|
-
|
33
|
-
# @return [
|
43
|
+
|
44
|
+
# @return [Thinreports::Layout::Base]
|
34
45
|
attr_reader :layout
|
35
|
-
|
36
|
-
# @param [
|
37
|
-
# @param [
|
46
|
+
|
47
|
+
# @param [Thinreports::Report::Base] report
|
48
|
+
# @param [Thinreports::Layout::Base] layout
|
38
49
|
# @param [Hash] options ({})
|
39
50
|
# @option options [Boolean] :count (true)
|
40
51
|
def initialize(report, layout, options = {})
|
41
52
|
super(options.key?(:count) ? options[:count] : true)
|
42
|
-
|
53
|
+
|
43
54
|
@report = report
|
44
55
|
@layout = layout
|
45
56
|
@finalized = false
|
46
|
-
|
57
|
+
|
47
58
|
initialize_manager(layout.format) do |f|
|
48
59
|
Core::Shape::Interface(self, f)
|
49
60
|
end
|
50
61
|
end
|
51
|
-
|
62
|
+
|
52
63
|
# @return [Boolean] (false)
|
53
64
|
def blank?
|
54
65
|
false
|
55
66
|
end
|
56
|
-
|
57
|
-
# @private
|
67
|
+
|
58
68
|
def copy
|
59
|
-
new_page = self.class.new(report, layout, :
|
60
|
-
|
69
|
+
new_page = self.class.new(report, layout, count: count?)
|
70
|
+
|
61
71
|
manager.shapes.each do |id, shape|
|
62
72
|
new_shape = shape.copy(new_page)
|
63
73
|
new_page.manager.shapes[id] = new_shape
|
64
|
-
|
74
|
+
|
65
75
|
if new_shape.internal.type_of?(:list)
|
66
76
|
new_page.manager.lists[id] = new_shape
|
67
77
|
end
|
68
78
|
end
|
69
79
|
new_page
|
70
80
|
end
|
71
|
-
|
81
|
+
|
72
82
|
# @param [Hash] options
|
73
83
|
# @option options [:create, :copy] :at (:create)
|
74
|
-
# @private
|
75
84
|
def finalize(options = {})
|
76
85
|
at = options[:at] || :create
|
77
|
-
|
86
|
+
|
78
87
|
# For list shapes.
|
79
88
|
if at == :create
|
80
89
|
manager.lists.values.each {|list| list.manager.finalize }
|
81
90
|
end
|
82
|
-
|
91
|
+
|
83
92
|
@finalized = true
|
84
93
|
end
|
85
|
-
|
86
|
-
# @private
|
94
|
+
|
87
95
|
def finalized?
|
88
96
|
@finalized
|
89
97
|
end
|
90
98
|
end
|
91
|
-
|
99
|
+
|
92
100
|
end
|
93
101
|
end
|
data/lib/thinreports/version.rb
CHANGED
data/test/data/font.ttf
ADDED
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":"0.8.0","config":{"title":"","option":{},"page":{"paper-type":"A4","orientation":"portrait","margin-top":"20","margin-bottom":"20","margin-left":"20","margin-right":"20"}},"svg":"<svg width=\"595.2\" height=\"841.8\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" preserveAspectRatio=\"none\" viewBox=\"0 0 595.2 841.8\"><g class=\"canvas\"><!--SHAPE{\"type\":\"s-tblock\",\"id\":\"text_block1\",\"display\":\"true\",\"desc\":null,\"multiple\":\"false\",\"valign\":\"\",\"line-height\":\"\",\"box\":{\"x\":40,\"y\":60.9,\"width\":291.7,\"height\":21},\"inline-format\":\"false\",\"format\":{\"base\":\"\",\"type\":\"\"},\"value\":\"\",\"ref-id\":\"\",\"overflow\":\"\",\"word-wrap\":\"none\",\"svg\":{\"tag\":\"text\",\"attrs\":{\"x\":40,\"y\":77.9,\"xml:space\":\"preserve\",\"kerning\":\"auto\",\"letter-spacing\":\"normal\",\"id\":\"goog_773191970\",\"fill\":\"#000000\",\"fill-opacity\":\"1\",\"font-size\":\"18\",\"font-family\":\"Helvetica\",\"font-weight\":\"normal\",\"font-style\":\"normal\",\"text-anchor\":\"start\",\"text-decoration\":\"none\"}}}SHAPE--><!--LAYOUT<g xmlns=\"http://www.w3.org/2000/svg\" class=\"s-tblock\" x-format-type=\"\" x-value=\"\" x-format-base=\"\" x-ref-id=\"\" kerning=\"auto\" letter-spacing=\"normal\" x-display=\"true\" x-multiple=\"false\" id=\"goog_773191970\" x-id=\"text_block1\" fill=\"#000000\" fill-opacity=\"1\" font-size=\"18\" font-family=\"Helvetica\" font-weight=\"normal\" font-style=\"normal\" text-anchor=\"start\" text-decoration=\"none\" x-width=\"291.7\" x-height=\"21\" x-left=\"40\" x-top=\"60.9\"><rect class=\"s-tblock-box\" stroke=\"none\" fill=\"#0096fd\" fill-opacity=\"0.2\" width=\"291.7\" height=\"21\" x=\"40\" y=\"60.9\"/><text class=\"s-tblock-id\" font-size=\"10.5\" font-family=\"Helvetica\" font-weight=\"normal\" font-style=\"normal\" text-decoration=\"none\" text-anchor=\"start\" kerning=\"auto\" stroke=\"none\" fill=\"#0096fd\" fill-opacity=\"1\" x=\"44\" y=\"71.9\">text_block1</text></g>LAYOUT--><!--SHAPE{\"type\":\"s-tblock\",\"id\":\"text_block2\",\"display\":\"true\",\"desc\":null,\"multiple\":\"false\",\"valign\":\"\",\"line-height\":\"\",\"box\":{\"x\":40,\"y\":95,\"width\":291.7,\"height\":21},\"inline-format\":\"false\",\"format\":{\"base\":\"\",\"type\":\"\"},\"value\":\"\",\"ref-id\":\"\",\"overflow\":\"truncate\",\"word-wrap\":\"none\",\"svg\":{\"tag\":\"text\",\"attrs\":{\"x\":40,\"y\":112,\"xml:space\":\"preserve\",\"kerning\":\"auto\",\"letter-spacing\":\"normal\",\"id\":\"goog_773191972\",\"fill\":\"#000000\",\"fill-opacity\":\"1\",\"font-size\":\"18\",\"font-family\":\"Helvetica\",\"font-weight\":\"normal\",\"font-style\":\"normal\",\"text-decoration\":\"none\",\"text-anchor\":\"start\"}}}SHAPE--><!--LAYOUT<g xmlns=\"http://www.w3.org/2000/svg\" class=\"s-tblock\" x-format-type=\"\" x-value=\"\" x-format-base=\"\" x-ref-id=\"\" kerning=\"auto\" letter-spacing=\"normal\" x-display=\"true\" x-multiple=\"false\" id=\"goog_773191972\" x-id=\"text_block2\" x-width=\"291.7\" x-height=\"21\" x-left=\"40\" x-top=\"95\" fill=\"#000000\" fill-opacity=\"1\" font-size=\"18\" font-family=\"Helvetica\" font-weight=\"normal\" font-style=\"normal\" text-decoration=\"none\" text-anchor=\"start\" x-overflow=\"truncate\" x-word-wrap=\"none\" x-inline-format=\"false\"><rect class=\"s-tblock-box\" stroke=\"none\" fill=\"#0096fd\" fill-opacity=\"0.2\" width=\"291.7\" height=\"21\" x=\"40\" y=\"95\"/><text class=\"s-tblock-id\" font-size=\"10.5\" font-family=\"Helvetica\" font-weight=\"normal\" font-style=\"normal\" text-decoration=\"none\" text-anchor=\"start\" kerning=\"auto\" stroke=\"none\" fill=\"#0096fd\" fill-opacity=\"1\" x=\"44\" y=\"106\">text_block2</text></g>LAYOUT--><!--SHAPE{\"type\":\"s-iblock\",\"id\":\"image_block1\",\"display\":\"true\",\"desc\":null,\"box\":{\"x\":40,\"y\":150,\"width\":288.7,\"height\":127.8},\"position-x\":\"left\",\"position-y\":\"top\",\"svg\":{\"tag\":\"image\",\"attrs\":{\"x\":40,\"y\":150,\"width\":288.7,\"height\":127.8}}}SHAPE--><!--LAYOUT<g xmlns=\"http://www.w3.org/2000/svg\" class=\"s-iblock\" x-display=\"true\" id=\"goog_773191973\" x-id=\"image_block1\" x-width=\"288.7\" x-height=\"127.8\" x-left=\"40\" x-top=\"150\"><rect class=\"s-iblock-box\" stroke=\"none\" fill=\"#0096fd\" fill-opacity=\"0.2\" width=\"288.7\" height=\"127.8\" x=\"40\" y=\"150\"/><image width=\"16\" height=\"16\" class=\"s-iblock-mark\" opacity=\"0.5\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xlink:href=\"assets/icons/x-image-mark.svg\" display=\"inline\" x=\"176\" y=\"205\"/><text class=\"s-iblock-id\" font-size=\"10.5\" font-family=\"Helvetica\" font-weight=\"normal\" font-style=\"normal\" text-decoration=\"none\" text-anchor=\"start\" kerning=\"auto\" stroke=\"none\" fill=\"#0096fd\" fill-opacity=\"1\" x=\"44\" y=\"161\">image_block1</text></g>LAYOUT--><!--SHAPE{\"type\":\"s-iblock\",\"id\":\"image_block2\",\"display\":\"true\",\"desc\":null,\"box\":{\"x\":40,\"y\":295,\"width\":288.7,\"height\":127.8},\"position-x\":\"left\",\"position-y\":\"top\",\"svg\":{\"tag\":\"image\",\"attrs\":{\"x\":40,\"y\":295,\"width\":288.7,\"height\":127.8}}}SHAPE--><!--LAYOUT<g xmlns=\"http://www.w3.org/2000/svg\" class=\"s-iblock\" x-display=\"true\" id=\"goog_773191974\" x-id=\"image_block2\" x-width=\"288.7\" x-height=\"127.8\" x-left=\"40\" x-top=\"295\" x-position-x=\"left\" x-position-y=\"top\"><rect class=\"s-iblock-box\" stroke=\"none\" fill=\"#0096fd\" fill-opacity=\"0.2\" width=\"288.7\" height=\"127.8\" x=\"40\" y=\"295\"/><image width=\"16\" height=\"16\" class=\"s-iblock-mark\" opacity=\"0.5\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xlink:href=\"assets/icons/x-image-mark.svg\" display=\"inline\" x=\"176\" y=\"350\"/><text class=\"s-iblock-id\" font-size=\"10.5\" font-family=\"Helvetica\" font-weight=\"normal\" font-style=\"normal\" text-decoration=\"none\" text-anchor=\"start\" kerning=\"auto\" stroke=\"none\" fill=\"#0096fd\" fill-opacity=\"1\" x=\"44\" y=\"306\">image_block2</text></g>LAYOUT--></g></svg>","state":{"layout-guide":[]}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":"0.7.7.1","finger-print":-1511277400,"config":{"title":"Basic List Layout","option":{},"page":{"paper-type":"A4","orientation":"portrait","margin-top":"20","margin-bottom":"20","margin-left":"20","margin-right":"20"}},"svg":"<svg width=\"595.2\" height=\"841.8\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" preserveAspectRatio=\"none\" viewBox=\"0 0 595.2 841.8\"><g class=\"canvas\"><!--SHAPE{\"type\":\"s-list\",\"id\":\"list\",\"display\":\"true\",\"desc\":null,\"footer\":{\"height\":55.5,\"svg\":{\"tag\":\"g\",\"content\":\"<g xmlns=\\\"http://www.w3.org/2000/svg\\\" class=\\\"s-text\\\" stroke-width=\\\"0\\\" fill=\\\"#000000\\\" fill-opacity=\\\"1\\\" kerning=\\\"auto\\\" x-display=\\\"true\\\" x-id=\\\"\\\" stroke=\\\"none\\\" font-weight=\\\"normal\\\" font-style=\\\"normal\\\" font-family=\\\"Helvetica\\\" font-size=\\\"18\\\" text-anchor=\\\"start\\\" text-decoration=\\\"none\\\" x-width=\\\"53\\\" x-height=\\\"18\\\" x-left=\\\"271.1\\\" x-top=\\\"318.3\\\" id=\\\"goog_2086231731\\\"><rect class=\\\"s-text-box\\\" stroke=\\\"none\\\" fill=\\\"#000000\\\" fill-opacity=\\\"0.001\\\" width=\\\"53\\\" height=\\\"18\\\" x=\\\"271.1\\\" y=\\\"318.3\\\"/><text class=\\\"s-text-l0\\\" xml:space=\\\"preserve\\\" stroke=\\\"none\\\" fill=\\\"inherit\\\" fill-opacity=\\\"1\\\" text-decoration=\\\"none\\\" x=\\\"271.1\\\" y=\\\"335.3\\\">Footer</text></g>\"},\"translate\":{\"x\":0,\"y\":-217.5}},\"footer-enabled\":\"true\",\"page-footer\":{\"height\":55.5,\"svg\":{\"tag\":\"g\",\"content\":\"<g xmlns=\\\"http://www.w3.org/2000/svg\\\" class=\\\"s-text\\\" stroke-width=\\\"0\\\" fill=\\\"#000000\\\" fill-opacity=\\\"1\\\" kerning=\\\"auto\\\" x-display=\\\"true\\\" x-id=\\\"\\\" stroke=\\\"none\\\" font-weight=\\\"normal\\\" font-style=\\\"normal\\\" font-family=\\\"Helvetica\\\" font-size=\\\"18\\\" text-anchor=\\\"start\\\" text-decoration=\\\"none\\\" x-width=\\\"99\\\" x-height=\\\"18\\\" x-left=\\\"248.1\\\" x-top=\\\"262.8\\\" id=\\\"goog_2086231730\\\"><rect class=\\\"s-text-box\\\" stroke=\\\"none\\\" fill=\\\"#000000\\\" fill-opacity=\\\"0.001\\\" width=\\\"99\\\" height=\\\"18\\\" x=\\\"248.1\\\" y=\\\"262.8\\\"/><text class=\\\"s-text-l0\\\" xml:space=\\\"preserve\\\" stroke=\\\"none\\\" fill=\\\"inherit\\\" fill-opacity=\\\"1\\\" text-decoration=\\\"none\\\" x=\\\"248.1\\\" y=\\\"279.8\\\">Page Footer</text></g>\"},\"translate\":{\"x\":0,\"y\":-162}},\"page-footer-enabled\":\"true\",\"detail\":{\"height\":50,\"svg\":{\"tag\":\"g\",\"content\":\"<g xmlns=\\\"http://www.w3.org/2000/svg\\\" class=\\\"s-text\\\" stroke-width=\\\"0\\\" fill=\\\"#000000\\\" fill-opacity=\\\"1\\\" kerning=\\\"auto\\\" x-display=\\\"true\\\" x-id=\\\"\\\" font-size=\\\"18\\\" font-family=\\\"Helvetica\\\" font-weight=\\\"normal\\\" font-style=\\\"normal\\\" text-anchor=\\\"start\\\" text-decoration=\\\"none\\\" x-width=\\\"47\\\" x-height=\\\"18\\\" x-left=\\\"274.1\\\" x-top=\\\"186\\\" id=\\\"goog_2086231729\\\"><rect class=\\\"s-text-box\\\" stroke=\\\"none\\\" fill=\\\"#000000\\\" fill-opacity=\\\"0.001\\\" width=\\\"47\\\" height=\\\"18\\\" x=\\\"274.1\\\" y=\\\"186\\\"/><text class=\\\"s-text-l0\\\" xml:space=\\\"preserve\\\" stroke=\\\"none\\\" fill=\\\"inherit\\\" fill-opacity=\\\"1\\\" text-decoration=\\\"none\\\" x=\\\"274.1\\\" y=\\\"203\\\">Detail</text></g>\"},\"translate\":{\"x\":0,\"y\":-88}},\"header\":{\"height\":61,\"svg\":{\"tag\":\"g\",\"content\":\"<g xmlns=\\\"http://www.w3.org/2000/svg\\\" class=\\\"s-text\\\" stroke-width=\\\"0\\\" fill=\\\"#000000\\\" fill-opacity=\\\"1\\\" kerning=\\\"auto\\\" x-display=\\\"true\\\" x-id=\\\"\\\" font-size=\\\"18\\\" font-family=\\\"Helvetica\\\" font-weight=\\\"normal\\\" font-style=\\\"normal\\\" text-anchor=\\\"start\\\" text-decoration=\\\"none\\\" x-width=\\\"60\\\" x-height=\\\"18\\\" x-left=\\\"267.6\\\" x-top=\\\"116\\\" id=\\\"goog_2086231728\\\"><rect class=\\\"s-text-box\\\" stroke=\\\"none\\\" fill=\\\"#000000\\\" fill-opacity=\\\"0.001\\\" width=\\\"60\\\" height=\\\"18\\\" x=\\\"267.6\\\" y=\\\"116\\\"/><text class=\\\"s-text-l0\\\" xml:space=\\\"preserve\\\" stroke=\\\"none\\\" fill=\\\"inherit\\\" fill-opacity=\\\"1\\\" text-decoration=\\\"none\\\" x=\\\"267.6\\\" y=\\\"133\\\">Header</text></g>\"},\"translate\":{\"x\":0,\"y\":-75}},\"header-enabled\":\"true\",\"svg\":{\"tag\":\"g\",\"attrs\":{}},\"content-height\":261.1,\"page-break\":\"true\"}SHAPE--><!--LAYOUT<g xmlns=\"http://www.w3.org/2000/svg\" class=\"s-list\" x-id=\"list\" x-header-enabled=\"true\" x-page-footer-enabled=\"true\" x-footer-enabled=\"true\" x-changing-page=\"true\" x-display=\"true\" width=\"555.2\" height=\"322.1\" x=\"20\" y=\"21\" id=\"goog_2086231732\"><g class=\"s-list-header\" transform=\"translate(0,-75) rotate(0 0 0)\" x-top=\"21\" x-height=\"61\"><g class=\"s-text\" stroke-width=\"0\" fill=\"#000000\" fill-opacity=\"1\" kerning=\"auto\" x-display=\"true\" x-id=\"\" font-size=\"18\" font-family=\"Helvetica\" font-weight=\"normal\" font-style=\"normal\" text-anchor=\"start\" text-decoration=\"none\" x-width=\"60\" x-height=\"18\" x-left=\"267.6\" x-top=\"116\" id=\"goog_2086231728\"><rect class=\"s-text-box\" stroke=\"none\" fill=\"#000000\" fill-opacity=\"0.001\" width=\"60\" height=\"18\" x=\"267.6\" y=\"116\"/><text class=\"s-text-l0\" xml:space=\"preserve\" stroke=\"none\" fill=\"inherit\" fill-opacity=\"1\" text-decoration=\"none\" x=\"267.6\" y=\"133\">Header</text></g></g><g class=\"s-list-detail\" transform=\"translate(0,-88) rotate(0 0 0)\" x-top=\"82\" x-height=\"50\"><g class=\"s-text\" stroke-width=\"0\" fill=\"#000000\" fill-opacity=\"1\" kerning=\"auto\" x-display=\"true\" x-id=\"\" font-size=\"18\" font-family=\"Helvetica\" font-weight=\"normal\" font-style=\"normal\" text-anchor=\"start\" text-decoration=\"none\" x-width=\"47\" x-height=\"18\" x-left=\"274.1\" x-top=\"186\" id=\"goog_2086231729\"><rect class=\"s-text-box\" stroke=\"none\" fill=\"#000000\" fill-opacity=\"0.001\" width=\"47\" height=\"18\" x=\"274.1\" y=\"186\"/><text class=\"s-text-l0\" xml:space=\"preserve\" stroke=\"none\" fill=\"inherit\" fill-opacity=\"1\" text-decoration=\"none\" x=\"274.1\" y=\"203\">Detail</text></g></g><g class=\"s-list-page-footer\" transform=\"translate(0,-112) rotate(0 0 0)\" x-top=\"132\" x-height=\"55.5\"><g class=\"s-text\" stroke-width=\"0\" fill=\"#000000\" fill-opacity=\"1\" kerning=\"auto\" x-display=\"true\" x-id=\"\" stroke=\"none\" font-weight=\"normal\" font-style=\"normal\" font-family=\"Helvetica\" font-size=\"18\" text-anchor=\"start\" text-decoration=\"none\" x-width=\"99\" x-height=\"18\" x-left=\"248.1\" x-top=\"262.8\" id=\"goog_2086231730\"><rect class=\"s-text-box\" stroke=\"none\" fill=\"#000000\" fill-opacity=\"0.001\" width=\"99\" height=\"18\" x=\"248.1\" y=\"262.8\"/><text class=\"s-text-l0\" xml:space=\"preserve\" stroke=\"none\" fill=\"inherit\" fill-opacity=\"1\" text-decoration=\"none\" x=\"248.1\" y=\"279.8\">Page Footer</text></g></g><g class=\"s-list-footer\" transform=\"translate(0,-112) rotate(0 0 0)\" x-top=\"187.5\" x-height=\"55.5\"><g class=\"s-text\" stroke-width=\"0\" fill=\"#000000\" fill-opacity=\"1\" kerning=\"auto\" x-display=\"true\" x-id=\"\" stroke=\"none\" font-weight=\"normal\" font-style=\"normal\" font-family=\"Helvetica\" font-size=\"18\" text-anchor=\"start\" text-decoration=\"none\" x-width=\"53\" x-height=\"18\" x-left=\"271.1\" x-top=\"318.3\" id=\"goog_2086231731\"><rect class=\"s-text-box\" stroke=\"none\" fill=\"#000000\" fill-opacity=\"0.001\" width=\"53\" height=\"18\" x=\"271.1\" y=\"318.3\"/><text class=\"s-text-l0\" xml:space=\"preserve\" stroke=\"none\" fill=\"inherit\" fill-opacity=\"1\" text-decoration=\"none\" x=\"271.1\" y=\"335.3\">Footer</text></g></g><text class=\"s-list-id\" font-size=\"11\" font-family=\"Helvetica\" font-weight=\"normal\" font-style=\"normal\" text-anchor=\"start\" stroke=\"none\" fill=\"#7C4007\" fill-opacity=\"1\" x=\"22\" y=\"31.8\">list</text><rect stroke-dasharray=\"5\" stroke=\"#BBBBBB\" stroke-width=\"1\" fill=\"#FFFFFF\" fill-opacity=\"0\" class=\"s-list-face\" width=\"555.2\" height=\"322.1\" x=\"20\" y=\"21\"/></g>LAYOUT--></g></svg>","state":{"layout-guide":[]}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":"0.7.7.1","finger-print":1145350506,"config":{"title":"Basic List (No Header) Layout","option":{},"page":{"paper-type":"A4","orientation":"portrait","margin-top":"20","margin-bottom":"20","margin-left":"20","margin-right":"20"}},"svg":"<svg width=\"595.2\" height=\"841.8\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" preserveAspectRatio=\"none\" viewBox=\"0 0 595.2 841.8\"><g class=\"canvas\"><!--SHAPE{\"type\":\"s-list\",\"id\":\"default\",\"display\":\"true\",\"desc\":null,\"footer\":{\"height\":55.5,\"svg\":{\"tag\":\"g\",\"content\":\"<g xmlns=\\\"http://www.w3.org/2000/svg\\\" class=\\\"s-text\\\" stroke-width=\\\"0\\\" fill=\\\"#000000\\\" fill-opacity=\\\"1\\\" kerning=\\\"auto\\\" x-display=\\\"true\\\" x-id=\\\"\\\" stroke=\\\"none\\\" font-weight=\\\"normal\\\" font-style=\\\"normal\\\" font-family=\\\"Helvetica\\\" font-size=\\\"18\\\" text-anchor=\\\"start\\\" text-decoration=\\\"none\\\" x-width=\\\"53\\\" x-height=\\\"18\\\" x-left=\\\"271.1\\\" x-top=\\\"318.3\\\" id=\\\"goog_2086231735\\\"><rect class=\\\"s-text-box\\\" stroke=\\\"none\\\" fill=\\\"#000000\\\" fill-opacity=\\\"0.001\\\" width=\\\"53\\\" height=\\\"18\\\" x=\\\"271.1\\\" y=\\\"318.3\\\"/><text class=\\\"s-text-l0\\\" xml:space=\\\"preserve\\\" stroke=\\\"none\\\" fill=\\\"inherit\\\" fill-opacity=\\\"1\\\" text-decoration=\\\"none\\\" x=\\\"271.1\\\" y=\\\"335.3\\\">Footer</text></g>\"},\"translate\":{\"x\":0,\"y\":-278.5}},\"footer-enabled\":\"true\",\"page-footer\":{\"height\":55.5,\"svg\":{\"tag\":\"g\",\"content\":\"<g xmlns=\\\"http://www.w3.org/2000/svg\\\" class=\\\"s-text\\\" stroke-width=\\\"0\\\" fill=\\\"#000000\\\" fill-opacity=\\\"1\\\" kerning=\\\"auto\\\" x-display=\\\"true\\\" x-id=\\\"\\\" stroke=\\\"none\\\" font-weight=\\\"normal\\\" font-style=\\\"normal\\\" font-family=\\\"Helvetica\\\" font-size=\\\"18\\\" text-anchor=\\\"start\\\" text-decoration=\\\"none\\\" x-width=\\\"99\\\" x-height=\\\"18\\\" x-left=\\\"248.1\\\" x-top=\\\"262.8\\\" id=\\\"goog_2086231734\\\"><rect class=\\\"s-text-box\\\" stroke=\\\"none\\\" fill=\\\"#000000\\\" fill-opacity=\\\"0.001\\\" width=\\\"99\\\" height=\\\"18\\\" x=\\\"248.1\\\" y=\\\"262.8\\\"/><text class=\\\"s-text-l0\\\" xml:space=\\\"preserve\\\" stroke=\\\"none\\\" fill=\\\"inherit\\\" fill-opacity=\\\"1\\\" text-decoration=\\\"none\\\" x=\\\"248.1\\\" y=\\\"279.8\\\">Page Footer</text></g>\"},\"translate\":{\"x\":0,\"y\":-223}},\"page-footer-enabled\":\"true\",\"detail\":{\"height\":50,\"svg\":{\"tag\":\"g\",\"content\":\"<g xmlns=\\\"http://www.w3.org/2000/svg\\\" class=\\\"s-text\\\" stroke-width=\\\"0\\\" fill=\\\"#000000\\\" fill-opacity=\\\"1\\\" kerning=\\\"auto\\\" x-display=\\\"true\\\" x-id=\\\"\\\" font-size=\\\"18\\\" font-family=\\\"Helvetica\\\" font-weight=\\\"normal\\\" font-style=\\\"normal\\\" text-anchor=\\\"start\\\" text-decoration=\\\"none\\\" x-width=\\\"47\\\" x-height=\\\"18\\\" x-left=\\\"274.1\\\" x-top=\\\"186\\\" id=\\\"goog_2086231733\\\"><rect class=\\\"s-text-box\\\" stroke=\\\"none\\\" fill=\\\"#000000\\\" fill-opacity=\\\"0.001\\\" width=\\\"47\\\" height=\\\"18\\\" x=\\\"274.1\\\" y=\\\"186\\\"/><text class=\\\"s-text-l0\\\" xml:space=\\\"preserve\\\" stroke=\\\"none\\\" fill=\\\"inherit\\\" fill-opacity=\\\"1\\\" text-decoration=\\\"none\\\" x=\\\"274.1\\\" y=\\\"203\\\">Detail</text></g>\"},\"translate\":{\"x\":0,\"y\":-149}},\"header\":{},\"header-enabled\":\"false\",\"svg\":{\"tag\":\"g\",\"attrs\":{}},\"content-height\":322.1,\"page-break\":\"true\"}SHAPE--><!--LAYOUT<g xmlns=\"http://www.w3.org/2000/svg\" class=\"s-list\" x-id=\"default\" x-header-enabled=\"false\" x-page-footer-enabled=\"true\" x-footer-enabled=\"true\" x-changing-page=\"true\" x-display=\"true\" width=\"555.2\" height=\"322.1\" x=\"20\" y=\"21\" id=\"goog_2086231736\"><g class=\"s-list-header\" transform=\"translate(0,-75) rotate(0 0 0)\" x-top=\"21\" x-height=\"0\" display=\"none\"/><g class=\"s-list-detail\" transform=\"translate(0,-149) rotate(0 0 0)\" x-top=\"21\" x-height=\"50\"><g class=\"s-text\" stroke-width=\"0\" fill=\"#000000\" fill-opacity=\"1\" kerning=\"auto\" x-display=\"true\" x-id=\"\" font-size=\"18\" font-family=\"Helvetica\" font-weight=\"normal\" font-style=\"normal\" text-anchor=\"start\" text-decoration=\"none\" x-width=\"47\" x-height=\"18\" x-left=\"274.1\" x-top=\"186\" id=\"goog_2086231733\"><rect class=\"s-text-box\" stroke=\"none\" fill=\"#000000\" fill-opacity=\"0.001\" width=\"47\" height=\"18\" x=\"274.1\" y=\"186\"/><text class=\"s-text-l0\" xml:space=\"preserve\" stroke=\"none\" fill=\"inherit\" fill-opacity=\"1\" text-decoration=\"none\" x=\"274.1\" y=\"203\">Detail</text></g></g><g class=\"s-list-page-footer\" transform=\"translate(0,-173) rotate(0 0 0)\" x-top=\"71\" x-height=\"55.5\"><g class=\"s-text\" stroke-width=\"0\" fill=\"#000000\" fill-opacity=\"1\" kerning=\"auto\" x-display=\"true\" x-id=\"\" stroke=\"none\" font-weight=\"normal\" font-style=\"normal\" font-family=\"Helvetica\" font-size=\"18\" text-anchor=\"start\" text-decoration=\"none\" x-width=\"99\" x-height=\"18\" x-left=\"248.1\" x-top=\"262.8\" id=\"goog_2086231734\"><rect class=\"s-text-box\" stroke=\"none\" fill=\"#000000\" fill-opacity=\"0.001\" width=\"99\" height=\"18\" x=\"248.1\" y=\"262.8\"/><text class=\"s-text-l0\" xml:space=\"preserve\" stroke=\"none\" fill=\"inherit\" fill-opacity=\"1\" text-decoration=\"none\" x=\"248.1\" y=\"279.8\">Page Footer</text></g></g><g class=\"s-list-footer\" transform=\"translate(0,-173) rotate(0 0 0)\" x-top=\"126.5\" x-height=\"55.5\"><g class=\"s-text\" stroke-width=\"0\" fill=\"#000000\" fill-opacity=\"1\" kerning=\"auto\" x-display=\"true\" x-id=\"\" stroke=\"none\" font-weight=\"normal\" font-style=\"normal\" font-family=\"Helvetica\" font-size=\"18\" text-anchor=\"start\" text-decoration=\"none\" x-width=\"53\" x-height=\"18\" x-left=\"271.1\" x-top=\"318.3\" id=\"goog_2086231735\"><rect class=\"s-text-box\" stroke=\"none\" fill=\"#000000\" fill-opacity=\"0.001\" width=\"53\" height=\"18\" x=\"271.1\" y=\"318.3\"/><text class=\"s-text-l0\" xml:space=\"preserve\" stroke=\"none\" fill=\"inherit\" fill-opacity=\"1\" text-decoration=\"none\" x=\"271.1\" y=\"335.3\">Footer</text></g></g><text class=\"s-list-id\" font-size=\"11\" font-family=\"Helvetica\" font-weight=\"normal\" font-style=\"normal\" text-anchor=\"start\" stroke=\"none\" fill=\"#7C4007\" fill-opacity=\"1\" x=\"22\" y=\"31.8\">default</text><rect stroke-dasharray=\"5\" stroke=\"#BBBBBB\" stroke-width=\"1\" fill=\"#FFFFFF\" fill-opacity=\"0\" class=\"s-list-face\" width=\"555.2\" height=\"322.1\" x=\"20\" y=\"21\"/></g>LAYOUT--></g></svg>","state":{"layout-guide":[]}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":"0.7.7.1","finger-print":1504945686,"config":{"title":"Basic Layout","option":{},"page":{"paper-type":"A4","orientation":"portrait","margin-top":"20","margin-bottom":"20","margin-left":"20","margin-right":"20"}},"svg":"<svg width=\"595.2\" height=\"841.8\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" preserveAspectRatio=\"none\" viewBox=\"0 0 595.2 841.8\"><g class=\"canvas\"><g class=\"s-text\" stroke-width=\"0\" fill=\"#000000\" fill-opacity=\"1\" kerning=\"auto\" x-display=\"true\" x-id=\"\" font-size=\"36\" font-family=\"Times New Roman\" font-weight=\"normal\" font-style=\"normal\" text-anchor=\"middle\" text-decoration=\"none\" x-width=\"208.9\" x-height=\"100\" x-left=\"197.6\" x-top=\"369\" x-valign=\"center\" id=\"goog_2086231726\"><rect class=\"s-text-box\" stroke=\"none\" fill=\"#000000\" fill-opacity=\"0.001\" width=\"208.9\" height=\"100\" x=\"197.6\" y=\"369\"/><text class=\"s-text-l0\" xml:space=\"preserve\" stroke=\"none\" fill=\"inherit\" fill-opacity=\"1\" text-decoration=\"none\" x=\"300.6\" y=\"427\">Basic Layout1</text></g></g></svg>","state":{"layout-guide":[]}}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":"0.7.7.1","finger-print":1756736661,"config":{"title":"Basic Layout2","option":{},"page":{"paper-type":"A4","orientation":"portrait","margin-top":"20","margin-bottom":"20","margin-left":"20","margin-right":"20"}},"svg":"<svg width=\"595.2\" height=\"841.8\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" preserveAspectRatio=\"none\" viewBox=\"0 0 595.2 841.8\"><g class=\"canvas\"><g class=\"s-text\" stroke-width=\"0\" fill=\"#000000\" fill-opacity=\"1\" kerning=\"auto\" x-display=\"true\" x-id=\"\" stroke=\"none\" font-weight=\"normal\" font-style=\"normal\" font-family=\"Times New Roman\" font-size=\"36\" text-anchor=\"middle\" x-valign=\"center\" text-decoration=\"none\" x-width=\"208.9\" x-height=\"100\" x-left=\"197.6\" x-top=\"369\" id=\"goog_2086231727\"><rect class=\"s-text-box\" stroke=\"none\" fill=\"#000000\" fill-opacity=\"0.001\" width=\"208.9\" height=\"100\" x=\"197.6\" y=\"369\"/><text class=\"s-text-l0\" xml:space=\"preserve\" stroke=\"none\" fill=\"inherit\" fill-opacity=\"1\" text-decoration=\"none\" x=\"300.6\" y=\"427\">Basic Layout2</text></g></g></svg>","state":{"layout-guide":[]}}
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
gem 'minitest' # for 1.9.3
|
4
|
+
require 'minitest/autorun'
|
5
|
+
require 'minitest/spec'
|
6
|
+
require 'minitest/unit'
|
7
|
+
require 'mocha/mini_test'
|
8
|
+
|
9
|
+
require 'digest/sha1'
|
10
|
+
require 'pathname'
|
11
|
+
require 'thinreports'
|
12
|
+
|
13
|
+
module Thinreports::TestHelper
|
14
|
+
ROOT = Pathname.new(File.expand_path('..', __FILE__))
|
15
|
+
|
16
|
+
def setup
|
17
|
+
Thinreports::TestHelper.disable_stderr
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
super
|
22
|
+
clear_temp_files
|
23
|
+
end
|
24
|
+
|
25
|
+
def new_report(file, &block)
|
26
|
+
report = Thinreports::Report.new layout: data_file(file)
|
27
|
+
block.call(report) if block_given?
|
28
|
+
report
|
29
|
+
end
|
30
|
+
|
31
|
+
def new_layout(file)
|
32
|
+
Thinreports::Layout.new(data_file(file))
|
33
|
+
end
|
34
|
+
|
35
|
+
def new_layout_format(file)
|
36
|
+
Thinreports::Layout::Format.build(data_file(file))
|
37
|
+
end
|
38
|
+
|
39
|
+
def clear_temp_files
|
40
|
+
FileUtils.rm Dir.glob(temp_path.join('*'))
|
41
|
+
end
|
42
|
+
|
43
|
+
def clean_whitespaces(s)
|
44
|
+
s.gsub(/^\s*|\n\s*/, '')
|
45
|
+
end
|
46
|
+
|
47
|
+
def data_file(filename)
|
48
|
+
ROOT.join('data', filename).to_s
|
49
|
+
end
|
50
|
+
|
51
|
+
def temp_file(extname = 'pdf')
|
52
|
+
filename = (('a'..'z').to_a + (0..9).to_a).shuffle[0, 8].join + ".#{extname}"
|
53
|
+
temp_path.join(filename).to_s
|
54
|
+
end
|
55
|
+
|
56
|
+
def temp_path
|
57
|
+
ROOT.join('tmp')
|
58
|
+
end
|
59
|
+
|
60
|
+
@@original_stderr = nil
|
61
|
+
|
62
|
+
def self.disable_stderr
|
63
|
+
unless $stdout.is_a? StringIO
|
64
|
+
@@original_stderr = $stderr
|
65
|
+
$stderr = StringIO.new
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.enable_stderr
|
70
|
+
$stderr = @@original_stderr
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
Minitest.after_run { Thinreports::TestHelper.enable_stderr }
|
File without changes
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'test_helper'
|
4
4
|
|
5
|
-
class
|
5
|
+
class Thinreports::Core::Format::BaseTest < Minitest::Test
|
6
6
|
TEST_FORMAT_CONFIG = {
|
7
7
|
'c1' => 'c1',
|
8
8
|
'c2' => {
|
@@ -31,40 +31,40 @@ class ThinReports::Core::Format::BaseTest < MiniTest::Unit::TestCase
|
|
31
31
|
'c21' => 'c21'
|
32
32
|
}
|
33
33
|
|
34
|
-
class TestFormat <
|
34
|
+
class TestFormat < Thinreports::Core::Format::Base
|
35
35
|
# For testing
|
36
36
|
attr_reader :config
|
37
37
|
|
38
38
|
# Basic methods
|
39
39
|
config_reader :c1
|
40
|
-
config_reader :
|
41
|
-
:
|
40
|
+
config_reader c2_1: %w( c2 c2_1 ),
|
41
|
+
c3_1_1: %w( c3 c3_1 c3_1_1 )
|
42
42
|
config_reader :c4, :c5
|
43
43
|
config_reader 'c6'
|
44
44
|
|
45
45
|
# Alias methods
|
46
|
-
config_reader :
|
47
|
-
:
|
46
|
+
config_reader c1_alias: %w( c1 ),
|
47
|
+
c2_1_alias: %w( c2 c2_1 )
|
48
48
|
|
49
49
|
# Invalid methods
|
50
|
-
config_reader :
|
50
|
+
config_reader c3_invalid: %w( c3 c3_1 not_exist_key )
|
51
51
|
|
52
52
|
# Customized methods
|
53
|
-
config_reader :
|
53
|
+
config_reader c2_1_customized: %w( c2 c2_1 ) do |val|
|
54
54
|
"Customized #{val}"
|
55
55
|
end
|
56
56
|
|
57
57
|
# Checker methods
|
58
58
|
config_checker 'true', :c7, :c8
|
59
|
-
config_checker 'true', :
|
60
|
-
:
|
59
|
+
config_checker 'true', c9_1: %w( c9 c9_1 ),
|
60
|
+
c9_2: %w( c9 c9_2 )
|
61
61
|
|
62
62
|
# Writer methods
|
63
63
|
config_writer :c10
|
64
|
-
config_writer :
|
65
|
-
config_writer :
|
64
|
+
config_writer c10_alias: %w( c10 )
|
65
|
+
config_writer c11_1: %w( c11 c11_1 )
|
66
66
|
# Writer for not exist config on default
|
67
|
-
config_writer :
|
67
|
+
config_writer c11_2: %w( c11 c11_2 )
|
68
68
|
|
69
69
|
# Accessor methods
|
70
70
|
config_accessor :c20
|