thinreports 0.9.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +41 -0
- data/.travis.yml +4 -6
- data/CHANGELOG.md +21 -2
- data/Gemfile +2 -4
- data/README.md +4 -5
- data/Rakefile +7 -8
- data/examples/character_spacing/character_spacing.rb +1 -1
- data/examples/dynamic_image/dynamic_image.rb +3 -3
- data/examples/dynamic_style/dynamic_style.rb +1 -1
- data/examples/eudc/eudc.rb +1 -1
- data/examples/helper.rb +2 -2
- data/examples/hidden_shapes/hidden_shapes.rb +1 -1
- data/examples/list_events/list_events.rb +1 -1
- data/examples/list_manual_generation/list_manual_generation.rb +1 -1
- data/examples/list_page_number/list_page_number.rb +1 -1
- data/examples/page_number/page_number.rb +1 -1
- data/examples/palleted_png/palleted_png.rb +1 -3
- data/examples/password_setting/password_setting.rb +1 -1
- data/examples/report_callbacks/report_callbacks.rb +1 -1
- data/examples/single_line_tblock/single_line_tblock.rb +1 -1
- data/examples/tblock_overflow/tblock_overflow.rb +1 -1
- data/examples/tblock_styles/tblock_styles.rb +1 -1
- data/examples/text_align/text_align.rb +1 -1
- data/examples/typeB_page_size/typeB_page_size.rb +1 -1
- data/examples/word_wrap/word_wrap.rb +1 -1
- data/lib/thinreports.rb +16 -15
- data/lib/thinreports/config.rb +2 -24
- data/lib/thinreports/core/errors.rb +6 -17
- data/lib/thinreports/core/format/base.rb +62 -61
- data/lib/thinreports/core/shape.rb +13 -14
- data/lib/thinreports/core/shape/base.rb +3 -12
- data/lib/thinreports/core/shape/base/interface.rb +35 -32
- data/lib/thinreports/core/shape/base/internal.rb +45 -43
- data/lib/thinreports/core/shape/basic.rb +12 -12
- data/lib/thinreports/core/shape/basic/block_format.rb +8 -6
- data/lib/thinreports/core/shape/basic/block_interface.rb +24 -22
- data/lib/thinreports/core/shape/basic/block_internal.rb +28 -26
- data/lib/thinreports/core/shape/basic/format.rb +11 -9
- data/lib/thinreports/core/shape/basic/interface.rb +79 -77
- data/lib/thinreports/core/shape/basic/internal.rb +17 -14
- data/lib/thinreports/core/shape/image_block.rb +9 -9
- data/lib/thinreports/core/shape/image_block/format.rb +7 -5
- data/lib/thinreports/core/shape/image_block/interface.rb +15 -13
- data/lib/thinreports/core/shape/image_block/internal.rb +10 -8
- data/lib/thinreports/core/shape/list.rb +13 -13
- data/lib/thinreports/core/shape/list/format.rb +83 -77
- data/lib/thinreports/core/shape/list/manager.rb +182 -176
- data/lib/thinreports/core/shape/list/page.rb +94 -93
- data/lib/thinreports/core/shape/list/page_state.rb +42 -40
- data/lib/thinreports/core/shape/list/section_format.rb +28 -26
- data/lib/thinreports/core/shape/list/section_interface.rb +42 -40
- data/lib/thinreports/core/shape/list/section_internal.rb +21 -19
- data/lib/thinreports/core/shape/manager.rb +4 -13
- data/lib/thinreports/core/shape/manager/format.rb +21 -19
- data/lib/thinreports/core/shape/manager/internal.rb +88 -84
- data/lib/thinreports/core/shape/manager/target.rb +93 -95
- data/lib/thinreports/core/shape/page_number.rb +9 -9
- data/lib/thinreports/core/shape/page_number/format.rb +20 -18
- data/lib/thinreports/core/shape/page_number/interface.rb +20 -18
- data/lib/thinreports/core/shape/page_number/internal.rb +47 -44
- data/lib/thinreports/core/shape/style.rb +5 -14
- data/lib/thinreports/core/shape/style/base.rb +121 -120
- data/lib/thinreports/core/shape/style/basic.rb +12 -10
- data/lib/thinreports/core/shape/style/graphic.rb +35 -33
- data/lib/thinreports/core/shape/style/text.rb +113 -107
- data/lib/thinreports/core/shape/text.rb +9 -9
- data/lib/thinreports/core/shape/text/format.rb +10 -9
- data/lib/thinreports/core/shape/text/interface.rb +13 -11
- data/lib/thinreports/core/shape/text/internal.rb +14 -12
- data/lib/thinreports/core/shape/text_block.rb +10 -10
- data/lib/thinreports/core/shape/text_block/format.rb +35 -33
- data/lib/thinreports/core/shape/text_block/formatter.rb +26 -24
- data/lib/thinreports/core/shape/text_block/formatter/basic.rb +25 -25
- data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +15 -12
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +45 -39
- data/lib/thinreports/core/shape/text_block/formatter/padding.rb +17 -14
- data/lib/thinreports/core/shape/text_block/interface.rb +25 -23
- data/lib/thinreports/core/shape/text_block/internal.rb +68 -68
- data/lib/thinreports/core/utils.rb +4 -3
- data/lib/thinreports/generator/pdf.rb +24 -25
- data/lib/thinreports/generator/pdf/document.rb +109 -110
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +58 -51
- data/lib/thinreports/generator/pdf/document/draw_template_items.rb +51 -47
- data/lib/thinreports/generator/pdf/document/font.rb +62 -59
- data/lib/thinreports/generator/pdf/document/graphics.rb +32 -33
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +122 -121
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +113 -114
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +58 -150
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +152 -137
- data/lib/thinreports/generator/pdf/document/page.rb +63 -64
- data/lib/thinreports/generator/pdf/document/parse_color.rb +37 -37
- data/lib/thinreports/generator/pdf/drawer/base.rb +41 -41
- data/lib/thinreports/generator/pdf/drawer/list.rb +48 -45
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +42 -40
- data/lib/thinreports/generator/pdf/drawer/page.rb +101 -96
- data/lib/thinreports/generator/pdf/prawn_ext.rb +4 -30
- data/lib/thinreports/generator/pdf/prawn_ext/calc_image_dimensions.rb +34 -0
- data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +29 -0
- data/lib/thinreports/layout.rb +5 -7
- data/lib/thinreports/layout/base.rb +5 -7
- data/lib/thinreports/layout/format.rb +18 -13
- data/lib/thinreports/layout/legacy_schema.rb +18 -10
- data/lib/thinreports/layout/version.rb +22 -25
- data/lib/thinreports/report.rb +4 -6
- data/lib/thinreports/report/base.rb +24 -51
- data/lib/thinreports/report/internal.rb +9 -11
- data/lib/thinreports/report/page.rb +5 -6
- data/lib/thinreports/version.rb +2 -2
- data/test/schema_helper.rb +4 -3
- data/test/test_helper.rb +9 -3
- data/test/unit/core/format/test_base.rb +1 -1
- data/test/unit/core/shape/base/test_internal.rb +1 -1
- data/test/unit/core/shape/basic/test_block_format.rb +1 -1
- data/test/unit/core/shape/basic/test_block_interface.rb +1 -1
- data/test/unit/core/shape/basic/test_block_internal.rb +1 -1
- data/test/unit/core/shape/basic/test_format.rb +1 -1
- data/test/unit/core/shape/basic/test_interface.rb +1 -1
- data/test/unit/core/shape/basic/test_internal.rb +1 -1
- data/test/unit/core/shape/image_block/test_interface.rb +1 -1
- data/test/unit/core/shape/image_block/test_internal.rb +1 -1
- data/test/unit/core/shape/list/test_format.rb +1 -1
- data/test/unit/core/shape/list/test_manager.rb +4 -4
- data/test/unit/core/shape/list/test_page.rb +1 -1
- data/test/unit/core/shape/list/test_page_state.rb +1 -1
- data/test/unit/core/shape/list/test_section_format.rb +1 -1
- data/test/unit/core/shape/list/test_section_interface.rb +2 -2
- data/test/unit/core/shape/list/test_section_internal.rb +1 -1
- data/test/unit/core/shape/manager/test_format.rb +2 -2
- data/test/unit/core/shape/manager/test_internal.rb +3 -3
- data/test/unit/core/shape/manager/test_target.rb +1 -1
- data/test/unit/core/shape/page_number/test_format.rb +1 -1
- data/test/unit/core/shape/page_number/test_interface.rb +1 -1
- data/test/unit/core/shape/page_number/test_internal.rb +1 -1
- data/test/unit/core/shape/styles/test_base.rb +1 -1
- data/test/unit/core/shape/styles/test_basic.rb +1 -1
- data/test/unit/core/shape/styles/test_graphic.rb +1 -1
- data/test/unit/core/shape/styles/test_text.rb +1 -1
- data/test/unit/core/shape/text/test_format.rb +1 -1
- data/test/unit/core/shape/text/test_internal.rb +1 -1
- data/test/unit/core/shape/text_block/formatter/test_basic.rb +1 -1
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +1 -1
- data/test/unit/core/shape/text_block/formatter/test_number.rb +1 -1
- data/test/unit/core/shape/text_block/formatter/test_padding.rb +2 -2
- data/test/unit/core/shape/text_block/test_format.rb +1 -1
- data/test/unit/core/shape/text_block/test_formatter.rb +1 -1
- data/test/unit/core/shape/text_block/test_interface.rb +1 -1
- data/test/unit/core/shape/text_block/test_internal.rb +3 -3
- data/test/unit/core/test_shape.rb +1 -1
- data/test/unit/core/test_utils.rb +2 -2
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +1 -1
- data/test/unit/generator/pdf/document/graphics/test_basic.rb +2 -1
- data/test/unit/generator/pdf/document/graphics/test_image.rb +27 -131
- data/test/unit/generator/pdf/document/graphics/test_text.rb +1 -1
- data/test/unit/generator/pdf/document/test_font.rb +2 -2
- data/test/unit/generator/pdf/document/test_graphics.rb +1 -1
- data/test/unit/generator/pdf/document/test_page.rb +7 -7
- data/test/unit/generator/pdf/document/test_parse_color.rb +1 -1
- data/test/unit/generator/pdf/prawn_ext/test_calc_image_dimensions.rb +41 -0
- data/test/unit/generator/pdf/prawn_ext/test_width_of.rb +22 -0
- data/test/unit/generator/pdf/test_document.rb +8 -6
- data/test/unit/generator/test_pdf.rb +12 -10
- data/test/unit/layout/test_base.rb +1 -1
- data/test/unit/layout/test_format.rb +2 -2
- data/test/unit/layout/test_legacy_schema.rb +4 -4
- data/test/unit/layout/test_version.rb +11 -80
- data/test/unit/report/test_base.rb +45 -59
- data/test/unit/report/test_internal.rb +1 -1
- data/test/unit/test_config.rb +1 -16
- data/test/unit/test_layout.rb +1 -1
- data/test/unit/test_report.rb +1 -1
- data/thinreports.gemspec +11 -14
- metadata +42 -103
- data/lib/thinreports/generator.rb +0 -29
- data/lib/thinreports/generator/base.rb +0 -40
- data/lib/thinreports/generator/configuration.rb +0 -31
- data/lib/thinreports/report/events.rb +0 -32
- data/test/unit/generator/test_base.rb +0 -40
- data/test/unit/generator/test_configuration.rb +0 -21
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
@@ -29,7 +29,7 @@ class Thinreports::Core::Shape::List::TestManager < Minitest::Test
|
|
29
29
|
|
30
30
|
def test_switch_current_should_replace_own_current_page_property_by_the_given_page
|
31
31
|
report = create_report {|r| r.start_new_page }
|
32
|
-
list
|
32
|
+
list = report.page.list
|
33
33
|
new_page = List::Page.new(report.page, list.internal.format)
|
34
34
|
|
35
35
|
list.manager.switch_current!(new_page)
|
@@ -39,7 +39,7 @@ class Thinreports::Core::Shape::List::TestManager < Minitest::Test
|
|
39
39
|
|
40
40
|
def test_switch_current_should_replace_own_current_page_state_property_by_internal_property_of_the_given_page
|
41
41
|
report = create_report {|r| r.start_new_page }
|
42
|
-
list
|
42
|
+
list = report.page.list
|
43
43
|
new_page = List::Page.new(report.page, list.internal.format)
|
44
44
|
|
45
45
|
list.manager.switch_current!(new_page)
|
@@ -49,7 +49,7 @@ class Thinreports::Core::Shape::List::TestManager < Minitest::Test
|
|
49
49
|
|
50
50
|
def test_switch_current_should_return_the_self
|
51
51
|
report = create_report {|r| r.start_new_page }
|
52
|
-
list
|
52
|
+
list = report.page.list
|
53
53
|
new_page = List::Page.new(report.page, list.internal.format)
|
54
54
|
|
55
55
|
assert_same list.manager.switch_current!(new_page), list.manager
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
@@ -62,7 +62,7 @@ class Thinreports::Core::Shape::List::TestSectionInterface < Minitest::Test
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def copied_list(list, &block)
|
65
|
-
tblock
|
65
|
+
tblock = Thinreports::Core::Shape::TextBlock
|
66
66
|
new_parent = @report.start_new_page
|
67
67
|
|
68
68
|
%w( foo bar hoge ).each do |id|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
@@ -26,7 +26,7 @@ class Thinreports::Core::Shape::Manager::TestFormat < Minitest::Test
|
|
26
26
|
|
27
27
|
def test_find_shape_should_return_format_of_shape_when_shape_is_found
|
28
28
|
format = TestFormat.new({}) do |f|
|
29
|
-
f.shapes[:foo] = Thinreports::Core::Shape::TextBlock::Format.new('id'
|
29
|
+
f.shapes[:foo] = Thinreports::Core::Shape::TextBlock::Format.new('id' => 'foo',
|
30
30
|
'type' => 'text-block')
|
31
31
|
end
|
32
32
|
assert_equal format.find_shape(:foo).id, 'foo'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
@@ -9,8 +9,8 @@ class Thinreports::Core::Shape::Manager::TestInternal < Minitest::Test
|
|
9
9
|
Shape = Thinreports::Core::Shape
|
10
10
|
|
11
11
|
def create_shape_format(type, id, other_config = {})
|
12
|
-
Shape::Format(type).new({'id'
|
13
|
-
'type'
|
12
|
+
Shape::Format(type).new({'id' => id,
|
13
|
+
'type' => type,
|
14
14
|
'display' => true}.merge(other_config))
|
15
15
|
end
|
16
16
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
@@ -34,7 +34,7 @@ class Thinreports::Core::Shape::TextBlock::Formatter::TestPadding < Minitest::Te
|
|
34
34
|
def test_apply_padding_formats_with_right_direction
|
35
35
|
formatter = init_formatter(format_padding_length: 5,
|
36
36
|
format_padding_char: '0',
|
37
|
-
:format_padding_rdir?
|
37
|
+
:format_padding_rdir? => true)
|
38
38
|
|
39
39
|
assert_equal formatter.apply(123), '12300'
|
40
40
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
@@ -13,7 +13,7 @@ class Thinreports::Core::Shape::TextBlock::TestInternal < Minitest::Test
|
|
13
13
|
report.start_new_page do |page|
|
14
14
|
# Add to force TextBlock shape.
|
15
15
|
page.manager.format.shapes[:foo] = TextBlock::Format.new('type' => 'text-block',
|
16
|
-
'id'
|
16
|
+
'id' => 'foo')
|
17
17
|
# Set value to TextBlock.
|
18
18
|
page.item(:foo).value('foo value')
|
19
19
|
end
|
@@ -66,7 +66,7 @@ class Thinreports::Core::Shape::TextBlock::TestInternal < Minitest::Test
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_real_value_should_return_the_formatted_value_when_tblock_has_any_format
|
69
|
-
tblock = create_internal('format' => {'type'
|
69
|
+
tblock = create_internal('format' => {'type' => 'datetime',
|
70
70
|
'datetime' => {'format' => '%Y/%m/%d'}})
|
71
71
|
tblock.write_value(value = Time.now)
|
72
72
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
@@ -10,7 +10,7 @@ class Thinreports::Core::TestShape < Minitest::Test
|
|
10
10
|
expected = '123'
|
11
11
|
assert_same expected, call_block_in(expected)
|
12
12
|
|
13
|
-
assert_equal
|
13
|
+
assert_equal [1, 2, 3], call_block_in([2, 1, 3], &proc { sort! })
|
14
14
|
assert_equal [1, 2, 3], call_block_in([2, 1, 3], &proc { |a| a.sort! })
|
15
15
|
end
|
16
16
|
|
@@ -1,150 +1,46 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
|
-
|
5
4
|
require 'base64'
|
6
|
-
require 'digest/md5'
|
7
5
|
|
8
6
|
class Thinreports::Generator::PDF::Graphics::TestImage < Minitest::Test
|
9
7
|
include Thinreports::TestHelper
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
Thinreports.config.convert_palleted_transparency_png = false
|
17
|
-
|
18
|
-
test_image = TestImage.new
|
19
|
-
base64_image = Base64.encode64(read_data_file('image_normal.png'))
|
20
|
-
|
21
|
-
# Should not be normalized
|
22
|
-
TestImage::PNGNormalizer.stubs(:load_blob).never
|
23
|
-
test_image.normalize_image_from_base64('image/png', base64_image)
|
24
|
-
|
25
|
-
image_registry = test_image.temp_image_registry
|
26
|
-
assert_equal 1, image_registry.count
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_normalize_image_from_file_in_disabled
|
30
|
-
Thinreports.config.convert_palleted_transparency_png = false
|
31
|
-
|
32
|
-
original_image_path = data_file('image_pallete_based.png')
|
33
|
-
|
34
|
-
test_image = TestImage.new
|
35
|
-
returned_image_path = test_image.normalize_image_from_file(original_image_path)
|
36
|
-
|
37
|
-
# Should not be normalized
|
38
|
-
assert_empty test_image.temp_image_registry
|
39
|
-
assert_same original_image_path, returned_image_path
|
9
|
+
def setup
|
10
|
+
format = Thinreports::Layout::Format.build(self.layout_file.path)
|
11
|
+
@document = Thinreports::Generator::PDF::Document.new.tap { |doc|
|
12
|
+
doc.start_new_page(format)
|
13
|
+
}
|
40
14
|
end
|
41
15
|
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
['image/png', 'image_normal.png'],
|
47
|
-
['image/jpeg', 'image_normal.jpg']
|
48
|
-
]
|
49
|
-
.each do |(image_type, image_file)|
|
50
|
-
base64_normal_image = Base64.encode64(read_data_file(image_file))
|
51
|
-
|
52
|
-
test_image = TestImage.new
|
53
|
-
|
54
|
-
normalized_image_path = test_image.normalize_image_from_base64(image_type, base64_normal_image)
|
55
|
-
|
56
|
-
image_registry = test_image.temp_image_registry
|
57
|
-
assert_equal 1, image_registry.count
|
58
|
-
|
59
|
-
image_id = Digest::MD5.hexdigest(base64_normal_image)
|
60
|
-
assert_includes image_registry.keys, image_id
|
61
|
-
assert_equal normalized_image_path, image_registry[image_id].path
|
62
|
-
|
63
|
-
assert equal_image(data_file(image_file), normalized_image_path)
|
64
|
-
|
65
|
-
assert_equal normalized_image_path,
|
66
|
-
test_image.normalize_image_from_base64(image_type, base64_normal_image)
|
16
|
+
def test_image
|
17
|
+
each_image do |image_filename|
|
18
|
+
@document.image(data_file(image_filename), 0, 0, 100, 100)
|
19
|
+
@document.image(StringIO.new(read_data_file(image_filename)), 0, 100, 100, 100)
|
67
20
|
end
|
21
|
+
assert_equal 6, analyze_pdf_images(@document.render).count
|
68
22
|
end
|
69
23
|
|
70
|
-
def
|
71
|
-
|
72
|
-
|
73
|
-
base64_palleted_png = Base64.encode64(read_data_file('image_pallete_based.png'))
|
74
|
-
|
75
|
-
test_image = TestImage.new
|
76
|
-
|
77
|
-
normalized_image_path = test_image.normalize_image_from_base64('image/png', base64_palleted_png)
|
78
|
-
|
79
|
-
image_registry = test_image.temp_image_registry
|
80
|
-
assert_equal 1, image_registry.count
|
81
|
-
|
82
|
-
image_id = Digest::MD5.hexdigest(base64_palleted_png)
|
83
|
-
assert_includes image_registry.keys, image_id
|
84
|
-
assert_equal normalized_image_path, image_registry[image_id].path
|
85
|
-
|
86
|
-
refute equal_image(data_file('image_pallete_based.png'), normalized_image_path)
|
87
|
-
|
88
|
-
assert_not_palette_based_transparency_png File.read(normalized_image_path)
|
89
|
-
|
90
|
-
# 2nd time
|
91
|
-
assert_equal normalized_image_path,
|
92
|
-
test_image.normalize_image_from_base64('image/png', base64_palleted_png)
|
93
|
-
assert_equal 1, test_image.temp_image_registry.count
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_normalize_image_from_file_with_normal_images
|
97
|
-
Thinreports.config.convert_palleted_transparency_png = true
|
98
|
-
|
99
|
-
[
|
100
|
-
data_file('image_normal.png'),
|
101
|
-
data_file('iamge_normal.jpg'),
|
102
|
-
data_file('image_normal_png_noext'),
|
103
|
-
data_file('image_normal_jpg_noext')
|
104
|
-
]
|
105
|
-
.each do |original_image_path|
|
106
|
-
test_image = TestImage.new
|
107
|
-
image_path = test_image.normalize_image_from_file(original_image_path)
|
108
|
-
|
109
|
-
assert_equal original_image_path, image_path
|
110
|
-
assert_empty test_image.temp_image_registry
|
24
|
+
def test_base64image
|
25
|
+
each_image do |image_filename|
|
26
|
+
@document.base64image(Base64.encode64(read_data_file(image_filename)), 0, 0, 100, 100)
|
111
27
|
end
|
28
|
+
assert_equal 3, analyze_pdf_images(@document.render).count
|
112
29
|
end
|
113
30
|
|
114
|
-
def
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
normalized_image_path = test_image.normalize_image_from_file(original_image_path)
|
122
|
-
image_registry = test_image.temp_image_registry
|
123
|
-
|
124
|
-
assert_equal 1, image_registry.count
|
125
|
-
assert_includes image_registry.keys, original_image_path
|
126
|
-
|
127
|
-
refute equal_image(original_image_path, normalized_image_path)
|
128
|
-
|
129
|
-
assert_not_palette_based_transparency_png File.read(normalized_image_path)
|
130
|
-
|
131
|
-
# It should never called in 2nd time or subsequent.
|
132
|
-
TestImage::PNGNormalizer.stubs(:load_file).never
|
133
|
-
assert_equal normalized_image_path,
|
134
|
-
test_image.normalize_image_from_file(original_image_path)
|
135
|
-
end
|
136
|
-
|
137
|
-
def assert_not_palette_based_transparency_png(data)
|
138
|
-
image_data = ChunkyPNG::Image.from_blob(data)
|
139
|
-
datastream = ChunkyPNG::Datastream.from_blob(data)
|
140
|
-
|
141
|
-
assert_equal ChunkyPNG::COLOR_INDEXED, image_data.palette.best_color_settings.first
|
142
|
-
assert_equal nil, datastream.transparency_chunk
|
31
|
+
def test_image_box
|
32
|
+
each_image do |image_filename|
|
33
|
+
@document.image_box(data_file(image_filename), 0, 0, 100, 100)
|
34
|
+
@document.image(StringIO.new(read_data_file(image_filename)), 0, 100, 100, 100)
|
35
|
+
end
|
36
|
+
assert_equal 6, analyze_pdf_images(@document.render).count
|
143
37
|
end
|
144
38
|
|
145
|
-
def
|
146
|
-
|
147
|
-
|
148
|
-
|
39
|
+
def each_image(&block)
|
40
|
+
%w(
|
41
|
+
image_normal.png
|
42
|
+
image_normal.jpg
|
43
|
+
image_pallete_based.png
|
44
|
+
).each { |image_filename| block.call(image_filename) }
|
149
45
|
end
|
150
46
|
end
|