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,43 +1,42 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class Thinreports::Generator::PDF::TestGraphics < Minitest::Test
|
6
|
+
include Thinreports::TestHelper
|
4
7
|
|
5
|
-
class ThinReports::Generator::PDF::TestGraphics < MiniTest::Unit::TestCase
|
6
|
-
include ThinReports::TestHelpers
|
7
|
-
|
8
8
|
class TestGraphics
|
9
9
|
attr_accessor :pdf
|
10
|
-
include
|
10
|
+
include Thinreports::Generator::PDF::Graphics
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def setup
|
14
|
-
@g
|
15
|
-
@g.pdf =
|
14
|
+
@g = TestGraphics.new
|
15
|
+
@g.pdf = mock('pdf')
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def test_setup_custom_graphic_states
|
19
|
-
@g.pdf.
|
20
|
-
should_receive(:line_width).
|
19
|
+
@g.pdf.expects(:line_width).
|
21
20
|
with(TestGraphics::BASE_LINE_WIDTH).once
|
22
|
-
|
21
|
+
|
23
22
|
@g.send(:setup_custom_graphic_states)
|
24
23
|
end
|
25
|
-
|
24
|
+
|
26
25
|
def test_line_width
|
27
26
|
@g.pdf.
|
28
|
-
|
27
|
+
expects(:line_width).
|
29
28
|
with(10 * TestGraphics::BASE_LINE_WIDTH).once
|
30
|
-
|
29
|
+
|
31
30
|
@g.send(:line_width, 10)
|
32
31
|
end
|
33
|
-
|
32
|
+
|
34
33
|
def test_save_graphics_state
|
35
|
-
@g.pdf.
|
34
|
+
@g.pdf.expects(:save_graphics_state).once
|
36
35
|
@g.send(:save_graphics_state)
|
37
36
|
end
|
38
|
-
|
37
|
+
|
39
38
|
def test_restore_graphics_state
|
40
|
-
@g.pdf.
|
39
|
+
@g.pdf.expects(:restore_graphics_state).once
|
41
40
|
@g.send(:restore_graphics_state)
|
42
41
|
end
|
43
42
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class Thinreports::Generator::PDF::Document::TestPage < Minitest::Test
|
6
|
+
include Thinreports::TestHelper
|
4
7
|
|
5
|
-
class ThinReports::Generator::PDF::Document::TestPage < MiniTest::Unit::TestCase
|
6
|
-
include ThinReports::TestHelpers
|
7
|
-
|
8
8
|
def create_pdf
|
9
|
-
@pdf =
|
9
|
+
@pdf = Thinreports::Generator::PDF::Document.new
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_page_geometry
|
13
|
-
page_geometry =
|
13
|
+
page_geometry = ::PDF::Core::PageGeometry::SIZES
|
14
14
|
assert_equal page_geometry['B4_JIS'], [728.5, 1031.8]
|
15
15
|
assert_equal page_geometry['B5_JIS'], [515.9, 728.5]
|
16
16
|
end
|
@@ -18,8 +18,8 @@ class ThinReports::Generator::PDF::Document::TestPage < MiniTest::Unit::TestCase
|
|
18
18
|
def test_B4_paper_size_should_be_converted_to_B4_JIS
|
19
19
|
create_pdf
|
20
20
|
|
21
|
-
format =
|
22
|
-
|
21
|
+
format = new_layout_format('layout_text1.tlf')
|
22
|
+
format.stubs(page_paper_type: 'B4')
|
23
23
|
|
24
24
|
@pdf.start_new_page(format)
|
25
25
|
assert_equal @pdf.internal.page.size, 'B4_JIS'
|
@@ -28,8 +28,8 @@ class ThinReports::Generator::PDF::Document::TestPage < MiniTest::Unit::TestCase
|
|
28
28
|
def test_B4_ISO_paper_size_should_be_converted_to_B4
|
29
29
|
create_pdf
|
30
30
|
|
31
|
-
format =
|
32
|
-
|
31
|
+
format = new_layout_format('layout_text1.tlf')
|
32
|
+
format.stubs(page_paper_type: 'B4_ISO')
|
33
33
|
|
34
34
|
@pdf.start_new_page(format)
|
35
35
|
assert_equal @pdf.internal.page.size, 'B4'
|
@@ -37,85 +37,84 @@ class ThinReports::Generator::PDF::Document::TestPage < MiniTest::Unit::TestCase
|
|
37
37
|
|
38
38
|
def test_change_page_format_should_return_true_at_first_time
|
39
39
|
create_pdf
|
40
|
-
format =
|
41
|
-
|
40
|
+
format = new_layout_format('layout_text1.tlf')
|
41
|
+
|
42
42
|
assert_equal @pdf.send(:change_page_format?, format), true
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
def test_change_page_format_should_return_false_when_given_the_same_format
|
46
46
|
create_pdf
|
47
|
-
format =
|
48
|
-
|
47
|
+
format = new_layout_format('layout_text1.tlf')
|
48
|
+
|
49
49
|
@pdf.instance_variable_set(:@current_page_format, format)
|
50
50
|
assert_equal @pdf.send(:change_page_format?, format), false
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
def test_change_page_format_should_return_true_when_given_the_other_format
|
54
54
|
create_pdf
|
55
|
-
format1 =
|
56
|
-
format2 =
|
57
|
-
|
55
|
+
format1 = new_layout_format('layout_text1.tlf')
|
56
|
+
format2 = new_layout_format('layout_text2.tlf')
|
57
|
+
|
58
58
|
@pdf.instance_variable_set(:@current_page_format, format1)
|
59
59
|
assert_equal @pdf.send(:change_page_format?, format2), true
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
def test_new_basic_page_options
|
63
|
-
format =
|
63
|
+
format = new_layout_format('layout_text1.tlf')
|
64
64
|
options = create_pdf.send(:new_basic_page_options, format)
|
65
|
-
|
65
|
+
|
66
66
|
assert_equal options[:layout], format.page_orientation.to_sym
|
67
67
|
assert_equal options[:size], format.page_paper_type
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
def test_new_basic_page_options_when_the_layout_has_customize_size
|
71
|
-
format =
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
71
|
+
format = stub user_paper_type?: true,
|
72
|
+
page_width: 100,
|
73
|
+
page_height: 100,
|
74
|
+
page_orientation: 'portrait'
|
75
|
+
|
77
76
|
options = create_pdf.send(:new_basic_page_options, format)
|
78
77
|
assert_equal options[:size], [100, 100]
|
79
78
|
end
|
80
|
-
|
79
|
+
|
81
80
|
def test_start_new_page_should_create_stamp
|
82
81
|
create_pdf
|
83
|
-
format =
|
82
|
+
format = new_layout_format('layout_text1.tlf')
|
84
83
|
@pdf.start_new_page(format)
|
85
|
-
|
84
|
+
|
86
85
|
assert_includes @pdf.send(:format_stamp_registry), format.identifier
|
87
86
|
end
|
88
|
-
|
87
|
+
|
89
88
|
def test_start_new_page_should_not_create_stamp
|
90
89
|
create_pdf
|
91
|
-
format =
|
90
|
+
format = new_layout_format('layout_text1.tlf')
|
92
91
|
@pdf.start_new_page(format)
|
93
92
|
@pdf.start_new_page(format)
|
94
|
-
|
93
|
+
|
95
94
|
assert_equal @pdf.send(:format_stamp_registry).size, 1
|
96
95
|
end
|
97
|
-
|
96
|
+
|
98
97
|
def test_start_new_page_should_stamp_constantly
|
99
98
|
create_pdf
|
100
|
-
format =
|
101
|
-
|
102
|
-
|
99
|
+
format = new_layout_format('layout_text1.tlf')
|
100
|
+
@pdf.expects(:stamp).with(format.identifier.to_s).times(2)
|
101
|
+
|
103
102
|
@pdf.start_new_page(format)
|
104
103
|
@pdf.start_new_page(format)
|
105
104
|
end
|
106
105
|
|
107
106
|
def test_add_blank_page_should_create_an_A4_size_page_in_first_page
|
108
107
|
create_pdf
|
109
|
-
|
110
|
-
|
108
|
+
@pdf.internal.expects(:start_new_page).with(size: 'A4').once
|
109
|
+
|
111
110
|
@pdf.add_blank_page
|
112
111
|
end
|
113
|
-
|
112
|
+
|
114
113
|
def test_add_blank_page_should_call_with_no_arguments_since_second_page
|
115
114
|
create_pdf
|
116
|
-
@pdf.start_new_page(
|
117
|
-
|
118
|
-
|
115
|
+
@pdf.start_new_page(new_layout_format('layout_text1.tlf'))
|
116
|
+
@pdf.internal.expects(:start_new_page).with({}).once
|
117
|
+
|
119
118
|
@pdf.add_blank_page
|
120
119
|
end
|
121
120
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'test_helper'
|
4
4
|
|
5
|
-
class
|
6
|
-
include
|
5
|
+
class Thinreports::Generator::PDF::TestParseColor < Minitest::Test
|
6
|
+
include Thinreports::TestHelper
|
7
7
|
|
8
8
|
class TestColorParser
|
9
|
-
include
|
9
|
+
include Thinreports::Generator::PDF::ParseColor
|
10
10
|
end
|
11
11
|
|
12
12
|
def setup
|
@@ -23,7 +23,7 @@ class ThinReports::Generator::PDF::TestParseColor < MiniTest::Unit::TestCase
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_parse_color_with_colorname_raise_when_unknown_name_given
|
26
|
-
assert_raises
|
26
|
+
assert_raises Thinreports::Errors::UnsupportedColorName do
|
27
27
|
@parser.parse_color('whitesmoke')
|
28
28
|
end
|
29
29
|
end
|
@@ -1,15 +1,22 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class Thinreports::Generator::PDF::TestConfiguration < Minitest::Test
|
6
|
+
include Thinreports::TestHelper
|
4
7
|
|
5
|
-
class ThinReports::Generator::PDF::TestConfiguration < MiniTest::Unit::TestCase
|
6
|
-
include ThinReports::TestHelpers
|
7
|
-
|
8
8
|
def setup
|
9
|
-
@config =
|
9
|
+
@config = Thinreports::Generator::PDF::Configuration.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_eudc_fonts_is_deprecated
|
13
|
+
out, err = capture_io do
|
14
|
+
@config.eudc_fonts = []
|
15
|
+
end
|
16
|
+
assert_includes err, '[DEPRECATION]'
|
10
17
|
end
|
11
|
-
|
12
|
-
def
|
18
|
+
|
19
|
+
def test_eudc_fonts_should_be_able_to_set_only_TTF
|
13
20
|
assert_raises ArgumentError do
|
14
21
|
@config.eudc_fonts = '/path/to/eudc'
|
15
22
|
end
|
@@ -17,8 +24,8 @@ class ThinReports::Generator::PDF::TestConfiguration < MiniTest::Unit::TestCase
|
|
17
24
|
@config.eudc_fonts = %w( /path/to/eudc1.ttf /path/to/eudc2 )
|
18
25
|
end
|
19
26
|
end
|
20
|
-
|
27
|
+
|
21
28
|
def test_eudc_fonts_should_return_empty_array_by_default
|
22
29
|
assert_equal @config.eudc_fonts, []
|
23
30
|
end
|
24
|
-
end
|
31
|
+
end
|
@@ -1,28 +1,20 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class Thinreports::Generator::PDF::TestDocument < Minitest::Test
|
6
|
+
include Thinreports::TestHelper
|
4
7
|
|
5
|
-
class ThinReports::Generator::PDF::TestDocument < MiniTest::Unit::TestCase
|
6
|
-
include ThinReports::TestHelpers
|
7
|
-
|
8
8
|
# Alias
|
9
|
-
Document =
|
10
|
-
|
9
|
+
Document = Thinreports::Generator::PDF::Document
|
10
|
+
|
11
11
|
def test_new_without_page_creation
|
12
12
|
pdf = Document.new
|
13
13
|
assert_equal pdf.internal.page_count, 0
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def test_new_with_zero_margin_canvas
|
17
17
|
pdf = Document.new
|
18
18
|
assert_equal pdf.internal.page.margins.values, [0, 0, 0, 0]
|
19
19
|
end
|
20
|
-
|
21
|
-
def test_new_with_security_settings
|
22
|
-
flexmock(Prawn::Document).new_instances.
|
23
|
-
should_receive(:encrypt_document).once.
|
24
|
-
with(:user_password => 'foo')
|
25
|
-
|
26
|
-
Document.new(:security => {:user_password => 'foo'})
|
27
|
-
end
|
28
|
-
end
|
20
|
+
end
|
@@ -1,51 +1,40 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require '
|
4
|
-
|
5
|
-
class
|
6
|
-
include
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
assert_same FooHoge, Generator.registry.delete(:foohoge)
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_initialize_finalize_given_the_report
|
18
|
-
report = flexmock('report').
|
19
|
-
should_receive(:finalize).once.
|
20
|
-
should_receive(:internal).once.mock
|
21
|
-
|
22
|
-
Generator::Base.new(report)
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class Thinreports::Generator::TestBase < Minitest::Test
|
6
|
+
include Thinreports::TestHelper
|
7
|
+
|
8
|
+
Generator = Thinreports::Generator
|
9
|
+
|
10
|
+
class FooGenerator < Generator::Base; end
|
11
|
+
|
12
|
+
def test_registring_generator
|
13
|
+
assert_same FooGenerator, Generator.registry.delete(:foogenerator)
|
23
14
|
end
|
24
|
-
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
15
|
+
|
16
|
+
def test_new
|
17
|
+
report = new_report 'layout_text1.tlf'
|
18
|
+
|
19
|
+
refute report.finalized?
|
20
|
+
Generator::Base.new report
|
21
|
+
assert report.finalized?
|
29
22
|
end
|
30
|
-
|
31
|
-
def
|
23
|
+
|
24
|
+
def test_generate
|
25
|
+
report = new_report 'layout_text1.tlf'
|
26
|
+
|
27
|
+
generator = Generator::Base.new report
|
32
28
|
assert_raises NotImplementedError do
|
33
|
-
|
29
|
+
generator.generate
|
34
30
|
end
|
35
31
|
end
|
36
|
-
|
32
|
+
|
37
33
|
def test_default_layout
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
|
45
|
-
def new_generator
|
46
|
-
report = flexmock('report').
|
47
|
-
should_receive(:finalize).
|
48
|
-
should_receive(:internal).and_return(flexmock('report_internal')).mock
|
49
|
-
Generator::Base.new(report)
|
34
|
+
report = new_report 'layout_text1.tlf'
|
35
|
+
|
36
|
+
generator = Generator::Base.new report
|
37
|
+
assert_equal data_file('layout_text1.tlf'),
|
38
|
+
generator.default_layout.filename
|
50
39
|
end
|
51
|
-
end
|
40
|
+
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'test_helper'
|
4
4
|
|
5
|
-
class
|
6
|
-
include
|
5
|
+
class Thinreports::Generator::TestConfiguration < Minitest::Test
|
6
|
+
include Thinreports::TestHelper
|
7
7
|
|
8
8
|
def setup
|
9
|
-
@config =
|
9
|
+
@config = Thinreports::Generator::Configuration.new
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_pdf_should_return_configuration_of_pdf
|
13
|
-
assert_instance_of
|
13
|
+
assert_instance_of Thinreports::Generator::PDF::Configuration, @config.pdf
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_default_should_return_pdf_by_default
|
@@ -18,7 +18,7 @@ class ThinReports::Generator::TestConfiguration < MiniTest::Unit::TestCase
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_default_should_raise_when_value_is_unknown_generator_type
|
21
|
-
assert_raises
|
21
|
+
assert_raises Thinreports::Errors::UnknownGeneratorType do
|
22
22
|
@config.default = :unknown
|
23
23
|
end
|
24
24
|
end
|
@@ -1,20 +1,23 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'test_helper'
|
4
|
+
|
5
|
+
class Thinreports::Generator::TestPDF < Minitest::Test
|
6
|
+
include Thinreports::TestHelper
|
7
|
+
|
8
|
+
PDF = Thinreports::Generator::PDF
|
4
9
|
|
5
|
-
class ThinReports::Generator::TestPDF < MiniTest::Unit::TestCase
|
6
|
-
include ThinReports::TestHelpers
|
7
|
-
|
8
|
-
# Alias
|
9
|
-
PDF = ThinReports::Generator::PDF
|
10
|
-
|
11
10
|
def test_new_should_set_title_as_metadata
|
12
|
-
report =
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
report = new_report('layout_text1.tlf') {|r| r.start_new_page }
|
12
|
+
|
13
|
+
actual_pdf_title = nil
|
14
|
+
PDF::Document.define_singleton_method(:new) {|options, meta|
|
15
|
+
actual_pdf_title = meta[:Title]
|
16
|
+
}
|
17
|
+
PDF.new report, {}
|
18
|
+
|
19
|
+
assert_equal 'Basic Layout', actual_pdf_title
|
20
|
+
ensure
|
21
|
+
PDF::Document.singleton_class.send(:remove_method, :new)
|
18
22
|
end
|
19
23
|
end
|
20
|
-
|