thinreports 0.7.7 → 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 +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,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::Core::TestEvents < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
8
|
# Alias
|
|
9
|
-
Events =
|
|
9
|
+
Events = Thinreports::Core::Events
|
|
10
10
|
|
|
11
11
|
def setup
|
|
12
12
|
@events = Events.new(:load, :change, :blur)
|
|
@@ -33,7 +33,7 @@ class ThinReports::Core::TestEvents < MiniTest::Unit::TestCase
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def test_listen_raise_error_when_unknown_event_type_is_set
|
|
36
|
-
assert_raises
|
|
36
|
+
assert_raises Thinreports::Errors::UnknownEventType do
|
|
37
37
|
@events.listen(:unknown) {|e| e.type }
|
|
38
38
|
end
|
|
39
39
|
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::Core::TestShape < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
8
|
# Alias
|
|
9
|
-
ShapeModule =
|
|
9
|
+
ShapeModule = Thinreports::Core::Shape
|
|
10
10
|
|
|
11
11
|
def test_find_by_type_should_return_PageNumber
|
|
12
12
|
assert_same ShapeModule.find_by_type('s-pageno'), ShapeModule::PageNumber
|
|
@@ -45,7 +45,7 @@ class ThinReports::Core::TestShape < MiniTest::Unit::TestCase
|
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def test_find_by_type_should_raise
|
|
48
|
-
assert_raises
|
|
48
|
+
assert_raises Thinreports::Errors::UnknownShapeType do
|
|
49
49
|
ShapeModule.find_by_type('unknown')
|
|
50
50
|
end
|
|
51
51
|
end
|
|
@@ -57,7 +57,7 @@ class ThinReports::Core::TestShape < MiniTest::Unit::TestCase
|
|
|
57
57
|
|
|
58
58
|
def test_Configuration_should_raise
|
|
59
59
|
# When shape don't have a Configuration
|
|
60
|
-
assert_raises
|
|
60
|
+
assert_raises Thinreports::Errors::NoConfigurationFound do
|
|
61
61
|
ShapeModule::Configuration('s-line')
|
|
62
62
|
end
|
|
63
63
|
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::TestShape < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
|
+
include Thinreports::Utils
|
|
8
|
+
|
|
9
|
+
def test_call_block_in
|
|
10
|
+
expected = '123'
|
|
11
|
+
assert_same expected, call_block_in(expected)
|
|
12
|
+
|
|
13
|
+
assert_equal '321', call_block_in('123', &proc { reverse! })
|
|
14
|
+
assert_equal [1, 2, 3], call_block_in([2, 1, 3], &proc { |a| a.sort! })
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_deep_copy_in_unsupported_object
|
|
18
|
+
[123, nil, Struct.new(:foo).new].each do |unsupported_value|
|
|
19
|
+
assert_raises ArgumentError do
|
|
20
|
+
deep_copy(unsupported_value)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_deep_copy_in_Array
|
|
26
|
+
src = ['string', Time.now]
|
|
27
|
+
dup = deep_copy(src)
|
|
28
|
+
|
|
29
|
+
refute_same dup, src
|
|
30
|
+
|
|
31
|
+
src.each_with_index do |e, i|
|
|
32
|
+
assert_equal dup[i], e
|
|
33
|
+
refute_same dup[i], e
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_deep_copy_in_Hash
|
|
38
|
+
src = { a: 'string', b: Time.now }
|
|
39
|
+
dup = deep_copy(src)
|
|
40
|
+
|
|
41
|
+
refute_same dup, src
|
|
42
|
+
|
|
43
|
+
src.each do |k, v|
|
|
44
|
+
assert_equal dup[k], v
|
|
45
|
+
refute_same dup[k], v
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_blank_value_in_String
|
|
50
|
+
["", ''].each do |val|
|
|
51
|
+
assert_equal true, blank_value?(val)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
[' ', ' ', 'abc', 'あいう'].each do |val|
|
|
55
|
+
assert_equal false, blank_value?(val)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_blank_value_in_NilClass
|
|
60
|
+
assert_equal true, blank_value?(nil)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_blank_value_in_other_classes
|
|
64
|
+
[0, 1, -1, 9.99, true, false, Time.now].each do |val|
|
|
65
|
+
assert_equal false, blank_value?(val)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
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::Graphics::TestAttributes < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
8
|
def setup
|
|
9
|
-
@pdf =
|
|
9
|
+
@pdf = Thinreports::Generator::PDF::Document.new
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def test_common_graphic_attrs_should_return_converted_Hash_as_attributes
|
|
@@ -1,164 +1,171 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Generator::PDF::Graphics::TestText < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
4
7
|
|
|
5
|
-
class ThinReports::Generator::PDF::Graphics::TestText < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
8
|
def setup
|
|
9
|
-
@pdf =
|
|
9
|
+
@pdf = Thinreports::Generator::PDF::Document.new
|
|
10
10
|
@pdf.internal.start_new_page
|
|
11
11
|
end
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
def exec_with_font_styles(attrs = nil, font = nil, &block)
|
|
14
|
-
attrs ||= {:
|
|
15
|
-
font ||= {:
|
|
16
|
-
|
|
14
|
+
attrs ||= {styles: [:bold]}
|
|
15
|
+
font ||= {name: 'IPAMincho', size: 18, color: 'ff0000'}
|
|
16
|
+
|
|
17
17
|
@pdf.send(:with_font_styles, attrs, font, &block)
|
|
18
18
|
end
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
def exec_with_text_styles(attrs = {}, &block)
|
|
21
|
-
default_attrs = {:
|
|
22
|
-
:
|
|
23
|
-
:
|
|
21
|
+
default_attrs = {font: 'Helvetica',
|
|
22
|
+
color: 'ff0000',
|
|
23
|
+
size: 18}
|
|
24
24
|
@pdf.send(:with_text_styles, default_attrs.merge(attrs), &block)
|
|
25
25
|
end
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
def test_with_text_styles_should_not_operate_when_color_is_none
|
|
28
|
-
exec_with_text_styles(:
|
|
28
|
+
exec_with_text_styles(color: 'none') do |attrs, styles|
|
|
29
29
|
flunk
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
def test_with_text_styles_should_set_leading_via_line_height_attribute
|
|
34
|
-
exec_with_text_styles(:
|
|
34
|
+
exec_with_text_styles(line_height: 30) do |attrs, styles|
|
|
35
35
|
expected = @pdf.send(:text_line_leading,
|
|
36
36
|
@pdf.send(:s2f, 30),
|
|
37
|
-
:
|
|
37
|
+
name: 'Helvetica', size: 18)
|
|
38
38
|
assert_equal attrs[:leading], expected
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
def test_with_text_styles_should_not_set_leading_when_line_height_is_not_specified
|
|
43
43
|
exec_with_text_styles do |attrs, styles|
|
|
44
44
|
refute_includes attrs.keys, :leading
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
def test_with_text_styles_should_set_character_spacing_via_letter_spacing_attribute
|
|
49
|
-
exec_with_text_styles(:
|
|
49
|
+
exec_with_text_styles(letter_spacing: 5) do |attrs, styles|
|
|
50
50
|
assert_equal attrs[:character_spacing], @pdf.send(:s2f, 5)
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
def test_with_text_styles_should_not_set_character_spacing_when_letter_spacing_is_not_specified
|
|
55
55
|
exec_with_text_styles do |attrs, styles|
|
|
56
56
|
refute_includes attrs.keys, :character_spacing
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
def test_with_text_styles_should_parse_color
|
|
61
|
-
exec_with_text_styles(:
|
|
61
|
+
exec_with_text_styles(color: '#ff0000') do |attrs, styles|
|
|
62
62
|
assert_equal @pdf.internal.fill_color, 'ff0000'
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
def test_with_font_styles_should_set_fill_color_using_color_of_font
|
|
67
67
|
exec_with_font_styles do |attrs, styles|
|
|
68
68
|
assert_equal @pdf.internal.fill_color, 'ff0000'
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
|
-
|
|
71
|
+
|
|
72
72
|
def test_with_font_styles_should_perform_manual_style_when_bold_style_cannot_be_applied
|
|
73
73
|
exec_with_font_styles do |attrs, styles|
|
|
74
74
|
assert_empty styles
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
def test_with_font_styles_should_perform_manual_style_when_italic_style_cannot_be_applied
|
|
79
79
|
exec_with_font_styles do |attrs, styles|
|
|
80
80
|
assert_empty styles
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
|
-
|
|
83
|
+
|
|
84
84
|
def test_with_font_styles_should_set_stroke_color_using_color_of_font_when_bold_style_cannot_be_applied
|
|
85
85
|
exec_with_font_styles do |attrs, styles|
|
|
86
86
|
assert_equal @pdf.internal.stroke_color, 'ff0000'
|
|
87
87
|
end
|
|
88
88
|
end
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
def test_with_font_styles_should_set_line_width_calculated_from_font_size_when_bold_style_cannot_be_applied
|
|
91
91
|
exec_with_font_styles do |attrs, styles|
|
|
92
92
|
assert_equal @pdf.internal.line_width, 18 * 0.025
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
def test_with_font_styles_should_set_mode_to_fill_stroke_when_bold_style_cannot_be_applied
|
|
97
97
|
exec_with_font_styles do |attrs, styles|
|
|
98
98
|
assert_equal attrs[:mode], :fill_stroke
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
|
-
|
|
101
|
+
|
|
102
102
|
def test_with_font_styles_should_not_perform_a_manual_style_when_bold_style_can_be_applied
|
|
103
|
-
exec_with_font_styles(nil, :
|
|
103
|
+
exec_with_font_styles(nil, name: 'Helvetica', size: 12, color: '0000ff') do |attrs, styles|
|
|
104
104
|
assert_includes styles, :bold
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
|
-
|
|
107
|
+
|
|
108
108
|
def test_with_font_styles_should_not_perform_a_manual_style_when_italic_style_can_be_applied
|
|
109
|
-
exec_with_font_styles({:
|
|
109
|
+
exec_with_font_styles({styles: [:italic]}, name: 'Helvetica', size: 12, color: 'ff0000') do |attrs, styles|
|
|
110
110
|
assert_includes styles, :italic
|
|
111
111
|
end
|
|
112
112
|
end
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
def test_text_line_leading_should_return_a_specified_leading_value_minus_the_font_height
|
|
115
|
-
font = {:
|
|
116
|
-
font_height = @pdf.internal.font(font[:name], :
|
|
117
|
-
|
|
115
|
+
font = {name: 'IPAMincho', size: 36}
|
|
116
|
+
font_height = @pdf.internal.font(font[:name], size: font[:size]).height
|
|
117
|
+
|
|
118
118
|
assert_equal @pdf.send(:text_line_leading, 100, font), 100 - font_height
|
|
119
119
|
end
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
def test_text_without_line_wrap_should_replace_the_spaces_NBSP
|
|
122
122
|
assert_equal @pdf.send(:text_without_line_wrap, ' ' * 2), Prawn::Text::NBSP * 2
|
|
123
123
|
end
|
|
124
|
-
|
|
124
|
+
|
|
125
125
|
def test_text_box_should_not_raise_PrawnCannotFitError
|
|
126
|
-
@pdf.text_box('foo', 0, 0, 1, 1, :
|
|
127
|
-
:
|
|
128
|
-
:
|
|
126
|
+
@pdf.text_box('foo', 0, 0, 1, 1, font: 'IPAMincho',
|
|
127
|
+
size: 100,
|
|
128
|
+
color: '000000')
|
|
129
129
|
rescue Prawn::Errors::CannotFit
|
|
130
130
|
flunk('Raise Prawn::Errors::CannotFit.')
|
|
131
131
|
end
|
|
132
|
-
|
|
132
|
+
|
|
133
133
|
def test_text_box_attrs_should_return_a_Hash_containing_a_at_and_width_options
|
|
134
134
|
attrs = @pdf.send(:text_box_attrs, 0, 0, 50, 100)
|
|
135
|
-
|
|
135
|
+
|
|
136
136
|
assert_equal attrs.values_at(:at, :width),
|
|
137
137
|
[@pdf.send(:pos, 0, 0), @pdf.send(:s2f, 50)]
|
|
138
138
|
end
|
|
139
|
-
|
|
139
|
+
|
|
140
140
|
def test_text_box_attrs_should_return_a_Hash_which_doesnt_contain_the_single_line_option_when_single_is_true_but_overflow_is_expand
|
|
141
|
-
attrs = @pdf.send(:text_box_attrs, 0, 0, 100, 100, :
|
|
141
|
+
attrs = @pdf.send(:text_box_attrs, 0, 0, 100, 100, single: true, overflow: :expand)
|
|
142
142
|
refute attrs.key?(:single_line)
|
|
143
143
|
end
|
|
144
|
-
|
|
144
|
+
|
|
145
145
|
def test_text_box_attrs_should_return_a_Hash_containing_a_single_line_option_when_single_is_true_and_overflow_isnot_expand
|
|
146
|
-
attrs = @pdf.send(:text_box_attrs, 0, 0, 100, 100, :
|
|
146
|
+
attrs = @pdf.send(:text_box_attrs, 0, 0, 100, 100, single: true, overflow: :truncate)
|
|
147
147
|
assert_equal attrs[:single_line], true
|
|
148
148
|
end
|
|
149
|
-
|
|
149
|
+
|
|
150
150
|
def test_text_box_attrs_should_return_a_Hash_which_does_not_contain_a_height_option_when_single_is_true
|
|
151
|
-
attrs = @pdf.send(:text_box_attrs, 0, 0, 100, 100, :
|
|
151
|
+
attrs = @pdf.send(:text_box_attrs, 0, 0, 100, 100, single: true)
|
|
152
152
|
refute attrs.key?(:height)
|
|
153
153
|
end
|
|
154
|
-
|
|
154
|
+
|
|
155
155
|
def test_text_box_attrs_should_return_a_Hash_which_does_not_contain_a_single_line_option_when_single_is_not_specified
|
|
156
156
|
attrs = @pdf.send(:text_box_attrs, 0, 0, 100, 100)
|
|
157
157
|
refute attrs.key?(:single_line)
|
|
158
158
|
end
|
|
159
|
-
|
|
159
|
+
|
|
160
160
|
def test_text_box_attrs_should_return_a_Hash_containing_a_height_optin_when_single_is_not_specified
|
|
161
161
|
attrs = @pdf.send(:text_box_attrs, 0, 0, 100, 200)
|
|
162
162
|
assert_equal attrs[:height], 200
|
|
163
163
|
end
|
|
164
|
+
|
|
165
|
+
def test_text
|
|
166
|
+
@pdf.expects(:text_box).
|
|
167
|
+
with('contents', 100, 200, 150, 250, { overflow: :shirink_to_fit }).once
|
|
168
|
+
|
|
169
|
+
@pdf.text('contents', 100, 200, 150, 250)
|
|
170
|
+
end
|
|
164
171
|
end
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
include
|
|
5
|
+
class Thinreports::Generator::PDF::TestDrawShape < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
8
|
def setup
|
|
9
|
-
@pdf =
|
|
9
|
+
@pdf = Thinreports::Generator::PDF::Document.new
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def create_tblock_interface(format_config = {})
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
report = new_report 'layout_text1'
|
|
14
|
+
parent = report.start_new_page
|
|
15
|
+
|
|
16
|
+
format = Thinreports::Core::Shape::TextBlock::Format.new format_config
|
|
17
|
+
Thinreports::Core::Shape::TextBlock::Interface.new parent, format
|
|
15
18
|
end
|
|
16
19
|
|
|
17
20
|
def test_shape_text_attrs_should_return_attrs_containing_an_overflow_property
|
|
@@ -39,4 +42,3 @@ class ThinReports::Generator::PDF::TestDrawShape < MiniTest::Unit::TestCase
|
|
|
39
42
|
assert_includes @pdf.send(:shape_text_attrs, tblock.internal).keys, :word_wrap
|
|
40
43
|
end
|
|
41
44
|
end
|
|
42
|
-
|
|
@@ -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
|