thinreports 0.10.3 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +39 -0
- data/CHANGELOG.md +20 -0
- data/Dockerfile +12 -0
- data/Gemfile +5 -0
- data/README.md +37 -13
- data/Rakefile +1 -0
- data/lib/thinreports/core/shape/image_block.rb +1 -1
- data/lib/thinreports/core/shape/list.rb +1 -1
- data/lib/thinreports/core/shape/page_number.rb +1 -1
- data/lib/thinreports/core/shape/text.rb +1 -1
- data/lib/thinreports/core/shape/text_block.rb +1 -1
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +6 -1
- data/lib/thinreports/core/shape/text_block/internal.rb +0 -2
- data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +6 -0
- data/lib/thinreports/layout/base.rb +1 -1
- data/lib/thinreports/layout/version.rb +1 -1
- data/lib/thinreports/report/internal.rb +2 -0
- data/lib/thinreports/version.rb +1 -1
- data/thinreports.gemspec +5 -9
- metadata +6 -204
- data/.travis.yml +0 -32
- data/test/data/font.ttf +0 -0
- data/test/data/image_normal.jpg +0 -0
- data/test/data/image_normal.png +0 -0
- data/test/data/image_normal_jpg_noext +0 -0
- data/test/data/image_normal_png_noext +0 -0
- data/test/data/image_pallete_based.png +0 -0
- data/test/data/legacy_layout/all-items.tlf +0 -1
- data/test/features/dynamic_style/expect.pdf +0 -3714
- data/test/features/dynamic_style/image.png +0 -0
- data/test/features/dynamic_style/templates/styles.tlf +0 -1835
- data/test/features/dynamic_style/templates/styles_in_list.tlf +0 -344
- data/test/features/dynamic_style/test_dynamic_style.rb +0 -152
- data/test/features/eudc/eudc.ttf +0 -0
- data/test/features/eudc/expect.pdf +0 -0
- data/test/features/eudc/template.tlf +0 -180
- data/test/features/eudc/test_eudc.rb +0 -27
- data/test/features/feature_test.rb +0 -58
- data/test/features/graphics/expect.pdf +0 -475
- data/test/features/graphics/template.tlf +0 -309
- data/test/features/graphics/test_graphics.rb +0 -12
- data/test/features/hidden_item/expect.pdf +0 -0
- data/test/features/hidden_item/template.tlf +0 -449
- data/test/features/hidden_item/test_hidden_item.rb +0 -12
- data/test/features/image_block/expect.pdf +0 -0
- data/test/features/image_block/img200x100.png +0 -0
- data/test/features/image_block/img50x50.png +0 -0
- data/test/features/image_block/template.tlf +0 -661
- data/test/features/image_block/test_image_block.rb +0 -35
- data/test/features/list_events/expect.pdf +0 -659
- data/test/features/list_events/template.tlf +0 -361
- data/test/features/list_events/test_list_events.rb +0 -36
- data/test/features/list_manually/expect.pdf +0 -599
- data/test/features/list_manually/template.tlf +0 -132
- data/test/features/list_manually/test_list_manually.rb +0 -25
- data/test/features/page_number/expect.pdf +0 -400
- data/test/features/page_number/template.tlf +0 -215
- data/test/features/page_number/test_page_number.rb +0 -24
- data/test/features/page_number_with_list/expect.pdf +0 -721
- data/test/features/page_number_with_list/template.tlf +0 -254
- data/test/features/page_number_with_list/test_page_number_with_list.rb +0 -21
- data/test/features/palleted_png/expect.pdf +0 -0
- data/test/features/palleted_png/palleted_png.png +0 -0
- data/test/features/palleted_png/template.tlf +0 -47
- data/test/features/palleted_png/test_palleted_png.rb +0 -14
- data/test/features/report_callbacks/expect.pdf +0 -169
- data/test/features/report_callbacks/template.tlf +0 -147
- data/test/features/report_callbacks/test_report_callbacks.rb +0 -18
- data/test/features/text_align/expect.pdf +0 -0
- data/test/features/text_align/template.tlf +0 -241
- data/test/features/text_align/test_text_align.rb +0 -12
- data/test/features/text_block_overflow/expect.pdf +0 -0
- data/test/features/text_block_overflow/template.tlf +0 -538
- data/test/features/text_block_overflow/test_text_block_overflow.rb +0 -25
- data/test/features/text_block_singleline/expect.pdf +0 -0
- data/test/features/text_block_singleline/template.tlf +0 -170
- data/test/features/text_block_singleline/test_text_block_singleline.rb +0 -15
- data/test/features/text_block_style/expect.pdf +0 -1391
- data/test/features/text_block_style/templates/basic_styles.tlf +0 -889
- data/test/features/text_block_style/templates/font_size.tlf +0 -383
- data/test/features/text_block_style/test_text_block_style.rb +0 -47
- data/test/features/text_character_spacing/expect.pdf +0 -0
- data/test/features/text_character_spacing/template.tlf +0 -293
- data/test/features/text_character_spacing/test_text_character_spacing.rb +0 -12
- data/test/features/text_word_wrap/expect.pdf +0 -0
- data/test/features/text_word_wrap/template.tlf +0 -297
- data/test/features/text_word_wrap/test_text_word_wrap.rb +0 -30
- data/test/schema_helper.rb +0 -122
- data/test/test_helper.rb +0 -39
- data/test/units/core/format/test_base.rb +0 -152
- data/test/units/core/shape/base/test_internal.rb +0 -87
- data/test/units/core/shape/basic/test_block_format.rb +0 -23
- data/test/units/core/shape/basic/test_block_interface.rb +0 -29
- data/test/units/core/shape/basic/test_block_internal.rb +0 -55
- data/test/units/core/shape/basic/test_format.rb +0 -37
- data/test/units/core/shape/basic/test_interface.rb +0 -108
- data/test/units/core/shape/basic/test_internal.rb +0 -55
- data/test/units/core/shape/image_block/test_interface.rb +0 -24
- data/test/units/core/shape/image_block/test_internal.rb +0 -31
- data/test/units/core/shape/list/test_format.rb +0 -111
- data/test/units/core/shape/list/test_manager.rb +0 -67
- data/test/units/core/shape/list/test_page.rb +0 -156
- data/test/units/core/shape/list/test_page_state.rb +0 -31
- data/test/units/core/shape/list/test_section_format.rb +0 -36
- data/test/units/core/shape/list/test_section_interface.rb +0 -75
- data/test/units/core/shape/list/test_section_internal.rb +0 -50
- data/test/units/core/shape/manager/test_format.rb +0 -38
- data/test/units/core/shape/manager/test_internal.rb +0 -132
- data/test/units/core/shape/manager/test_target.rb +0 -140
- data/test/units/core/shape/page_number/test_format.rb +0 -55
- data/test/units/core/shape/page_number/test_interface.rb +0 -33
- data/test/units/core/shape/page_number/test_internal.rb +0 -81
- data/test/units/core/shape/styles/test_base.rb +0 -191
- data/test/units/core/shape/styles/test_basic.rb +0 -24
- data/test/units/core/shape/styles/test_graphic.rb +0 -50
- data/test/units/core/shape/styles/test_text.rb +0 -97
- data/test/units/core/shape/text/test_format.rb +0 -44
- data/test/units/core/shape/text/test_internal.rb +0 -20
- data/test/units/core/shape/text_block/formatter/test_basic.rb +0 -24
- data/test/units/core/shape/text_block/formatter/test_datetime.rb +0 -49
- data/test/units/core/shape/text_block/formatter/test_number.rb +0 -76
- data/test/units/core/shape/text_block/formatter/test_padding.rb +0 -77
- data/test/units/core/shape/text_block/test_format.rb +0 -169
- data/test/units/core/shape/text_block/test_formatter.rb +0 -28
- data/test/units/core/shape/text_block/test_interface.rb +0 -63
- data/test/units/core/shape/text_block/test_internal.rb +0 -128
- data/test/units/core/test_shape.rb +0 -52
- data/test/units/core/test_utils.rb +0 -68
- data/test/units/generator/pdf/document/graphics/test_attributes.rb +0 -135
- data/test/units/generator/pdf/document/graphics/test_basic.rb +0 -46
- data/test/units/generator/pdf/document/graphics/test_image.rb +0 -46
- data/test/units/generator/pdf/document/graphics/test_text.rb +0 -171
- data/test/units/generator/pdf/document/test_font.rb +0 -110
- data/test/units/generator/pdf/document/test_graphics.rb +0 -42
- data/test/units/generator/pdf/document/test_page.rb +0 -122
- data/test/units/generator/pdf/document/test_parse_color.rb +0 -30
- data/test/units/generator/pdf/prawn_ext/test_calc_image_dimensions.rb +0 -41
- data/test/units/generator/pdf/prawn_ext/test_width_of.rb +0 -22
- data/test/units/generator/pdf/test_document.rb +0 -22
- data/test/units/generator/test_pdf.rb +0 -26
- data/test/units/layout/test_base.rb +0 -41
- data/test/units/layout/test_format.rb +0 -100
- data/test/units/layout/test_legacy_schema.rb +0 -576
- data/test/units/layout/test_version.rb +0 -26
- data/test/units/report/test_base.rb +0 -248
- data/test/units/report/test_internal.rb +0 -206
- data/test/units/test_config.rb +0 -36
- data/test/units/test_layout.rb +0 -12
- data/test/units/test_report.rb +0 -18
@@ -1,28 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::TextBlock::TestFormatter < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
# Alias
|
9
|
-
Formatter = Thinreports::Core::Shape::TextBlock::Formatter
|
10
|
-
|
11
|
-
def test_initialize_formatter_by_type
|
12
|
-
assert_instance_of Formatter::Basic,
|
13
|
-
Formatter.setup( stub(format_type: '') )
|
14
|
-
|
15
|
-
assert_instance_of Formatter::Number,
|
16
|
-
Formatter.setup( stub(format_type: 'number') )
|
17
|
-
|
18
|
-
assert_instance_of Formatter::Datetime,
|
19
|
-
Formatter.setup( stub(format_type: 'datetime') )
|
20
|
-
|
21
|
-
assert_instance_of Formatter::Padding,
|
22
|
-
Formatter.setup( stub(format_type: 'padding') )
|
23
|
-
|
24
|
-
assert_raises Thinreports::Errors::UnknownFormatterType do
|
25
|
-
Formatter.setup( stub(format_type: 'unknown') )
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::TextBlock::TestInterface < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
# Alias
|
9
|
-
TextBlock = Thinreports::Core::Shape::TextBlock
|
10
|
-
|
11
|
-
def create_interface(format_config = {})
|
12
|
-
report = Thinreports::Report.new layout: layout_file.path
|
13
|
-
parent = report.start_new_page
|
14
|
-
|
15
|
-
TextBlock::Interface.new parent, TextBlock::Format.new(format_config)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_format_enabled_asker_should_operate_as_delegator_of_internal
|
19
|
-
tblock = create_interface('format' => {'type' => 'datetime'})
|
20
|
-
assert_equal tblock.format_enabled?, tblock.internal.format_enabled?
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_format_enabled_should_properly_set_value_to_internal
|
24
|
-
tblock = create_interface('format' => {'type' => 'number'})
|
25
|
-
tblock.format_enabled(false)
|
26
|
-
|
27
|
-
assert_equal tblock.internal.format_enabled?, false
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_set_should_properly_set_a_value
|
31
|
-
tblock = create_interface
|
32
|
-
tblock.set(1000, visible: false)
|
33
|
-
|
34
|
-
assert_equal tblock.value, 1000
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_set_should_properly_set_styles
|
38
|
-
tblock = create_interface
|
39
|
-
tblock.set(1000, color: '#ff0000',
|
40
|
-
bold: true,
|
41
|
-
italic: true)
|
42
|
-
|
43
|
-
assert_equal [tblock.style(:color),
|
44
|
-
tblock.style(:bold),
|
45
|
-
tblock.style(:italic)],
|
46
|
-
['#ff0000', true, true]
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_value=
|
50
|
-
report = Thinreports::Report.new layout: layout_file.path
|
51
|
-
page = report.start_new_page
|
52
|
-
|
53
|
-
page.item(:text_block).value = 'foo'
|
54
|
-
assert_equal 'foo', page.item(:text_block).value
|
55
|
-
|
56
|
-
page.item(:text_block).value += 'bar'
|
57
|
-
assert_equal 'foobar', page.item(:text_block).value
|
58
|
-
|
59
|
-
page.item(:text_block).value = 1000
|
60
|
-
page.item(:text_block).value += 999
|
61
|
-
assert_equal 1999, page.item(:text_block).value
|
62
|
-
end
|
63
|
-
end
|
@@ -1,128 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::TextBlock::TestInternal < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
# Alias
|
9
|
-
TextBlock = Thinreports::Core::Shape::TextBlock
|
10
|
-
|
11
|
-
def create_parent
|
12
|
-
report = Thinreports::Report.new layout: layout_file.path
|
13
|
-
report.start_new_page do |page|
|
14
|
-
# Add to force TextBlock shape.
|
15
|
-
page.manager.format.shapes[:foo] = TextBlock::Format.new('type' => 'text-block',
|
16
|
-
'id' => 'foo')
|
17
|
-
# Set value to TextBlock.
|
18
|
-
page.item(:foo).value('foo value')
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def create_internal(format_config = {})
|
23
|
-
TextBlock::Internal.new(create_parent, TextBlock::Format.new(format_config))
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_multiple_asker_should_operate_as_delegator_of_format
|
27
|
-
tblock = create_internal('multiple-line' => true)
|
28
|
-
assert_equal tblock.multiple?, tblock.format.multiple?
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_style_should_return_the_instance_of_Style_Text
|
32
|
-
assert_instance_of Thinreports::Core::Shape::Style::Text, create_internal.style
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_read_value_should_return_the_format_value_as_default
|
36
|
-
tblock = create_internal('value' => 'default value')
|
37
|
-
assert_equal tblock.read_value, 'default value'
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_read_value_should_return_the_value_of_referenced_shape
|
41
|
-
tblock = create_internal('reference-id' => 'foo', 'value' => '')
|
42
|
-
assert_equal tblock.read_value, 'foo value'
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_read_value_should_return_the_value_stored_in_states
|
46
|
-
tblock = create_internal
|
47
|
-
tblock.states[:value] = 'value in states'
|
48
|
-
|
49
|
-
assert_equal tblock.read_value, 'value in states'
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_write_value_should_properly_set_the_specified_value_to_states
|
53
|
-
tblock = create_internal
|
54
|
-
tblock.write_value(1000)
|
55
|
-
|
56
|
-
assert_equal tblock.states[:value], 1000
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_write_value_should_show_warnings_when_tblock_has_reference
|
60
|
-
tblock = create_internal('id' => 'bar', 'reference-id' => 'foo')
|
61
|
-
_out, err = capture_io do
|
62
|
-
tblock.write_value('value')
|
63
|
-
end
|
64
|
-
assert_equal err.chomp, 'The set value was not saved, ' +
|
65
|
-
"Because 'bar' has reference to 'foo'."
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_real_value_should_return_the_formatted_value_when_tblock_has_any_format
|
69
|
-
tblock = create_internal('format' => {'type' => 'datetime',
|
70
|
-
'datetime' => {'format' => '%Y/%m/%d'}})
|
71
|
-
tblock.write_value(value = Time.now)
|
72
|
-
|
73
|
-
assert_equal tblock.real_value, value.strftime('%Y/%m/%d')
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_real_value_should_return_the_raw_value_when_tblock_has_no_format
|
77
|
-
tblock = create_internal
|
78
|
-
tblock.write_value('any value')
|
79
|
-
|
80
|
-
assert_equal tblock.real_value, 'any value'
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_format_enabled_should_properly_set_value_to_states_as_format_enabled
|
84
|
-
tblock = create_internal
|
85
|
-
tblock.format_enabled(false)
|
86
|
-
|
87
|
-
assert_equal tblock.states[:format_enabled], false
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_format_enabled_asker_should_return_true_when_format_has_any_type
|
91
|
-
tblock = create_internal('format' => {'type' => 'datetime'})
|
92
|
-
|
93
|
-
assert_equal tblock.format_enabled?, true
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_format_enabled_asker_should_return_true_when_base_of_format_has_any_value
|
97
|
-
tblock = create_internal('format' => {'base' => '{value}'})
|
98
|
-
|
99
|
-
assert_equal tblock.format_enabled?, true
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_format_enabled_asker_should_return_false_when_format_has_no_type_and_base_has_not_value
|
103
|
-
assert_equal create_internal.format_enabled?, false
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_format_enabled_asker_should_return_false_constantly_when_tblock_is_multiple_mode
|
107
|
-
tblock = create_internal('multiple-line' => true,
|
108
|
-
'format' => {'base' => '{value}',
|
109
|
-
'type' => 'number'})
|
110
|
-
tblock.format_enabled(true)
|
111
|
-
|
112
|
-
assert_equal tblock.format_enabled?, false
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_type_of_asker_should_return_true_when_value_is_tblock
|
116
|
-
assert_equal create_internal.type_of?('text-block'), true
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_type_of_asker_should_return_true_when_value_is_block
|
120
|
-
assert_equal create_internal.type_of?(:block), true
|
121
|
-
end
|
122
|
-
|
123
|
-
def test_formatter_should_return_instance_of_FormatterBasic_when_format_is_enable
|
124
|
-
tblock = create_internal('format' => {'type' => 'datetime'})
|
125
|
-
|
126
|
-
assert_kind_of TextBlock::Formatter::Basic, tblock.send(:formatter)
|
127
|
-
end
|
128
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::TestShape < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
# Alias
|
9
|
-
ShapeModule = Thinreports::Core::Shape
|
10
|
-
|
11
|
-
def test_find_by_type_should_return_PageNumber
|
12
|
-
assert_same ShapeModule.find_by_type('page-number'), ShapeModule::PageNumber
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_find_by_type_should_return_ImageBlock
|
16
|
-
assert_same ShapeModule.find_by_type('image-block'), ShapeModule::ImageBlock
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_find_by_type_should_return_TextBlock
|
20
|
-
assert_same ShapeModule.find_by_type('text-block'), ShapeModule::TextBlock
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_find_by_type_should_return_List
|
24
|
-
assert_same ShapeModule.find_by_type('list'), ShapeModule::List
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_find_by_type_should_return_Text
|
28
|
-
assert_same ShapeModule.find_by_type('text'), ShapeModule::Text
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_find_by_type_should_return_Basic_as_Image
|
32
|
-
assert_same ShapeModule.find_by_type('image'), ShapeModule::Basic
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_find_by_type_should_return_Basic_as_Line
|
36
|
-
assert_same ShapeModule.find_by_type('line'), ShapeModule::Basic
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_find_by_type_should_return_Basic_as_Rect
|
40
|
-
assert_same ShapeModule.find_by_type('rect'), ShapeModule::Basic
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_find_by_type_should_return_Basic_as_Ellipse
|
44
|
-
assert_same ShapeModule.find_by_type('ellipse'), ShapeModule::Basic
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_find_by_type_should_raise
|
48
|
-
assert_raises Thinreports::Errors::UnknownShapeType do
|
49
|
-
ShapeModule.find_by_type('unknown')
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
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 [1, 2, 3], call_block_in([2, 1, 3], &proc { sort! })
|
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,135 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Generator::PDF::Graphics::TestAttributes < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@pdf = Thinreports::Generator::PDF::Document.new
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_build_graphic_attributes
|
13
|
-
graphic_styles = {
|
14
|
-
'border-color' => '#ff0000',
|
15
|
-
'border-width' => 2.0,
|
16
|
-
'border-style' => 'solid',
|
17
|
-
'fill-color' => '#000000'
|
18
|
-
}
|
19
|
-
|
20
|
-
assert_equal(
|
21
|
-
{
|
22
|
-
stroke: '#ff0000',
|
23
|
-
stroke_width: 2.0,
|
24
|
-
stroke_type: 'solid',
|
25
|
-
fill: '#000000'
|
26
|
-
},
|
27
|
-
@pdf.build_graphic_attributes(graphic_styles)
|
28
|
-
)
|
29
|
-
|
30
|
-
customized_attributes = @pdf.build_graphic_attributes(graphic_styles) { |attrs| attrs[:stroke] = 'blue' }
|
31
|
-
assert_equal 'blue', customized_attributes[:stroke]
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_build_text_attributes
|
35
|
-
text_styles = {
|
36
|
-
'font-family' => %w( Helvetica IPAMincho ),
|
37
|
-
'font-size' => 18.0,
|
38
|
-
'color' => 'red',
|
39
|
-
'text-align' => 'right',
|
40
|
-
'vertical-align' => 'bottom',
|
41
|
-
'font-style' => %w( bold italic ),
|
42
|
-
'letter-spacing' => 2.0,
|
43
|
-
'line-height' => 20.0,
|
44
|
-
'overflow' => 'expand',
|
45
|
-
'word-wrap' => 'break-word'
|
46
|
-
}
|
47
|
-
|
48
|
-
assert_equal(
|
49
|
-
{
|
50
|
-
font: 'Helvetica',
|
51
|
-
size: 18.0,
|
52
|
-
color: 'red',
|
53
|
-
align: :right,
|
54
|
-
valign: :bottom,
|
55
|
-
styles: [:bold, :italic],
|
56
|
-
letter_spacing: 2.0,
|
57
|
-
line_height: 20.0,
|
58
|
-
overflow: :expand,
|
59
|
-
word_wrap: :break_word
|
60
|
-
},
|
61
|
-
@pdf.build_text_attributes(text_styles)
|
62
|
-
)
|
63
|
-
|
64
|
-
customized_attributes = @pdf.build_text_attributes(text_styles) { |attrs| attrs[:color] = 'blue' }
|
65
|
-
assert_equal 'blue', customized_attributes[:color]
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_font_family
|
69
|
-
assert_equal 'IPAGothic', @pdf.font_family(%w( IPAGothic Helvetica ))
|
70
|
-
assert_equal 'Helvetica', @pdf.font_family(%w( Unknown IPAMincho ))
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_font_styles
|
74
|
-
assert_equal [:bold, :italic, :underline, :strikethrough],
|
75
|
-
@pdf.font_styles(%w( bold italic underline linethrough ))
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_letter_spacing
|
79
|
-
assert_equal 2.0, @pdf.letter_spacing(2.0)
|
80
|
-
assert_nil @pdf.letter_spacing('')
|
81
|
-
assert_nil @pdf.letter_spacing(nil)
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_text_align
|
85
|
-
assert_equal :left, @pdf.text_align('left')
|
86
|
-
assert_equal :center, @pdf.text_align('center')
|
87
|
-
assert_equal :right, @pdf.text_align('right')
|
88
|
-
assert_equal :left, @pdf.text_align('')
|
89
|
-
assert_equal :left, @pdf.text_align(nil)
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_text_valign
|
93
|
-
assert_equal :top, @pdf.text_valign('top')
|
94
|
-
assert_equal :center, @pdf.text_valign('middle')
|
95
|
-
assert_equal :bottom, @pdf.text_valign('bottom')
|
96
|
-
assert_equal :top, @pdf.text_valign('')
|
97
|
-
assert_equal :top, @pdf.text_valign(nil)
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_text_overflow
|
101
|
-
assert_equal :truncate, @pdf.text_overflow('truncate')
|
102
|
-
assert_equal :shrink_to_fit, @pdf.text_overflow('fit')
|
103
|
-
assert_equal :expand, @pdf.text_overflow('expand')
|
104
|
-
assert_equal :truncate, @pdf.text_overflow('')
|
105
|
-
assert_equal :truncate, @pdf.text_overflow(nil)
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_word_wrap
|
109
|
-
assert_equal :break_word, @pdf.word_wrap('break-word')
|
110
|
-
assert_equal :none, @pdf.word_wrap('none')
|
111
|
-
assert_equal :none, @pdf.word_wrap(nil)
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_line_height
|
115
|
-
assert_equal 20.9, @pdf.line_height(20.9)
|
116
|
-
assert_nil @pdf.line_height('')
|
117
|
-
assert_nil @pdf.line_height(nil)
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_image_position_x
|
121
|
-
assert_equal :left, @pdf.image_position_x('left')
|
122
|
-
assert_equal :center, @pdf.image_position_x('center')
|
123
|
-
assert_equal :right, @pdf.image_position_x('right')
|
124
|
-
assert_equal :left, @pdf.image_position_x('')
|
125
|
-
assert_equal :left, @pdf.image_position_x(nil)
|
126
|
-
end
|
127
|
-
|
128
|
-
def test_image_position_y
|
129
|
-
assert_equal :top, @pdf.image_position_y('top')
|
130
|
-
assert_equal :center, @pdf.image_position_y('middle')
|
131
|
-
assert_equal :bottom, @pdf.image_position_y('bottom')
|
132
|
-
assert_equal :top, @pdf.image_position_y('')
|
133
|
-
assert_equal :top, @pdf.image_position_y(nil)
|
134
|
-
end
|
135
|
-
end
|