thinreports 0.7.6 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -5
- data/.travis.yml +8 -4
- data/CHANGELOG.md +220 -0
- data/Gemfile +2 -9
- 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/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/examples/eudc/eudc.rb +20 -0
- data/examples/eudc/eudc.tlf +1 -0
- data/examples/helper.rb +50 -0
- 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/examples/list_manual_generation/list_manual_generation.rb +22 -0
- data/examples/list_manual_generation/list_manual_generation.tlf +1 -0
- data/examples/list_page_number/list_page_number.rb +17 -0
- 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/examples/single_line_tblock/single_line_tblock.rb +13 -0
- 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/examples/typeB_page_size/typeB_page_size.rb +17 -0
- data/examples/word_wrap/word_wrap.rb +26 -0
- data/examples/word_wrap/word_wrap.tlf +1 -0
- 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 -25
- data/lib/thinreports/core/format/builder.rb +19 -27
- 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/base.rb +4 -5
- 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 +9 -6
- data/lib/thinreports/core/shape/basic.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/image_block.rb +1 -1
- data/lib/thinreports/core/shape/list/configuration.rb +37 -16
- 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 +135 -95
- data/lib/thinreports/core/shape/list/page.rb +57 -51
- data/lib/thinreports/core/shape/list/page_state.rb +19 -17
- 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/list.rb +1 -1
- data/lib/thinreports/core/shape/manager/format.rb +10 -11
- data/lib/thinreports/core/shape/manager/internal.rb +22 -21
- data/lib/thinreports/core/shape/manager/target.rb +63 -34
- data/lib/thinreports/core/shape/manager.rb +1 -1
- data/lib/thinreports/core/shape/page_number/format.rb +25 -0
- data/lib/thinreports/core/shape/page_number/interface.rb +27 -0
- data/lib/thinreports/core/shape/page_number/internal.rb +57 -0
- data/lib/thinreports/core/shape/page_number.rb +15 -0
- 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 +41 -31
- data/lib/thinreports/core/shape/style.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.rb +1 -1
- data/lib/thinreports/core/shape/text_block/format.rb +17 -17
- 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/formatter.rb +7 -8
- 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/shape/text_block.rb +1 -1
- data/lib/thinreports/core/shape.rb +11 -13
- data/lib/thinreports/core/utils.rb +33 -32
- data/lib/thinreports/generator/base.rb +15 -24
- data/lib/thinreports/generator/configuration.rb +10 -9
- data/lib/thinreports/generator/pdf/configuration.rb +11 -6
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +41 -32
- data/lib/thinreports/generator/pdf/document/font.rb +53 -44
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +34 -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 +43 -41
- data/lib/thinreports/generator/pdf/document/graphics.rb +8 -9
- data/lib/thinreports/generator/pdf/document/page.rb +37 -23
- 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/document.rb +28 -28
- data/lib/thinreports/generator/pdf/drawer/base.rb +16 -22
- data/lib/thinreports/generator/pdf/drawer/list.rb +39 -21
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +17 -18
- data/lib/thinreports/generator/pdf/drawer/page.rb +37 -26
- data/lib/thinreports/generator/pdf/prawn_ext.rb +18 -17
- data/lib/thinreports/generator/pdf.rb +28 -31
- data/lib/thinreports/generator.rb +6 -8
- data/lib/thinreports/layout/base.rb +24 -36
- data/lib/thinreports/layout/configuration.rb +11 -9
- data/lib/thinreports/layout/format.rb +26 -31
- data/lib/thinreports/layout/version.rb +8 -9
- data/lib/thinreports/layout.rb +2 -2
- data/lib/thinreports/report/base.rb +117 -109
- data/lib/thinreports/report/events.rb +5 -5
- data/lib/thinreports/report/internal.rb +48 -38
- data/lib/thinreports/{core → report}/page.rb +42 -32
- data/lib/thinreports/report.rb +10 -14
- data/lib/thinreports/version.rb +2 -3
- data/lib/thinreports.rb +14 -2
- 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/tmp/.gitkeep +0 -0
- data/test/unit/core/format/test_base.rb +14 -14
- data/test/unit/core/format/test_builder.rb +20 -25
- 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 +29 -18
- 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 +50 -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 +15 -5
- data/test/unit/core/shape/list/test_page.rb +80 -22
- data/test/unit/core/shape/list/test_page_state.rb +13 -13
- 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 +73 -0
- data/test/unit/core/shape/page_number/test_interface.rb +33 -0
- data/test/unit/core/shape/page_number/test_internal.rb +81 -0
- 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 +29 -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 +22 -20
- 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 +13 -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 +10 -8
- data/test/unit/core/test_shape.rb +11 -7
- data/test/unit/core/test_utils.rb +68 -0
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +10 -4
- data/test/unit/generator/pdf/document/graphics/test_text.rb +60 -53
- data/test/unit/generator/pdf/document/test_draw_shape.rb +14 -6
- 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 +68 -43
- 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 +15 -21
- 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 +160 -192
- data/test/unit/report/test_events.rb +4 -4
- data/test/unit/report/test_internal.rb +102 -82
- 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 +23 -26
- metadata +118 -181
- data/.yardopts +0 -1
- data/LICENSE +0 -1
- data/README.rdoc +0 -167
- data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
- 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/ext.rb +0 -5
- data/lib/thinreports/core/format.rb +0 -14
- data/lib/thinreports/core/ordered_hash.rb +0 -39
- data/lib/thinreports/core.rb +0 -20
- data/lib/thinreports/generator/pdf/drawer.rb +0 -16
- data/tasks/doc.rake +0 -13
- 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 -7
- 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/helper.rb +0 -29
- data/test/case/hidden_shapes/hidden_shapes.rb +0 -13
- 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_header_inheriting/list_header_inheriting.rb +0 -17
- data/test/case/list_header_inheriting/list_header_inheriting.tlf +0 -1
- data/test/case/list_manual_generation/list_manual_generation.rb +0 -22
- data/test/case/list_manual_generation/list_manual_generation.tlf +0 -1
- data/test/case/single_line_tblock/single_line_tblock.rb +0 -15
- 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 -9
- data/test/case/text_align/text_align.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 -65
- /data/{test/case → examples}/dynamic_image/img200x100.png +0 -0
- /data/{test/case → examples}/dynamic_image/img50x50.png +0 -0
- /data/{test/case → examples}/dynamic_style/image.png +0 -0
- /data/{test/case → examples}/eudc/eudc.ttf +0 -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
@@ -1,27 +1,31 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class Thinreports::Report::TestInternal < Minitest::Test
|
6
|
+
include Thinreports::TestHelper
|
4
7
|
|
5
|
-
class ThinReports::Report::TestInternal < MiniTest::Unit::TestCase
|
6
|
-
include ThinReports::TestHelpers
|
7
|
-
|
8
8
|
# Alias
|
9
|
-
Report =
|
10
|
-
|
9
|
+
Report = Thinreports::Report
|
10
|
+
|
11
11
|
def report
|
12
12
|
Report::Base.new
|
13
13
|
end
|
14
14
|
|
15
15
|
def sample_layout1
|
16
|
-
data_file('
|
16
|
+
data_file('layout_text1.tlf')
|
17
17
|
end
|
18
18
|
|
19
19
|
def sample_layout2
|
20
|
-
data_file('
|
20
|
+
data_file('layout_text2.tlf')
|
21
|
+
end
|
22
|
+
|
23
|
+
def sample_list_layout
|
24
|
+
data_file('layout_list.tlf')
|
21
25
|
end
|
22
26
|
|
23
27
|
def test_layout_specified_in_new_method_should_be_defined_as_default_layout
|
24
|
-
internal = Report::Internal.new(report, :
|
28
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
25
29
|
assert_equal internal.default_layout.filename, sample_layout1
|
26
30
|
end
|
27
31
|
|
@@ -31,89 +35,98 @@ class ThinReports::Report::TestInternal < MiniTest::Unit::TestCase
|
|
31
35
|
|
32
36
|
assert_equal internal.default_layout.filename, sample_layout1
|
33
37
|
end
|
34
|
-
|
38
|
+
|
35
39
|
def test_register_layout_should_be_set_as_default_layout_when_default_option_is_true
|
36
40
|
internal = Report::Internal.new(report, {})
|
37
|
-
internal.register_layout(sample_layout1, :
|
38
|
-
|
41
|
+
internal.register_layout(sample_layout1, default: true)
|
42
|
+
|
39
43
|
assert_equal internal.default_layout.filename, sample_layout1
|
40
44
|
end
|
41
|
-
|
45
|
+
|
42
46
|
def test_register_layout_should_be_able_to_change_the_default_layout
|
43
|
-
internal = Report::Internal.new(report, :
|
44
|
-
internal.register_layout(sample_layout2, :
|
47
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
48
|
+
internal.register_layout(sample_layout2, default: true)
|
45
49
|
|
46
50
|
assert_equal internal.default_layout.filename, sample_layout2
|
47
51
|
end
|
48
|
-
|
52
|
+
|
49
53
|
def test_register_layout_should_be_set_as_with_id_when_id_option_is_set
|
50
54
|
internal = Report::Internal.new(report, {})
|
51
|
-
internal.register_layout(sample_layout1, :
|
55
|
+
internal.register_layout(sample_layout1, id: :foo)
|
52
56
|
|
53
57
|
assert_equal internal.layout_registry[:foo].filename, sample_layout1
|
54
58
|
end
|
55
|
-
|
59
|
+
|
56
60
|
def test_register_layout_should_raise_an_error_when_id_is_already_registered
|
57
61
|
internal = Report::Internal.new(report, {})
|
58
|
-
internal.register_layout(sample_layout2, :
|
59
|
-
|
62
|
+
internal.register_layout(sample_layout2, id: :foo)
|
63
|
+
|
60
64
|
assert_raises ArgumentError do
|
61
|
-
internal.register_layout(sample_layout1, :
|
65
|
+
internal.register_layout(sample_layout1, id: :foo)
|
62
66
|
end
|
63
67
|
end
|
64
|
-
|
68
|
+
|
65
69
|
def test_register_layout_should_return_the_instance_of_LayoutConfiguration
|
66
70
|
internal = Report::Internal.new(report, {})
|
67
71
|
|
68
|
-
assert_instance_of
|
72
|
+
assert_instance_of Thinreports::Layout::Configuration,
|
69
73
|
internal.register_layout(sample_layout1)
|
70
74
|
end
|
71
|
-
|
75
|
+
|
76
|
+
def test_register_layout_should_be_able_to_set_list_configuration_without_errors
|
77
|
+
internal = Report::Internal.new(report, {})
|
78
|
+
internal.register_layout(sample_list_layout) do |config|
|
79
|
+
config.list(:list).use_stores foo: 0
|
80
|
+
config.list(:list).use_stores bar: 1000
|
81
|
+
end
|
82
|
+
pass
|
83
|
+
end
|
84
|
+
|
72
85
|
def test_add_page_should_finalize_the_current_page
|
73
|
-
layout =
|
86
|
+
layout = Thinreports::Layout.new(sample_layout1)
|
74
87
|
|
75
|
-
internal = Report::Internal.new(report, :
|
76
|
-
page = internal.add_page(
|
77
|
-
internal.add_page(
|
88
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
89
|
+
page = internal.add_page(Thinreports::Report::Page.new(report, layout))
|
90
|
+
internal.add_page(Thinreports::Report::Page.new(report, layout))
|
78
91
|
|
79
92
|
assert_equal page.finalized?, true
|
80
93
|
end
|
81
94
|
|
82
95
|
def test_add_page_should_return_the_current_page
|
83
|
-
layout =
|
84
|
-
new_page =
|
96
|
+
layout = Thinreports::Layout.new(sample_layout1)
|
97
|
+
new_page = Thinreports::Report::Page.new(report, layout)
|
85
98
|
|
86
|
-
internal = Report::Internal.new(report, :
|
99
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
87
100
|
|
88
101
|
assert_same new_page, internal.add_page(new_page)
|
89
102
|
end
|
90
103
|
|
91
104
|
def test_add_page_should_add_the_initialized_page
|
92
|
-
layout =
|
93
|
-
new_page =
|
105
|
+
layout = Thinreports::Layout.new(sample_layout1)
|
106
|
+
new_page = Thinreports::Report::Page.new(report, layout)
|
94
107
|
|
95
|
-
internal = Report::Internal.new(report, :
|
108
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
96
109
|
internal.add_page(new_page)
|
97
110
|
|
98
111
|
assert_same new_page, internal.pages.last
|
99
112
|
end
|
100
113
|
|
101
114
|
def test_add_page_should_count_up_the_total_page_count
|
102
|
-
layout =
|
103
|
-
|
104
|
-
internal = Report::Internal.new(report, :
|
105
|
-
internal.add_page(
|
115
|
+
layout = Thinreports::Layout.new(sample_layout1)
|
116
|
+
|
117
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
118
|
+
internal.add_page(Thinreports::Report::Page.new(report, layout))
|
106
119
|
|
107
120
|
assert_equal internal.page_count, 1
|
108
121
|
end
|
109
|
-
|
122
|
+
|
110
123
|
def test_add_page_should_switch_to_a_reference_to_the_current_page
|
111
|
-
layout =
|
124
|
+
layout = Thinreports::Layout.new(sample_layout1)
|
112
125
|
new_pages = (1..2).inject([]) do |pages, i|
|
113
|
-
pages <<
|
126
|
+
pages << Thinreports::Report::Page.new(report, layout)
|
114
127
|
end
|
115
128
|
|
116
|
-
internal = Report::Internal.new(report, :
|
129
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
117
130
|
internal.add_page(new_pages[0])
|
118
131
|
|
119
132
|
assert_same internal.page, new_pages[0]
|
@@ -122,51 +135,51 @@ class ThinReports::Report::TestInternal < MiniTest::Unit::TestCase
|
|
122
135
|
|
123
136
|
assert_same internal.page, new_pages[1]
|
124
137
|
end
|
125
|
-
|
138
|
+
|
126
139
|
def test_add_page_should_dispatch_the_event_page_creation
|
127
140
|
dispatched = false
|
128
|
-
layout =
|
141
|
+
layout = Thinreports::Layout.new(sample_layout1)
|
129
142
|
|
130
|
-
internal = Report::Internal.new(report, :
|
143
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
131
144
|
internal.events.on(:page_create) {|e| dispatched = true }
|
132
|
-
internal.add_page(
|
145
|
+
internal.add_page(Thinreports::Report::Page.new(report, layout))
|
133
146
|
|
134
147
|
assert dispatched
|
135
148
|
end
|
136
149
|
|
137
150
|
def test_add_blank_page_should_not_dispatch_the_event_page_creation
|
138
151
|
dispatched = false
|
139
|
-
layout =
|
152
|
+
layout = Thinreports::Layout.new(sample_layout1)
|
140
153
|
|
141
|
-
internal = Report::Internal.new(report, :
|
154
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
142
155
|
internal.events.on(:page_create) {|e| dispatched = true }
|
143
|
-
internal.add_page(
|
156
|
+
internal.add_page(Thinreports::Report::BlankPage.new)
|
144
157
|
|
145
158
|
refute dispatched
|
146
159
|
end
|
147
|
-
|
160
|
+
|
148
161
|
def test_add_blank_page_should_not_count_up_the_total_page_count_when_count_is_disabled
|
149
|
-
layout =
|
162
|
+
layout = Thinreports::Layout.new(sample_layout1)
|
150
163
|
|
151
|
-
internal = Report::Internal.new(report, :
|
152
|
-
internal.add_page(
|
164
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
165
|
+
internal.add_page(Thinreports::Report::BlankPage.new(false))
|
153
166
|
|
154
167
|
assert_equal internal.page_count, 0
|
155
168
|
end
|
156
169
|
|
157
170
|
def test_add_blank_page_should_count_up_the_total_page_count_when_count_is_enabled
|
158
|
-
layout =
|
171
|
+
layout = Thinreports::Layout.new(sample_layout1)
|
159
172
|
|
160
|
-
internal = Report::Internal.new(report, :
|
161
|
-
internal.add_page(
|
173
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
174
|
+
internal.add_page(Thinreports::Report::BlankPage.new)
|
162
175
|
|
163
176
|
assert_equal internal.page_count, 1
|
164
177
|
end
|
165
|
-
|
178
|
+
|
166
179
|
def test_finalize_should_dispatch_the_event_report_generation
|
167
180
|
dispatched = false
|
168
181
|
|
169
|
-
internal = Report::Internal.new(report, :
|
182
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
170
183
|
internal.events.on(:generate) {|e| dispatched = true }
|
171
184
|
internal.finalize
|
172
185
|
|
@@ -174,72 +187,79 @@ class ThinReports::Report::TestInternal < MiniTest::Unit::TestCase
|
|
174
187
|
end
|
175
188
|
|
176
189
|
def test_finalize_should_finalize_the_report
|
177
|
-
internal = Report::Internal.new(report, :
|
190
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
178
191
|
internal.finalize
|
179
192
|
|
180
193
|
assert internal.finalized?
|
181
194
|
end
|
182
195
|
|
183
196
|
def test_finalize_should_not_work_when_report_is_already_finalized
|
184
|
-
internal = Report::Internal.new(report, :
|
185
|
-
|
186
|
-
flexmock(internal).
|
187
|
-
should_receive(:finalize_current_page).once
|
188
|
-
|
197
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
189
198
|
internal.finalize
|
199
|
+
|
200
|
+
# #finalize_current_page must never be called
|
201
|
+
internal.expects(:finalize_current_page).never
|
190
202
|
internal.finalize
|
191
203
|
end
|
192
204
|
|
193
205
|
def test_finalized_should_return_true_when_report_is_already_finalized
|
194
|
-
internal = Report::Internal.new(report, :
|
206
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
195
207
|
internal.finalize
|
196
208
|
|
197
209
|
assert internal.finalized?
|
198
210
|
end
|
199
|
-
|
211
|
+
|
200
212
|
def test_load_layout_with_String
|
201
|
-
internal = Report::Internal.new(report, :
|
202
|
-
|
203
|
-
assert_equal internal.load_layout(sample_layout2).filename,
|
213
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
214
|
+
|
215
|
+
assert_equal internal.load_layout(sample_layout2).filename,
|
204
216
|
sample_layout2
|
205
217
|
end
|
206
|
-
|
218
|
+
|
207
219
|
def test_load_layout_with_id
|
208
220
|
internal = Report::Internal.new(report, {})
|
209
|
-
internal.register_layout(sample_layout1, :
|
221
|
+
internal.register_layout(sample_layout1, id: :sample)
|
210
222
|
|
211
|
-
assert_equal internal.load_layout(:sample).filename,
|
223
|
+
assert_equal internal.load_layout(:sample).filename,
|
212
224
|
sample_layout1
|
213
225
|
end
|
214
|
-
|
226
|
+
|
215
227
|
def test_load_layout_with_unknown_id
|
216
228
|
internal = Report::Internal.new(report, {})
|
217
229
|
assert_nil internal.load_layout(:unknown)
|
218
230
|
end
|
219
|
-
|
231
|
+
|
232
|
+
def test_load_layout_should_set_default_layout_when_default_layout_is_nil
|
233
|
+
internal = Report::Internal.new(report, {})
|
234
|
+
internal.load_layout(sample_layout1)
|
235
|
+
|
236
|
+
assert_equal internal.default_layout.filename,
|
237
|
+
sample_layout1
|
238
|
+
end
|
239
|
+
|
220
240
|
def test_load_layout_should_raise_error_when_invalid_value_set
|
221
241
|
internal = Report::Internal.new(report, {})
|
222
242
|
|
223
|
-
assert_raises
|
243
|
+
assert_raises Thinreports::Errors::LayoutFileNotFound do
|
224
244
|
internal.load_layout('/path/to/unkown.tlf')
|
225
245
|
end
|
226
246
|
end
|
227
|
-
|
247
|
+
|
228
248
|
def test_copy_page_should_finalize_current_page
|
229
|
-
layout =
|
249
|
+
layout = Thinreports::Layout.new(sample_layout1)
|
230
250
|
|
231
|
-
internal = Report::Internal.new(report, :
|
232
|
-
internal.add_page(page =
|
251
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
252
|
+
internal.add_page(page = Thinreports::Report::Page.new(report, layout))
|
233
253
|
internal.copy_page
|
234
254
|
|
235
255
|
assert page.finalized?
|
236
256
|
end
|
237
257
|
|
238
258
|
def test_copy_page_should_add_the_copied_page
|
239
|
-
layout =
|
259
|
+
layout = Thinreports::Layout.new(sample_layout1)
|
240
260
|
|
241
|
-
internal = Report::Internal.new(report, :
|
242
|
-
internal.add_page(page =
|
261
|
+
internal = Report::Internal.new(report, layout: sample_layout1)
|
262
|
+
internal.add_page(page = Thinreports::Report::Page.new(report, layout))
|
243
263
|
internal.copy_page
|
244
264
|
|
245
265
|
assert_equal internal.page_count, 2
|
data/test/unit/test_config.rb
CHANGED
@@ -1,22 +1,41 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class Thinreports::TestConfig < Minitest::Test
|
6
|
+
include Thinreports::TestHelper
|
4
7
|
|
5
|
-
class ThinReports::TestConfig < MiniTest::Unit::TestCase
|
6
|
-
include ThinReports::TestHelpers
|
7
|
-
|
8
8
|
def test_generator_of_Configuration_should_return_configuration_of_generator
|
9
|
-
config =
|
10
|
-
assert_instance_of
|
9
|
+
config = Thinreports::Configuration.new
|
10
|
+
assert_instance_of Thinreports::Generator::Configuration, config.generator
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def test_config_should_return_configuration_of_thinreports
|
14
|
-
assert_instance_of
|
14
|
+
assert_instance_of Thinreports::Configuration, Thinreports.config
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def test_configure_should_exec_an_given_block_with_config_which_instance_of_Configuration
|
18
|
-
|
19
|
-
assert_instance_of
|
18
|
+
Thinreports.configure do |config|
|
19
|
+
assert_instance_of Thinreports::Configuration, config
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
|
+
def test_fallback_fonts
|
24
|
+
config = Thinreports::Configuration.new
|
25
|
+
|
26
|
+
# should be empty by default
|
27
|
+
assert_empty config.fallback_fonts
|
28
|
+
|
29
|
+
config.fallback_fonts = 'Helvetica'
|
30
|
+
assert_equal config.fallback_fonts, ['Helvetica']
|
31
|
+
|
32
|
+
config.fallback_fonts = ['/path/to/font.ttf', 'Courier New']
|
33
|
+
assert_equal config.fallback_fonts, ['/path/to/font.ttf', 'Courier New']
|
34
|
+
|
35
|
+
config.fallback_fonts = []
|
36
|
+
config.fallback_fonts << 'Helvetica'
|
37
|
+
config.fallback_fonts << 'IPAMincho'
|
38
|
+
config.fallback_fonts.unshift 'Times New Roman'
|
39
|
+
assert_equal config.fallback_fonts, ['Times New Roman', 'Helvetica', 'IPAMincho']
|
40
|
+
end
|
41
|
+
end
|
data/test/unit/test_layout.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class Thinreports::TestLayout < Minitest::Test
|
6
|
+
include Thinreports::TestHelper
|
4
7
|
|
5
|
-
class ThinReports::TestLayout < MiniTest::Unit::TestCase
|
6
|
-
include ThinReports::TestHelpers
|
7
|
-
|
8
8
|
def test_new
|
9
|
-
|
10
|
-
|
9
|
+
assert_instance_of Thinreports::Layout::Base,
|
10
|
+
Thinreports::Layout.new(data_file('layout_text1.tlf'))
|
11
11
|
end
|
12
|
-
end
|
12
|
+
end
|
data/test/unit/test_report.rb
CHANGED
@@ -1,30 +1,18 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class Thinreports::TestReport < Minitest::Test
|
6
|
+
include Thinreports::TestHelper
|
4
7
|
|
5
|
-
class ThinReports::TestReport < MiniTest::Unit::TestCase
|
6
|
-
include ThinReports::TestHelpers
|
7
|
-
|
8
8
|
# Alias
|
9
|
-
Report =
|
10
|
-
|
11
|
-
def
|
12
|
-
|
13
|
-
Report.new
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_create_should_delegate_to_Base_create
|
17
|
-
flexmock(Report::Base).should_receive(:create).once
|
18
|
-
Report.create
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_generate_should_delegate_to_Base_generate
|
22
|
-
flexmock(Report::Base).should_receive(:generate).once
|
23
|
-
Report.generate
|
9
|
+
Report = Thinreports::Report
|
10
|
+
|
11
|
+
def test_new
|
12
|
+
assert_instance_of Report::Base, Report.new
|
24
13
|
end
|
25
|
-
|
26
|
-
def
|
27
|
-
|
28
|
-
Report.generate_file
|
14
|
+
|
15
|
+
def test_create
|
16
|
+
assert_instance_of Report::Base, Report.create {}
|
29
17
|
end
|
30
|
-
end
|
18
|
+
end
|
data/thinreports.gemspec
CHANGED
@@ -5,32 +5,29 @@ require 'thinreports/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = 'thinreports'
|
8
|
-
s.version =
|
8
|
+
s.version = Thinreports::VERSION
|
9
9
|
s.author = 'Matsukei Co.,Ltd.'
|
10
|
-
s.email = 'thinreports@
|
11
|
-
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
s.
|
18
|
-
|
19
|
-
s.
|
20
|
-
|
21
|
-
|
22
|
-
s.extra_rdoc_files = ['README.rdoc']
|
23
|
-
|
10
|
+
s.email = 'thinreports@gmail.com'
|
11
|
+
s.summary = 'An open source report generation tool for Ruby.'
|
12
|
+
s.description = 'Thinreports is an open source report generation tool for Ruby.'
|
13
|
+
s.homepage = 'http://www.thinreports.org'
|
14
|
+
s.licenses = ['MIT']
|
15
|
+
|
16
|
+
s.platform = Gem::Platform::RUBY
|
17
|
+
s.required_ruby_version = '>= 1.9.3'
|
18
|
+
|
19
|
+
s.rdoc_options = ['--main', 'README.md']
|
20
|
+
s.extra_rdoc_files = ['README.md']
|
21
|
+
|
24
22
|
s.files = `git ls-files`.split($\)
|
25
|
-
s.test_files = s.files.grep
|
26
|
-
s.
|
27
|
-
|
28
|
-
s.add_dependency
|
29
|
-
|
30
|
-
s.add_development_dependency
|
31
|
-
s.add_development_dependency
|
32
|
-
s.add_development_dependency
|
33
|
-
s.add_development_dependency
|
34
|
-
s.add_development_dependency
|
35
|
-
s.add_development_dependency('simplecov', ['>=0'])
|
23
|
+
s.test_files = s.files.grep %r{^test/}
|
24
|
+
s.require_paths = ['lib']
|
25
|
+
|
26
|
+
s.add_dependency 'prawn', '1.3.0'
|
27
|
+
|
28
|
+
s.add_development_dependency 'bundler', ['>= 1.0.0']
|
29
|
+
s.add_development_dependency 'minitest', ['>= 5.0.0']
|
30
|
+
s.add_development_dependency 'mocha', ['>= 0']
|
31
|
+
s.add_development_dependency 'rake', ['>= 0']
|
32
|
+
s.add_development_dependency 'yard'
|
36
33
|
end
|