thinreports 0.8.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CONTRIBUTING.md +2 -0
- data/.travis.yml +3 -3
- data/CHANGELOG.md +98 -1
- data/README.md +0 -9
- data/Rakefile +1 -2
- data/examples/character_spacing/character_spacing.tlf +293 -1
- data/examples/dynamic_image/dynamic_image.tlf +661 -1
- data/examples/dynamic_style/dynamic_style.rb +4 -4
- data/examples/dynamic_style/dynamic_style.tlf +1835 -1
- data/examples/dynamic_style/dynamic_style_in_list.tlf +344 -1
- data/examples/eudc/eudc.tlf +180 -1
- data/examples/hidden_shapes/hidden_shapes.tlf +449 -1
- data/examples/list_events/list_events.rb +1 -28
- data/examples/list_events/list_events.tlf +361 -0
- data/examples/list_manual_generation/list_manual_generation.tlf +132 -1
- data/examples/list_page_number/list_page_number.tlf +254 -1
- data/examples/page_number/page_number.tlf +215 -1
- data/examples/palleted_png/palleted_png.rb +2 -0
- data/examples/palleted_png/palleted_png.tlf +47 -1
- data/examples/password_setting/password_setting.tlf +45 -1
- data/examples/report_callbacks/report_callbacks.rb +1 -18
- data/examples/report_callbacks/report_callbacks.tlf +147 -1
- data/examples/single_line_tblock/single_line_tblock.tlf +170 -1
- data/examples/tblock_overflow/tblock_overflow.tlf +538 -1
- data/examples/tblock_styles/font_size.tlf +383 -1
- data/examples/tblock_styles/tblock_styles.tlf +889 -1
- data/examples/text_align/text_align.tlf +241 -1
- data/examples/typeB_page_size/B4_ISO.tlf +45 -1
- data/examples/typeB_page_size/B4_JIS.tlf +45 -1
- data/examples/word_wrap/word_wrap.tlf +297 -1
- data/lib/thinreports.rb +0 -1
- data/lib/thinreports/config.rb +3 -0
- data/lib/thinreports/core/errors.rb +0 -3
- data/lib/thinreports/core/format/base.rb +4 -4
- data/lib/thinreports/core/shape.rb +1 -9
- data/lib/thinreports/core/shape/basic.rb +3 -3
- data/lib/thinreports/core/shape/basic/block_format.rb +1 -1
- data/lib/thinreports/core/shape/basic/format.rb +2 -14
- data/lib/thinreports/core/shape/basic/internal.rb +2 -2
- data/lib/thinreports/core/shape/image_block.rb +3 -3
- data/lib/thinreports/core/shape/image_block/format.rb +0 -2
- data/lib/thinreports/core/shape/image_block/internal.rb +1 -1
- data/lib/thinreports/core/shape/list.rb +3 -7
- data/lib/thinreports/core/shape/list/format.rb +37 -24
- data/lib/thinreports/core/shape/list/manager.rb +1 -36
- data/lib/thinreports/core/shape/list/page.rb +0 -15
- data/lib/thinreports/core/shape/list/page_state.rb +1 -1
- data/lib/thinreports/core/shape/list/section_format.rb +14 -12
- data/lib/thinreports/core/shape/list/section_internal.rb +4 -7
- data/lib/thinreports/core/shape/manager/format.rb +0 -2
- data/lib/thinreports/core/shape/manager/internal.rb +1 -1
- data/lib/thinreports/core/shape/page_number.rb +1 -1
- data/lib/thinreports/core/shape/page_number/format.rb +9 -6
- data/lib/thinreports/core/shape/page_number/interface.rb +1 -1
- data/lib/thinreports/core/shape/page_number/internal.rb +2 -6
- data/lib/thinreports/core/shape/style/base.rb +11 -13
- data/lib/thinreports/core/shape/style/basic.rb +4 -4
- data/lib/thinreports/core/shape/style/graphic.rb +4 -10
- data/lib/thinreports/core/shape/style/text.rb +36 -69
- data/lib/thinreports/core/shape/text.rb +3 -3
- data/lib/thinreports/core/shape/text/format.rb +3 -13
- data/lib/thinreports/core/shape/text/internal.rb +2 -2
- data/lib/thinreports/core/shape/text_block.rb +3 -3
- data/lib/thinreports/core/shape/text_block/format.rb +9 -6
- data/lib/thinreports/core/shape/text_block/interface.rb +7 -7
- data/lib/thinreports/core/shape/text_block/internal.rb +1 -1
- data/lib/thinreports/generator/pdf.rb +0 -1
- data/lib/thinreports/generator/pdf/document.rb +2 -2
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +25 -51
- data/lib/thinreports/generator/pdf/document/draw_template_items.rb +66 -0
- data/lib/thinreports/generator/pdf/document/font.rb +3 -8
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +97 -77
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +18 -13
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +17 -12
- data/lib/thinreports/generator/pdf/document/page.rb +1 -1
- data/lib/thinreports/generator/pdf/drawer/list.rb +5 -1
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +1 -4
- data/lib/thinreports/generator/pdf/drawer/page.rb +9 -9
- data/lib/thinreports/layout.rb +3 -3
- data/lib/thinreports/layout/base.rb +0 -16
- data/lib/thinreports/layout/format.rb +38 -57
- data/lib/thinreports/layout/legacy_schema.rb +354 -0
- data/lib/thinreports/layout/version.rb +1 -1
- data/lib/thinreports/report.rb +0 -1
- data/lib/thinreports/report/base.rb +3 -17
- data/lib/thinreports/report/internal.rb +13 -55
- data/lib/thinreports/report/page.rb +1 -1
- data/lib/thinreports/version.rb +1 -1
- data/test/data/legacy_layout/all-items.tlf +1 -0
- data/test/schema_helper.rb +121 -0
- data/test/test_helper.rb +13 -50
- data/test/unit/core/format/test_base.rb +35 -31
- data/test/unit/core/shape/base/test_internal.rb +1 -1
- data/test/unit/core/shape/basic/test_block_format.rb +23 -0
- data/test/unit/core/shape/basic/{test_basic_interface.rb → test_block_interface.rb} +1 -1
- data/test/unit/core/shape/basic/{test_basic_internal.rb → test_block_internal.rb} +4 -7
- data/test/unit/core/shape/basic/test_format.rb +25 -47
- data/test/unit/core/shape/basic/test_interface.rb +5 -5
- data/test/unit/core/shape/basic/test_internal.rb +6 -11
- data/test/unit/core/shape/image_block/test_interface.rb +5 -5
- data/test/unit/core/shape/image_block/test_internal.rb +2 -2
- data/test/unit/core/shape/list/test_format.rb +86 -44
- data/test/unit/core/shape/list/test_manager.rb +10 -65
- data/test/unit/core/shape/list/test_page.rb +10 -61
- data/test/unit/core/shape/list/test_page_state.rb +1 -1
- data/test/unit/core/shape/list/test_section_format.rb +19 -28
- data/test/unit/core/shape/list/test_section_interface.rb +14 -6
- data/test/unit/core/shape/list/test_section_internal.rb +17 -23
- data/test/unit/core/shape/manager/test_format.rb +1 -1
- data/test/unit/core/shape/manager/test_internal.rb +59 -98
- data/test/unit/core/shape/manager/test_target.rb +21 -30
- data/test/unit/core/shape/page_number/test_format.rb +34 -52
- data/test/unit/core/shape/page_number/test_interface.rb +1 -1
- data/test/unit/core/shape/page_number/test_internal.rb +2 -2
- data/test/unit/core/shape/styles/test_base.rb +16 -41
- data/test/unit/core/shape/styles/test_basic.rb +7 -7
- data/test/unit/core/shape/styles/test_graphic.rb +27 -32
- data/test/unit/core/shape/styles/test_text.rb +68 -311
- data/test/unit/core/shape/text/test_format.rb +30 -59
- data/test/unit/core/shape/text/test_internal.rb +5 -5
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +13 -13
- data/test/unit/core/shape/text_block/test_format.rb +145 -146
- data/test/unit/core/shape/text_block/test_interface.rb +9 -9
- data/test/unit/core/shape/text_block/test_internal.rb +9 -9
- data/test/unit/core/test_shape.rb +19 -31
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +112 -122
- data/test/unit/generator/pdf/document/graphics/test_basic.rb +45 -0
- data/test/unit/generator/pdf/document/graphics/test_image.rb +5 -5
- data/test/unit/generator/pdf/document/test_font.rb +4 -10
- data/test/unit/generator/pdf/document/test_page.rb +13 -11
- data/test/unit/generator/pdf/document/test_parse_color.rb +5 -5
- data/test/unit/generator/test_base.rb +5 -5
- data/test/unit/generator/test_configuration.rb +4 -8
- data/test/unit/generator/test_pdf.rb +3 -2
- data/test/unit/layout/test_base.rb +16 -22
- data/test/unit/layout/test_format.rb +66 -86
- data/test/unit/layout/test_legacy_schema.rb +587 -0
- data/test/unit/layout/test_version.rb +20 -20
- data/test/unit/report/test_base.rb +32 -45
- data/test/unit/report/test_internal.rb +43 -99
- data/test/unit/test_config.rb +4 -2
- data/test/unit/test_layout.rb +1 -1
- metadata +20 -48
- data/examples/list_events/list_events_0_7_7.tlf +0 -1
- data/examples/list_events/list_events_0_8.tlf +0 -1
- data/lib/thinreports/core/events.rb +0 -69
- data/lib/thinreports/core/format/builder.rb +0 -62
- data/lib/thinreports/core/shape/list/configuration.rb +0 -54
- data/lib/thinreports/core/shape/list/events.rb +0 -47
- data/lib/thinreports/core/shape/list/store.rb +0 -33
- data/lib/thinreports/generator/pdf/configuration.rb +0 -33
- data/lib/thinreports/generator/pdf/document/parse_svg.rb +0 -104
- data/lib/thinreports/layout/configuration.rb +0 -29
- data/test/data/layout_block.tlf +0 -1
- data/test/data/layout_list.tlf +0 -1
- data/test/data/layout_list_noheader.tlf +0 -1
- data/test/data/layout_text1.tlf +0 -1
- data/test/data/layout_text2.tlf +0 -1
- data/test/unit/core/format/test_builder.rb +0 -109
- data/test/unit/core/shape/basic/test_basic_format.rb +0 -30
- data/test/unit/core/shape/image_block/test_format.rb +0 -58
- data/test/unit/core/shape/list/test_configuration.rb +0 -69
- data/test/unit/core/shape/list/test_events.rb +0 -36
- data/test/unit/core/shape/list/test_store.rb +0 -41
- data/test/unit/core/test_events.rb +0 -93
- data/test/unit/generator/pdf/document/test_draw_shape.rb +0 -44
- data/test/unit/generator/pdf/test_configuration.rb +0 -31
- data/test/unit/layout/test_configuration.rb +0 -21
- data/test/unit/report/test_events.rb +0 -22
@@ -1,36 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::List::TestEvents < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
List = Thinreports::Core::Shape::List
|
9
|
-
|
10
|
-
def setup
|
11
|
-
@events = List::Events.new
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_page_footer_insert_event_should_be_able_to_be_used
|
15
|
-
@events.send(:verify_event_type, :page_footer_insert)
|
16
|
-
rescue Thinreports::Errors::UnknownEventType
|
17
|
-
flunk ':page_footer_insert cannot be used.'
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_footer_insert_event_should_be_able_to_be_used
|
21
|
-
@events.send(:verify_event_type, :footer_insert)
|
22
|
-
rescue Thinreports::Errors::UnknownEventType
|
23
|
-
flunk ':footer_insert cannot be used.'
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_page_finalize_event_should_be_able_to_be_used
|
27
|
-
@events.send(:verify_event_type, :page_finalize)
|
28
|
-
rescue Thinreports::Errors::UnknownEventType
|
29
|
-
flunk ':page_finalize cannot be used.'
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_list_property_of_PageEvent_should_equal_to_target_property
|
33
|
-
ev = List::Events::PageEvent.new(:page_finalize, 'list', 'page')
|
34
|
-
assert_same ev.list, ev.target
|
35
|
-
end
|
36
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::Shape::List::TestStore < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
List = Thinreports::Core::Shape::List
|
9
|
-
|
10
|
-
def test_new
|
11
|
-
klass = List::Store.new(foo: 'foo', hoge: 0)
|
12
|
-
|
13
|
-
assert_instance_of ::Class, klass
|
14
|
-
|
15
|
-
st1 = klass.new
|
16
|
-
st2 = klass.new
|
17
|
-
|
18
|
-
refute_same st1.foo, st2.foo
|
19
|
-
# Fixnum is immutable
|
20
|
-
assert_same st1.hoge, st2.hoge
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_init
|
24
|
-
store = List::Store.init(foo: 0, hoge: 'hoge')
|
25
|
-
|
26
|
-
assert_respond_to store, :foo
|
27
|
-
assert_respond_to store, :hoge
|
28
|
-
|
29
|
-
assert_equal store.foo, 0
|
30
|
-
assert_equal store.hoge, 'hoge'
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_copy
|
34
|
-
store = List::Store.init(foo: Time.now)
|
35
|
-
|
36
|
-
copied = store.copy
|
37
|
-
|
38
|
-
assert_equal store.foo, copied.foo
|
39
|
-
refute_same store.foo, copied.foo
|
40
|
-
end
|
41
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Core::TestEvents < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
# Alias
|
9
|
-
Events = Thinreports::Core::Events
|
10
|
-
|
11
|
-
def setup
|
12
|
-
@events = Events.new(:load, :change, :blur)
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_listen
|
16
|
-
load1_handler = proc{|e| e.type }
|
17
|
-
load2_handler = proc{|e| e.type }
|
18
|
-
change_handler = proc{|e| e.target }
|
19
|
-
|
20
|
-
@events.listen(:load, &load1_handler)
|
21
|
-
@events.listen(:change, &change_handler)
|
22
|
-
# Overwrite
|
23
|
-
@events.listen(:load, &load2_handler)
|
24
|
-
|
25
|
-
# Using #on method
|
26
|
-
@events.on(:blur) do |e|
|
27
|
-
e.target
|
28
|
-
end
|
29
|
-
|
30
|
-
assert_equal @events.events.size, 3
|
31
|
-
assert_same @events.events[:change], change_handler
|
32
|
-
assert_same @events.events[:load], load2_handler
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_listen_raise_error_when_unknown_event_type_is_set
|
36
|
-
assert_raises Thinreports::Errors::UnknownEventType do
|
37
|
-
@events.listen(:unknown) {|e| e.type }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_listen_raise_error_when_no_block_is_given
|
42
|
-
assert_raises ::ArgumentError do
|
43
|
-
@events.listen(:blur)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_unlisten
|
48
|
-
@events.listen(:load) {|e| e.type }
|
49
|
-
@events.listen(:change) {|e| e.type }
|
50
|
-
@events.listen(:blur) {|e| e.type }
|
51
|
-
|
52
|
-
@events.unlisten(:load)
|
53
|
-
@events.un(:change)
|
54
|
-
@events.un(:blur)
|
55
|
-
|
56
|
-
assert_empty @events.events
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_dispatch
|
60
|
-
# Expected returns a true value
|
61
|
-
@events.listen(:change) {|e| e.type == :change }
|
62
|
-
assert_equal @events.dispatch(Events::Event.new(:change)), true
|
63
|
-
|
64
|
-
# Expected to reverse the string given as e#target
|
65
|
-
@events.on(:blur) {|e| e.target.reverse }
|
66
|
-
assert_equal @events.dispatch(Events::Event.new(:blur, '123')), '321'
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_dispatch_raise_error_when_no_event_type_is_given
|
70
|
-
assert_raises ::ArgumentError do
|
71
|
-
@events.dispatch(Events::Event.new)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_dispatch_return_nil_when_event_type_is_not_listened
|
76
|
-
assert_nil @events.dispatch(Events::Event.new(:load, self))
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_copy
|
80
|
-
@events.on(:change) { :on_change }
|
81
|
-
@events.on(:load) { :on_load }
|
82
|
-
|
83
|
-
copied = @events.copy
|
84
|
-
|
85
|
-
assert @events.events.all? {|k,f|
|
86
|
-
copied.events[k].call == f.call
|
87
|
-
}
|
88
|
-
refute_same @events.events, copied.events
|
89
|
-
|
90
|
-
@events.unlisten(:change)
|
91
|
-
refute_nil copied.dispatch(Events::Event.new(:change, self))
|
92
|
-
end
|
93
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Generator::PDF::TestDrawShape < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@pdf = Thinreports::Generator::PDF::Document.new
|
10
|
-
end
|
11
|
-
|
12
|
-
def create_tblock_interface(format_config = {})
|
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
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_shape_text_attrs_should_return_attrs_containing_an_overflow_property
|
21
|
-
tblock = create_tblock_interface('id' => 'text', 'overflow' => 'truncate')
|
22
|
-
assert_equal @pdf.send(:shape_text_attrs, tblock.internal)[:overflow], :truncate
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_shape_text_attrs_should_return_attrs_containing_an_valign_property
|
26
|
-
tblock = create_tblock_interface('id' => 'text', 'valign' => 'top')
|
27
|
-
assert_equal @pdf.send(:shape_text_attrs, tblock.internal)[:valign], :top
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_shape_text_attrs_should_return_attrs_containing_an_line_height_unless_line_height_is_blank
|
31
|
-
tblock = create_tblock_interface('id' => 'text', 'line-height' => '10')
|
32
|
-
assert_equal @pdf.send(:shape_text_attrs, tblock.internal)[:line_height], '10'
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_shape_text_attrs_should_return_attrs_uncontaining_an_line_height_if_line_height_is_blank
|
36
|
-
tblock = create_tblock_interface('id' => 'text', 'line-height' => '')
|
37
|
-
assert_nil @pdf.send(:shape_text_attrs, tblock.internal)[:line_height]
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_shape_text_attrs
|
41
|
-
tblock = create_tblock_interface('id' => 'text', 'word-wrap' => 'none')
|
42
|
-
assert_includes @pdf.send(:shape_text_attrs, tblock.internal).keys, :word_wrap
|
43
|
-
end
|
44
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Generator::PDF::TestConfiguration < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
def setup
|
9
|
-
@config = Thinreports::Generator::PDF::Configuration.new
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_eudc_fonts_is_deprecated
|
13
|
-
_out, err = capture_io do
|
14
|
-
@config.eudc_fonts = []
|
15
|
-
end
|
16
|
-
assert_includes err, '[DEPRECATION]'
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_eudc_fonts_should_be_able_to_set_only_TTF
|
20
|
-
assert_raises ArgumentError do
|
21
|
-
@config.eudc_fonts = '/path/to/eudc'
|
22
|
-
end
|
23
|
-
assert_raises ArgumentError do
|
24
|
-
@config.eudc_fonts = %w( /path/to/eudc1.ttf /path/to/eudc2 )
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_eudc_fonts_should_return_empty_array_by_default
|
29
|
-
assert_equal @config.eudc_fonts, []
|
30
|
-
end
|
31
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Layout::TestConfiguration < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
# Alias
|
9
|
-
Configuration = Thinreports::Layout::Configuration
|
10
|
-
|
11
|
-
def setup
|
12
|
-
layout = Thinreports::Layout.new data_file('layout_text1.tlf')
|
13
|
-
@config = Configuration.new(layout)
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_disable_methods
|
17
|
-
assert_raises NoMethodError do
|
18
|
-
@config.values
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
|
5
|
-
class Thinreports::Report::TestEvents < Minitest::Test
|
6
|
-
include Thinreports::TestHelper
|
7
|
-
|
8
|
-
# Alias
|
9
|
-
Report = Thinreports::Report
|
10
|
-
|
11
|
-
def test_event_types
|
12
|
-
events = Report::Events.new
|
13
|
-
assert_equal events.instance_variable_get(:@types), [:page_create, :generate]
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_event_properly_store_the_properties
|
17
|
-
e = Report::Events::Event.new(:page_create, :target, :page, :pages)
|
18
|
-
assert_equal [e.type, e.target, e.page, e.pages],
|
19
|
-
[:page_create, :target, :page, :pages]
|
20
|
-
assert_same e.target, e.report
|
21
|
-
end
|
22
|
-
end
|