thinreports 0.7.6 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,69 +1,90 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
4
|
-
|
|
5
|
-
class
|
|
6
|
-
include
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def test_setup_fonts_install_builtin_fonts
|
|
16
|
-
Font::BUILTIN_FONTS.each_key do |font|
|
|
17
|
-
assert_includes @doc.internal.font_families.keys, font
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Generator::PDF::TestFont < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
|
+
|
|
8
|
+
Font = Thinreports::Generator::PDF::Font
|
|
9
|
+
|
|
10
|
+
def teardown
|
|
11
|
+
# Reset font settings
|
|
12
|
+
Thinreports.configure do |c|
|
|
13
|
+
c.fallback_fonts = []
|
|
14
|
+
c.generator.pdf.eudc_fonts = []
|
|
18
15
|
end
|
|
19
16
|
end
|
|
20
|
-
|
|
21
|
-
def
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
assert_includes @doc.internal.font_families.keys, 'EUDC1'
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def test_setup_fonts_install_fallback_fonts_as_eudc
|
|
35
|
-
ThinReports.config.generator.pdf.eudc_fonts = 'eudc.ttf'
|
|
36
|
-
setup
|
|
37
|
-
|
|
38
|
-
assert_includes @doc.internal.fallback_fonts, 'EUDC0'
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def test_fallback_font_has_all_styles_as_normal_IPAMincho
|
|
42
|
-
ipam = Font::BUILTIN_FONTS['IPAMincho'][:normal]
|
|
43
|
-
[:normal, :bold, :italic, :bold_italic].each do |style|
|
|
44
|
-
assert_same @doc.internal.font_families['DefaultFont'][style], ipam
|
|
17
|
+
|
|
18
|
+
def test_setup_fonts
|
|
19
|
+
pdf = document.pdf
|
|
20
|
+
|
|
21
|
+
Font::BUILTIN_FONTS.each do |name, font|
|
|
22
|
+
assert_equal font, pdf.font_families[name]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
Font::PRAWN_BUINTIN_FONT_ARIASES.each do |alias_font, original_font|
|
|
26
|
+
assert_equal pdf.font_families[alias_font],
|
|
27
|
+
pdf.font_families[original_font]
|
|
45
28
|
end
|
|
29
|
+
|
|
30
|
+
assert_equal Font::DEFAULT_FALLBACK_FONTS, pdf.fallback_fonts[-2..-1]
|
|
46
31
|
end
|
|
47
|
-
|
|
48
|
-
def
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
32
|
+
|
|
33
|
+
def test_setup_fonts_with_custom_fallback_fonts
|
|
34
|
+
Thinreports.configure do |c|
|
|
35
|
+
c.fallback_fonts = []
|
|
36
|
+
c.generator.pdf.eudc_fonts = []
|
|
37
|
+
end
|
|
38
|
+
assert_equal Font::DEFAULT_FALLBACK_FONTS,
|
|
39
|
+
document.pdf.fallback_fonts
|
|
40
|
+
|
|
41
|
+
Thinreports.configure do |c|
|
|
42
|
+
c.fallback_fonts = 'IPAGothic'
|
|
43
|
+
c.generator.pdf.eudc_fonts = []
|
|
44
|
+
end
|
|
45
|
+
assert_equal ['IPAGothic'] + Font::DEFAULT_FALLBACK_FONTS,
|
|
46
|
+
document.pdf.fallback_fonts
|
|
47
|
+
|
|
48
|
+
Thinreports.configure do |c|
|
|
49
|
+
c.fallback_fonts = ['IPAMincho']
|
|
50
|
+
c.generator.pdf.eudc_fonts = [data_file('font.ttf')]
|
|
51
|
+
end
|
|
52
|
+
assert_equal ['Custom-fallback-font0', 'IPAMincho'] + Font::DEFAULT_FALLBACK_FONTS,
|
|
53
|
+
document.pdf.fallback_fonts
|
|
54
|
+
|
|
55
|
+
Thinreports.configure do |c|
|
|
56
|
+
c.generator.pdf.eudc_fonts = [data_file('font.ttf')]
|
|
57
|
+
c.fallback_fonts = ['IPAMincho', 'IPAMincho', data_file('font.ttf')]
|
|
58
|
+
end
|
|
59
|
+
assert_equal ['Custom-fallback-font0', 'IPAMincho'] + Font::DEFAULT_FALLBACK_FONTS,
|
|
60
|
+
document.pdf.fallback_fonts
|
|
53
61
|
end
|
|
54
|
-
|
|
55
|
-
def
|
|
56
|
-
|
|
62
|
+
|
|
63
|
+
def test_setup_fonts_with_unknown_custom_fallback_fonts
|
|
64
|
+
Thinreports.configure do |c|
|
|
65
|
+
c.fallback_fonts = ['/path/to/unknown.ttf']
|
|
66
|
+
c.generator.pdf.eudc_fonts = []
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
assert_raises Thinreports::Errors::FontFileNotFound do
|
|
70
|
+
create_document
|
|
71
|
+
end
|
|
57
72
|
end
|
|
58
|
-
|
|
59
|
-
def
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
assert_equal
|
|
73
|
+
|
|
74
|
+
def test_font_helpers
|
|
75
|
+
doc = document
|
|
76
|
+
|
|
77
|
+
assert_equal 'Helvetica', doc.default_family
|
|
78
|
+
|
|
79
|
+
assert_equal 'Helvetica', doc.default_family_if_missing('unknown')
|
|
80
|
+
assert_equal 'IPAMincho', doc.default_family_if_missing('IPAMincho')
|
|
81
|
+
|
|
82
|
+
assert_equal false, doc.font_has_style?('IPAMincho', :bold)
|
|
83
|
+
assert_equal true, doc.font_has_style?('Courier New', :bold)
|
|
63
84
|
end
|
|
64
|
-
|
|
65
|
-
def
|
|
66
|
-
|
|
67
|
-
assert_equal @doc.send(:font_has_style?, 'Courier New', :bold), true
|
|
85
|
+
|
|
86
|
+
def document
|
|
87
|
+
Thinreports::Generator::PDF::Document.new
|
|
68
88
|
end
|
|
89
|
+
alias_method :create_document, :document
|
|
69
90
|
end
|
|
@@ -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,95 +1,120 @@
|
|
|
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
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_page_geometry
|
|
13
|
+
page_geometry = ::PDF::Core::PageGeometry::SIZES
|
|
14
|
+
assert_equal page_geometry['B4_JIS'], [728.5, 1031.8]
|
|
15
|
+
assert_equal page_geometry['B5_JIS'], [515.9, 728.5]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_B4_paper_size_should_be_converted_to_B4_JIS
|
|
19
|
+
create_pdf
|
|
20
|
+
|
|
21
|
+
format = new_layout_format('layout_text1.tlf')
|
|
22
|
+
format.stubs(page_paper_type: 'B4')
|
|
23
|
+
|
|
24
|
+
@pdf.start_new_page(format)
|
|
25
|
+
assert_equal @pdf.internal.page.size, 'B4_JIS'
|
|
10
26
|
end
|
|
11
|
-
|
|
27
|
+
|
|
28
|
+
def test_B4_ISO_paper_size_should_be_converted_to_B4
|
|
29
|
+
create_pdf
|
|
30
|
+
|
|
31
|
+
format = new_layout_format('layout_text1.tlf')
|
|
32
|
+
format.stubs(page_paper_type: 'B4_ISO')
|
|
33
|
+
|
|
34
|
+
@pdf.start_new_page(format)
|
|
35
|
+
assert_equal @pdf.internal.page.size, 'B4'
|
|
36
|
+
end
|
|
37
|
+
|
|
12
38
|
def test_change_page_format_should_return_true_at_first_time
|
|
13
39
|
create_pdf
|
|
14
|
-
format =
|
|
15
|
-
|
|
40
|
+
format = new_layout_format('layout_text1.tlf')
|
|
41
|
+
|
|
16
42
|
assert_equal @pdf.send(:change_page_format?, format), true
|
|
17
43
|
end
|
|
18
|
-
|
|
44
|
+
|
|
19
45
|
def test_change_page_format_should_return_false_when_given_the_same_format
|
|
20
46
|
create_pdf
|
|
21
|
-
format =
|
|
22
|
-
|
|
47
|
+
format = new_layout_format('layout_text1.tlf')
|
|
48
|
+
|
|
23
49
|
@pdf.instance_variable_set(:@current_page_format, format)
|
|
24
50
|
assert_equal @pdf.send(:change_page_format?, format), false
|
|
25
51
|
end
|
|
26
|
-
|
|
52
|
+
|
|
27
53
|
def test_change_page_format_should_return_true_when_given_the_other_format
|
|
28
54
|
create_pdf
|
|
29
|
-
format1 =
|
|
30
|
-
format2 =
|
|
31
|
-
|
|
55
|
+
format1 = new_layout_format('layout_text1.tlf')
|
|
56
|
+
format2 = new_layout_format('layout_text2.tlf')
|
|
57
|
+
|
|
32
58
|
@pdf.instance_variable_set(:@current_page_format, format1)
|
|
33
59
|
assert_equal @pdf.send(:change_page_format?, format2), true
|
|
34
60
|
end
|
|
35
|
-
|
|
61
|
+
|
|
36
62
|
def test_new_basic_page_options
|
|
37
|
-
format =
|
|
63
|
+
format = new_layout_format('layout_text1.tlf')
|
|
38
64
|
options = create_pdf.send(:new_basic_page_options, format)
|
|
39
|
-
|
|
65
|
+
|
|
40
66
|
assert_equal options[:layout], format.page_orientation.to_sym
|
|
41
67
|
assert_equal options[:size], format.page_paper_type
|
|
42
68
|
end
|
|
43
|
-
|
|
69
|
+
|
|
44
70
|
def test_new_basic_page_options_when_the_layout_has_customize_size
|
|
45
|
-
format =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
71
|
+
format = stub user_paper_type?: true,
|
|
72
|
+
page_width: 100,
|
|
73
|
+
page_height: 100,
|
|
74
|
+
page_orientation: 'portrait'
|
|
75
|
+
|
|
51
76
|
options = create_pdf.send(:new_basic_page_options, format)
|
|
52
77
|
assert_equal options[:size], [100, 100]
|
|
53
78
|
end
|
|
54
|
-
|
|
79
|
+
|
|
55
80
|
def test_start_new_page_should_create_stamp
|
|
56
81
|
create_pdf
|
|
57
|
-
format =
|
|
82
|
+
format = new_layout_format('layout_text1.tlf')
|
|
58
83
|
@pdf.start_new_page(format)
|
|
59
|
-
|
|
84
|
+
|
|
60
85
|
assert_includes @pdf.send(:format_stamp_registry), format.identifier
|
|
61
86
|
end
|
|
62
|
-
|
|
87
|
+
|
|
63
88
|
def test_start_new_page_should_not_create_stamp
|
|
64
89
|
create_pdf
|
|
65
|
-
format =
|
|
90
|
+
format = new_layout_format('layout_text1.tlf')
|
|
66
91
|
@pdf.start_new_page(format)
|
|
67
92
|
@pdf.start_new_page(format)
|
|
68
|
-
|
|
93
|
+
|
|
69
94
|
assert_equal @pdf.send(:format_stamp_registry).size, 1
|
|
70
95
|
end
|
|
71
|
-
|
|
96
|
+
|
|
72
97
|
def test_start_new_page_should_stamp_constantly
|
|
73
98
|
create_pdf
|
|
74
|
-
format =
|
|
75
|
-
|
|
76
|
-
|
|
99
|
+
format = new_layout_format('layout_text1.tlf')
|
|
100
|
+
@pdf.expects(:stamp).with(format.identifier.to_s).times(2)
|
|
101
|
+
|
|
77
102
|
@pdf.start_new_page(format)
|
|
78
103
|
@pdf.start_new_page(format)
|
|
79
104
|
end
|
|
80
|
-
|
|
105
|
+
|
|
81
106
|
def test_add_blank_page_should_create_an_A4_size_page_in_first_page
|
|
82
107
|
create_pdf
|
|
83
|
-
|
|
84
|
-
|
|
108
|
+
@pdf.internal.expects(:start_new_page).with(size: 'A4').once
|
|
109
|
+
|
|
85
110
|
@pdf.add_blank_page
|
|
86
111
|
end
|
|
87
|
-
|
|
112
|
+
|
|
88
113
|
def test_add_blank_page_should_call_with_no_arguments_since_second_page
|
|
89
114
|
create_pdf
|
|
90
|
-
@pdf.start_new_page(
|
|
91
|
-
|
|
92
|
-
|
|
115
|
+
@pdf.start_new_page(new_layout_format('layout_text1.tlf'))
|
|
116
|
+
@pdf.internal.expects(:start_new_page).with({}).once
|
|
117
|
+
|
|
93
118
|
@pdf.add_blank_page
|
|
94
119
|
end
|
|
95
|
-
end
|
|
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,29 +1,23 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
include
|
|
7
|
-
|
|
8
|
-
# Alias
|
|
9
|
-
PDF = ThinReports::Generator::PDF
|
|
10
|
-
|
|
11
|
-
def test_new_should_set_empty_title_when_the_default_layout_is_not_set
|
|
12
|
-
report = ThinReports::Report.new
|
|
13
|
-
report.start_new_page :layout => data_file('basic_layout1.tlf')
|
|
5
|
+
class Thinreports::Generator::TestPDF < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
14
7
|
|
|
15
|
-
|
|
16
|
-
with(Hash, :Title => nil).once
|
|
17
|
-
|
|
18
|
-
PDF.new(report, {})
|
|
19
|
-
end
|
|
8
|
+
PDF = Thinreports::Generator::PDF
|
|
20
9
|
|
|
21
10
|
def test_new_should_set_title_as_metadata
|
|
22
|
-
report =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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)
|
|
28
22
|
end
|
|
29
23
|
end
|