thinreports 0.10.3 → 0.11.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/.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,55 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'test_helper'
|
|
4
|
-
|
|
5
|
-
class Thinreports::Core::Shape::PageNumber::TestFormat < Minitest::Test
|
|
6
|
-
include Thinreports::TestHelper
|
|
7
|
-
|
|
8
|
-
PAGE_NUMBER_FORMAT = {
|
|
9
|
-
'id' => '',
|
|
10
|
-
'type' => 'page-number',
|
|
11
|
-
'display' => true,
|
|
12
|
-
'x' => 100.0,
|
|
13
|
-
'y' => 200.0,
|
|
14
|
-
'width' => 300.0,
|
|
15
|
-
'height' => 400.0,
|
|
16
|
-
'format' => '{page} / {total}',
|
|
17
|
-
'target' => '',
|
|
18
|
-
'style' => {
|
|
19
|
-
'overflow' => 'truncate',
|
|
20
|
-
'letter-spacing' => 'normal',
|
|
21
|
-
'color' => '#000000',
|
|
22
|
-
'font-size' => 18,
|
|
23
|
-
'font-family' => ['Helvetica'],
|
|
24
|
-
'line-height' => 60,
|
|
25
|
-
'line-height-ratio' => 1.5,
|
|
26
|
-
'text-align' => 'left'
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
PageNumber = Thinreports::Core::Shape::PageNumber
|
|
31
|
-
|
|
32
|
-
def test_attribute_readers
|
|
33
|
-
format = PageNumber::Format.new(PAGE_NUMBER_FORMAT)
|
|
34
|
-
|
|
35
|
-
assert_equal 'truncate', format.overflow
|
|
36
|
-
assert_equal '', format.target
|
|
37
|
-
assert_equal '{page} / {total}', format.default_format
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def test_id
|
|
41
|
-
format = PageNumber::Format.new(PAGE_NUMBER_FORMAT)
|
|
42
|
-
assert_match(/^__pageno\d+$/, format.id)
|
|
43
|
-
|
|
44
|
-
format = PageNumber::Format.new(PAGE_NUMBER_FORMAT.merge('id' => 'foo'))
|
|
45
|
-
assert_equal 'foo', format.id
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def test_for_report?
|
|
49
|
-
format_for_report = PageNumber::Format.new(PAGE_NUMBER_FORMAT)
|
|
50
|
-
assert_equal true, format_for_report.for_report?
|
|
51
|
-
|
|
52
|
-
format_for_list = PageNumber::Format.new(PAGE_NUMBER_FORMAT.merge('target' => 'target_list_id'))
|
|
53
|
-
assert_equal false, format_for_list.for_report?
|
|
54
|
-
end
|
|
55
|
-
end
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'test_helper'
|
|
4
|
-
|
|
5
|
-
class Thinreports::Core::Shape::PageNumber::TestInterface < Minitest::Test
|
|
6
|
-
include Thinreports::TestHelper
|
|
7
|
-
|
|
8
|
-
PageNumber = Thinreports::Core::Shape::PageNumber
|
|
9
|
-
|
|
10
|
-
def create_pageno(format = {})
|
|
11
|
-
report = Thinreports::Report.new layout: layout_file.path
|
|
12
|
-
parent = report.start_new_page
|
|
13
|
-
|
|
14
|
-
PageNumber::Interface.new parent, PageNumber::Format.new(format)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def test_format
|
|
18
|
-
pageno = create_pageno 'format' => '{page}'
|
|
19
|
-
|
|
20
|
-
assert_equal pageno.format, '{page}'
|
|
21
|
-
pageno.format('{page} / {total}')
|
|
22
|
-
assert_equal pageno.format, '{page} / {total}'
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def test_reset_format
|
|
26
|
-
pageno = create_pageno 'format' => '{page}'
|
|
27
|
-
|
|
28
|
-
pageno.format('-- {page} --')
|
|
29
|
-
pageno.reset_format
|
|
30
|
-
|
|
31
|
-
assert_equal pageno.format, '{page}'
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'test_helper'
|
|
4
|
-
|
|
5
|
-
class Thinreports::Core::Shape::PageNumber::TestInternal < Minitest::Test
|
|
6
|
-
include Thinreports::TestHelper
|
|
7
|
-
|
|
8
|
-
PageNumber = Thinreports::Core::Shape::PageNumber
|
|
9
|
-
|
|
10
|
-
def setup
|
|
11
|
-
@report = Thinreports::Report.new layout: layout_file.path
|
|
12
|
-
@report.start_new_page
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def init_pageno(format = {})
|
|
16
|
-
PageNumber::Internal.new(@report.page, PageNumber::Format.new(format))
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_read_format
|
|
20
|
-
pageno = init_pageno('format' => 'Page {page}')
|
|
21
|
-
|
|
22
|
-
assert_equal pageno.read_format, 'Page {page}'
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def test_write_format
|
|
26
|
-
pageno = init_pageno('format' => 'Page {page}')
|
|
27
|
-
pageno.write_format('{page}')
|
|
28
|
-
|
|
29
|
-
assert_equal pageno.read_format, '{page}'
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def test_reset_format
|
|
33
|
-
pageno = init_pageno('format' => '{page}')
|
|
34
|
-
pageno.write_format('Page {page}')
|
|
35
|
-
pageno.reset_format
|
|
36
|
-
|
|
37
|
-
assert_equal pageno.read_format, '{page}'
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def test_build_format
|
|
41
|
-
pageno = init_pageno('format' => '{page} / {total}')
|
|
42
|
-
assert_equal pageno.build_format(1, 100), '1 / 100'
|
|
43
|
-
|
|
44
|
-
pageno.write_format('{page}')
|
|
45
|
-
assert_equal pageno.build_format(1, 100), '1'
|
|
46
|
-
|
|
47
|
-
@report.start_page_number_from 5
|
|
48
|
-
pageno = init_pageno('format' => '{page} / {total}')
|
|
49
|
-
assert_equal pageno.build_format(1, 100), '5 / 104'
|
|
50
|
-
|
|
51
|
-
# if counted target is a List shape
|
|
52
|
-
pageno = init_pageno('format' => '{page} / {total}',
|
|
53
|
-
'target' => 'list-id')
|
|
54
|
-
assert_equal pageno.build_format(1, 100), '1 / 100'
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def test_type_of
|
|
58
|
-
pageno = init_pageno
|
|
59
|
-
assert pageno.type_of?('page-number')
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def test_style
|
|
63
|
-
pageno = init_pageno
|
|
64
|
-
style = pageno.style
|
|
65
|
-
|
|
66
|
-
assert_instance_of PageNumber::Style, style
|
|
67
|
-
assert_same pageno.style, style
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def test_for_report
|
|
71
|
-
pageno = init_pageno('target' => '')
|
|
72
|
-
assert_equal pageno.for_report?, true
|
|
73
|
-
|
|
74
|
-
pageno = init_pageno('target' => 'list-id')
|
|
75
|
-
assert_equal pageno.for_report?, false
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def test_Style_class
|
|
79
|
-
refute_includes PageNumber::Style.accessible_styles, :valign
|
|
80
|
-
end
|
|
81
|
-
end
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'test_helper'
|
|
4
|
-
|
|
5
|
-
class Thinreports::Core::Shape::Style::TestBase < Minitest::Test
|
|
6
|
-
include Thinreports::TestHelper
|
|
7
|
-
|
|
8
|
-
# Alias
|
|
9
|
-
Style = Thinreports::Core::Shape::Style::Base
|
|
10
|
-
|
|
11
|
-
def create_basic_format(base_style = {})
|
|
12
|
-
Thinreports::Core::Shape::Basic::Format.new('style' => base_style)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def create_style(base_style = {})
|
|
16
|
-
Style.new(create_basic_format(base_style))
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def create_new_style(base_style = {}, &block)
|
|
20
|
-
klass = ::Class.new(Style, &block)
|
|
21
|
-
klass.new(create_basic_format(base_style))
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def test_self_style_reader_should_properly_define_a_reading_method
|
|
25
|
-
style = create_new_style {
|
|
26
|
-
style_reader :hoge, 'foo'
|
|
27
|
-
}
|
|
28
|
-
assert_respond_to style, :hoge
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def test_self_style_writer_should_properly_define_a_writing_method
|
|
32
|
-
style = create_new_style {
|
|
33
|
-
style_writer :hoge, 'foo'
|
|
34
|
-
}
|
|
35
|
-
assert_respond_to style, :hoge=
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def test_self_style_accessor_should_properly_defines_reading_and_writing_methods
|
|
39
|
-
style = create_new_style {
|
|
40
|
-
style_accessor :hoge, 'foo'
|
|
41
|
-
}
|
|
42
|
-
assert_respond_to style, :hoge
|
|
43
|
-
assert_respond_to style, :hoge=
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def test_self_style_accessible_should_add_specified_styles_to_the_accessible_styles_variable
|
|
47
|
-
style = create_new_style {
|
|
48
|
-
style_accessible :hoge
|
|
49
|
-
style_accessible :foo, :bar
|
|
50
|
-
}
|
|
51
|
-
assert_equal style.class.accessible_styles, [:hoge, :foo, :bar]
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def test_self_accessible_styles_variable_should_not_be_shared_each_SubClasses
|
|
55
|
-
style1 = create_new_style {
|
|
56
|
-
style_accessible :hoge, :foo
|
|
57
|
-
}
|
|
58
|
-
assert_equal style1.class.accessible_styles, [:hoge, :foo]
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def test_self_accessible_styles_variable_should_be_inherited_to_SubClass
|
|
62
|
-
super_klass = ::Class.new(Style) {
|
|
63
|
-
style_accessible :hoge, :foo
|
|
64
|
-
}
|
|
65
|
-
sub_klass = ::Class.new(super_klass)
|
|
66
|
-
|
|
67
|
-
assert_equal sub_klass.accessible_styles, super_klass.accessible_styles
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def test_self_accessible_styles_variables_of_SubClass_should_not_interfere_mutually
|
|
71
|
-
super_klass = ::Class.new(Style) {
|
|
72
|
-
style_accessible :foo, :bar
|
|
73
|
-
}
|
|
74
|
-
sub_klass1 = ::Class.new(super_klass)
|
|
75
|
-
sub_klass2 = ::Class.new(super_klass)
|
|
76
|
-
|
|
77
|
-
refute_same sub_klass1.accessible_styles, sub_klass2.accessible_styles
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
def test_read_internal_style_should_return_style_of_styles_when_style_is_found_in_styles
|
|
81
|
-
style = create_style('hoge' => 'base_style')
|
|
82
|
-
style.write_internal_style('hoge', 'new_style')
|
|
83
|
-
|
|
84
|
-
assert_equal style.read_internal_style('hoge'), 'new_style'
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def test_read_internal_style_should_return_style_of_base_when_style_is_not_found_in_styles
|
|
88
|
-
style = create_style('hoge' => 'base_style')
|
|
89
|
-
assert_equal style.read_internal_style('hoge'), 'base_style'
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
def test_write_internal_style_should_properly_set_style_to_the_styles
|
|
93
|
-
style = create_style({})
|
|
94
|
-
style.write_internal_style('hoge', 'hoge_style')
|
|
95
|
-
|
|
96
|
-
assert_equal style.styles['hoge'], 'hoge_style'
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def test_has_style_asker_should_return_true_when_specified_style_method_is_accessible
|
|
100
|
-
style = create_new_style {
|
|
101
|
-
style_accessible :hoge, :foo
|
|
102
|
-
}
|
|
103
|
-
assert_equal style.has_style?(:foo), true
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def test_has_style_asker_should_return_false_when_specified_style_method_is_not_accessible
|
|
107
|
-
style = create_new_style {
|
|
108
|
-
style_accessible :foo
|
|
109
|
-
}
|
|
110
|
-
assert_equal style.has_style?(:hoge), false
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def test_verify_style_value_should_raise_when_value_is_not_included_in_list
|
|
114
|
-
assert_raises ArgumentError do
|
|
115
|
-
create_style.send(:verify_style_value, :invalid, [:hoge, :foo, :bar])
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def test_verify_style_value_should_not_raise_when_value_is_found_in_list
|
|
120
|
-
create_style.send(:verify_style_value, :valid, [:hoge, :valid, :foo])
|
|
121
|
-
rescue ArgumentError
|
|
122
|
-
flunk
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
def test_reader_method_caller_should_properly_delegate_to_real_method
|
|
126
|
-
style = create_new_style('hoge_style' => 'hoge_style_value') {
|
|
127
|
-
style_accessible :hoge
|
|
128
|
-
style_reader :hoge, 'hoge_style'
|
|
129
|
-
}
|
|
130
|
-
assert_equal style[:hoge], 'hoge_style_value'
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def test_writer_method_caller_should_properly_delegate_to_real_method
|
|
134
|
-
style = create_new_style {
|
|
135
|
-
style_accessible :hoge
|
|
136
|
-
style_accessor :hoge, 'hoge_style'
|
|
137
|
-
}
|
|
138
|
-
style[:hoge] = 'hoge_style_value'
|
|
139
|
-
assert_equal style.hoge, 'hoge_style_value'
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
def test_reader_method_caller_should_raise_when_style_is_not_accessible
|
|
143
|
-
assert_raises Thinreports::Errors::UnknownShapeStyleName do
|
|
144
|
-
create_new_style[:unknown]
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
def test_writer_method_caller_should_raise_when_style_is_not_accessible
|
|
149
|
-
assert_raises Thinreports::Errors::UnknownShapeStyleName do
|
|
150
|
-
create_new_style[:unknown] = 'value'
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
def test_copy_should_return_the_instance_of_the_same_class_as_itself
|
|
155
|
-
style = create_style
|
|
156
|
-
assert_instance_of Style, style.copy
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
def test_styles_of_copied_style_should_not_same_the_styles_of_original
|
|
160
|
-
style = create_style
|
|
161
|
-
refute_same style.styles, style.copy.styles
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
def test_styles_of_copied_style_should_equal_the_style_of_original
|
|
165
|
-
style = create_style
|
|
166
|
-
style.write_internal_style('foo', 'foo_value')
|
|
167
|
-
assert_equal style.styles['foo'], style.copy.styles['foo']
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
def test_identifier_should_return_empty_string_when_the_style_is_not_set
|
|
171
|
-
style = create_style
|
|
172
|
-
assert_equal style.identifier, ''
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
def test_identifier_should_return_the_same_as_hash_value_of_styles_when_style_is_set_something
|
|
176
|
-
style = create_style
|
|
177
|
-
style.write_internal_style('foo', 'foo_value')
|
|
178
|
-
|
|
179
|
-
assert_equal style.identifier, style.styles.hash.to_s
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
def test_finalized_styles
|
|
183
|
-
base_styles = { 'foo' => 'default foo', 'bar' => 'default bar' }
|
|
184
|
-
|
|
185
|
-
style = create_style(base_styles)
|
|
186
|
-
style.write_internal_style('foo', 'new foo')
|
|
187
|
-
|
|
188
|
-
assert_equal({ 'foo' => 'new foo', 'bar' => 'default bar' }, style.finalized_styles)
|
|
189
|
-
assert_same style.finalized_styles, style.finalized_styles
|
|
190
|
-
end
|
|
191
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'test_helper'
|
|
4
|
-
|
|
5
|
-
class Thinreports::Core::Shape::Style::TestBasic < Minitest::Test
|
|
6
|
-
include Thinreports::TestHelper
|
|
7
|
-
|
|
8
|
-
def create_basic_style(format_config = {})
|
|
9
|
-
format = Thinreports::Core::Shape::Basic::Format.new(format_config)
|
|
10
|
-
Thinreports::Core::Shape::Style::Basic.new(format)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def test_visible_should_return_visibility_of_format_as_default
|
|
14
|
-
style = create_basic_style('display' => false)
|
|
15
|
-
assert_equal style.visible, false
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def test_visible_should_properly_set_visibility
|
|
19
|
-
style = create_basic_style('display' => false)
|
|
20
|
-
style.visible = true
|
|
21
|
-
|
|
22
|
-
assert_equal style.visible, true
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'test_helper'
|
|
4
|
-
|
|
5
|
-
class Thinreports::Core::Shape::Style::TestGraphic < Minitest::Test
|
|
6
|
-
include Thinreports::TestHelper
|
|
7
|
-
|
|
8
|
-
def test_border_color
|
|
9
|
-
style = create_graphic_style('border-color' => 'red')
|
|
10
|
-
assert_equal 'red', style.border_color
|
|
11
|
-
|
|
12
|
-
style.border_color = '#ff0000'
|
|
13
|
-
assert_equal '#ff0000', style.styles['border-color']
|
|
14
|
-
assert_equal '#ff0000', style.border_color
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def test_border_width
|
|
18
|
-
style = create_graphic_style('border-width' => 2.0)
|
|
19
|
-
assert_equal 2.0, style.border_width
|
|
20
|
-
|
|
21
|
-
style.border_width = 10.9
|
|
22
|
-
assert_equal 10.9, style.styles['border-width']
|
|
23
|
-
assert_equal 10.9, style.border_width
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def test_fill_color
|
|
27
|
-
style = create_graphic_style('fill-color' => '#0000ff')
|
|
28
|
-
assert_equal '#0000ff', style.fill_color
|
|
29
|
-
|
|
30
|
-
style.fill_color = 'blue'
|
|
31
|
-
assert_equal 'blue', style.styles['fill-color']
|
|
32
|
-
assert_equal 'blue', style.fill_color
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def test_border
|
|
36
|
-
style = create_graphic_style('border-color' => 'red', 'border-width' => 1)
|
|
37
|
-
assert_equal [1, 'red'], style.border
|
|
38
|
-
|
|
39
|
-
style.border = [2.0, '#ff0000']
|
|
40
|
-
assert_equal 2.0, style.styles['border-width']
|
|
41
|
-
assert_equal '#ff0000', style.styles['border-color']
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
private
|
|
45
|
-
|
|
46
|
-
def create_graphic_style(default_style = {})
|
|
47
|
-
format = Thinreports::Core::Shape::Basic::Format.new('style' => default_style)
|
|
48
|
-
Thinreports::Core::Shape::Style::Graphic.new(format)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'test_helper'
|
|
4
|
-
|
|
5
|
-
class Thinreports::Core::Shape::Style::TestText < Minitest::Test
|
|
6
|
-
include Thinreports::TestHelper
|
|
7
|
-
|
|
8
|
-
def test_color
|
|
9
|
-
style = create_text_style('color' => 'red')
|
|
10
|
-
assert_equal 'red', style.color
|
|
11
|
-
|
|
12
|
-
style.color = 'blue'
|
|
13
|
-
assert_equal 'blue', style.styles['color']
|
|
14
|
-
assert_equal 'blue', style.color
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def test_font_size
|
|
18
|
-
style = create_text_style('font-size' => 18.0)
|
|
19
|
-
assert_equal 18.0, style.font_size
|
|
20
|
-
|
|
21
|
-
style.font_size = 19
|
|
22
|
-
assert_equal 19, style.styles['font-size']
|
|
23
|
-
assert_equal 19, style.font_size
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def test_initialize_font_style
|
|
27
|
-
default_font_style = ['bold', 'italic']
|
|
28
|
-
style = create_text_style('font-style' => default_font_style)
|
|
29
|
-
|
|
30
|
-
refute_same default_font_style, style.styles['font-style']
|
|
31
|
-
assert_equal default_font_style, style.styles['font-style']
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def test_bold
|
|
35
|
-
style = create_text_style('font-style' => ['bold'])
|
|
36
|
-
assert_equal true, style.bold
|
|
37
|
-
|
|
38
|
-
style.bold = false
|
|
39
|
-
assert_equal [], style.styles['font-style']
|
|
40
|
-
assert_equal false, style.bold
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def test_italic
|
|
44
|
-
style = create_text_style('font-style' => ['italic'])
|
|
45
|
-
assert_equal true, style.italic
|
|
46
|
-
|
|
47
|
-
style.italic = false
|
|
48
|
-
assert_equal [], style.styles['font-style']
|
|
49
|
-
assert_equal false, style.italic
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def test_underline
|
|
53
|
-
style = create_text_style('font-style' => ['underline'])
|
|
54
|
-
assert_equal true, style.underline
|
|
55
|
-
|
|
56
|
-
style.underline = false
|
|
57
|
-
assert_equal [], style.styles['font-style']
|
|
58
|
-
assert_equal false, style.underline
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def test_linethrough
|
|
62
|
-
style = create_text_style('font-style' => ['linethrough'])
|
|
63
|
-
assert_equal true, style.linethrough
|
|
64
|
-
|
|
65
|
-
style.linethrough = false
|
|
66
|
-
assert_equal [], style.styles['font-style']
|
|
67
|
-
assert_equal false, style.linethrough
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def test_align
|
|
71
|
-
style = create_text_style('text-align' => 'center')
|
|
72
|
-
assert_equal :center, style.align
|
|
73
|
-
|
|
74
|
-
style.align = :right
|
|
75
|
-
assert_equal 'right', style.styles['text-align']
|
|
76
|
-
assert_equal :right, style.align
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def test_valign
|
|
80
|
-
style = create_text_style('vertical-align' => '')
|
|
81
|
-
assert_equal :top, style.valign
|
|
82
|
-
|
|
83
|
-
style.valign = :middle
|
|
84
|
-
assert_equal 'middle', style.styles['vertical-align']
|
|
85
|
-
assert_equal :middle, style.valign
|
|
86
|
-
|
|
87
|
-
assert_deprecated { style.valign = :center }
|
|
88
|
-
assert_equal :middle, style.valign
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
private
|
|
92
|
-
|
|
93
|
-
def create_text_style(default_style = {})
|
|
94
|
-
format = Thinreports::Core::Shape::Text::Format.new('style' => default_style)
|
|
95
|
-
Thinreports::Core::Shape::Style::Text.new(format)
|
|
96
|
-
end
|
|
97
|
-
end
|