thinreports 0.10.2 → 0.12.1
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 -2
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/test.yml +50 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +43 -0
- data/Gemfile +2 -1
- data/{MIT-LICENSE → LICENSE.txt} +2 -0
- data/README.md +70 -56
- data/Rakefile +12 -25
- data/gemfiles/prawn-2.2.gemfile +5 -0
- data/gemfiles/prawn-2.3.gemfile +5 -0
- data/gemfiles/prawn-2.4.gemfile +5 -0
- data/lib/thinreports/core/shape/basic/format.rb +5 -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/stack_view/format.rb +27 -0
- data/lib/thinreports/core/shape/stack_view/interface.rb +17 -0
- data/lib/thinreports/core/shape/stack_view/internal.rb +22 -0
- data/lib/thinreports/core/shape/stack_view/row_format.rb +39 -0
- data/lib/thinreports/core/shape/stack_view.rb +17 -0
- data/lib/thinreports/core/shape/style/basic.rb +4 -1
- data/lib/thinreports/core/shape/text.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/core/shape/text_block.rb +1 -1
- data/lib/thinreports/core/shape.rb +2 -0
- data/lib/thinreports/generate.rb +11 -0
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +31 -10
- data/lib/thinreports/generator/pdf/document/draw_template_items.rb +1 -1
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +19 -1
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +10 -5
- data/lib/thinreports/generator/pdf/document/page.rb +12 -0
- data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +7 -7
- data/lib/thinreports/layout/base.rb +1 -1
- data/lib/thinreports/layout/legacy_schema.rb +1 -0
- data/lib/thinreports/layout/version.rb +1 -1
- data/lib/thinreports/report/internal.rb +2 -0
- data/lib/thinreports/report.rb +2 -2
- data/lib/thinreports/section_report/build.rb +32 -0
- data/lib/thinreports/section_report/builder/item_builder.rb +49 -0
- data/lib/thinreports/section_report/builder/report_builder.rb +82 -0
- data/lib/thinreports/section_report/builder/report_data.rb +13 -0
- data/lib/thinreports/section_report/builder/stack_view_builder.rb +53 -0
- data/lib/thinreports/section_report/builder/stack_view_data.rb +11 -0
- data/lib/thinreports/section_report/generate.rb +26 -0
- data/lib/thinreports/section_report/pdf/render.rb +23 -0
- data/lib/thinreports/section_report/pdf/renderer/draw_item.rb +68 -0
- data/lib/thinreports/section_report/pdf/renderer/group_renderer.rb +57 -0
- data/lib/thinreports/section_report/pdf/renderer/section_height.rb +100 -0
- data/lib/thinreports/section_report/pdf/renderer/section_renderer.rb +39 -0
- data/lib/thinreports/section_report/pdf/renderer/stack_view_renderer.rb +55 -0
- data/lib/thinreports/section_report/pdf/renderer/stack_view_row_renderer.rb +38 -0
- data/lib/thinreports/section_report/schema/loader.rb +28 -0
- data/lib/thinreports/section_report/schema/parser.rb +52 -0
- data/lib/thinreports/section_report/schema/report.rb +30 -0
- data/lib/thinreports/section_report/schema/section.rb +47 -0
- data/lib/thinreports/version.rb +1 -1
- data/lib/thinreports.rb +5 -0
- data/thinreports.gemspec +11 -10
- metadata +48 -150
- data/.travis.yml +0 -16
- data/examples/character_spacing/character_spacing.rb +0 -8
- data/examples/character_spacing/character_spacing.tlf +0 -293
- data/examples/dynamic_image/dynamic_image.rb +0 -31
- data/examples/dynamic_image/dynamic_image.tlf +0 -661
- data/examples/dynamic_image/img200x100.png +0 -0
- data/examples/dynamic_image/img50x50.png +0 -0
- data/examples/dynamic_style/dynamic_style.rb +0 -150
- data/examples/dynamic_style/dynamic_style.tlf +0 -1835
- data/examples/dynamic_style/dynamic_style_in_list.tlf +0 -344
- data/examples/dynamic_style/image.png +0 -0
- data/examples/eudc/eudc.rb +0 -20
- data/examples/eudc/eudc.tlf +0 -180
- data/examples/eudc/eudc.ttf +0 -0
- data/examples/helper.rb +0 -50
- data/examples/hidden_shapes/hidden_shapes.rb +0 -9
- data/examples/hidden_shapes/hidden_shapes.tlf +0 -449
- data/examples/list_events/list_events.rb +0 -32
- data/examples/list_events/list_events.tlf +0 -361
- data/examples/list_manual_generation/list_manual_generation.rb +0 -22
- data/examples/list_manual_generation/list_manual_generation.tlf +0 -132
- data/examples/list_page_number/list_page_number.rb +0 -17
- data/examples/list_page_number/list_page_number.tlf +0 -254
- data/examples/page_number/page_number.rb +0 -33
- data/examples/page_number/page_number.tlf +0 -215
- data/examples/palleted_png/palleted_png.png +0 -0
- data/examples/palleted_png/palleted_png.rb +0 -9
- data/examples/palleted_png/palleted_png.tlf +0 -47
- data/examples/password_setting/password_setting.rb +0 -10
- data/examples/password_setting/password_setting.tlf +0 -45
- data/examples/report_callbacks/report_callbacks.rb +0 -14
- data/examples/report_callbacks/report_callbacks.tlf +0 -147
- data/examples/single_line_tblock/single_line_tblock.rb +0 -13
- data/examples/single_line_tblock/single_line_tblock.tlf +0 -170
- data/examples/tblock_overflow/tblock_overflow.rb +0 -20
- data/examples/tblock_overflow/tblock_overflow.tlf +0 -538
- data/examples/tblock_styles/font_size.tlf +0 -383
- data/examples/tblock_styles/tblock_styles.rb +0 -43
- data/examples/tblock_styles/tblock_styles.tlf +0 -889
- data/examples/text_align/text_align.rb +0 -8
- data/examples/text_align/text_align.tlf +0 -241
- data/examples/typeB_page_size/B4_ISO.tlf +0 -45
- data/examples/typeB_page_size/B4_JIS.tlf +0 -45
- data/examples/typeB_page_size/typeB_page_size.rb +0 -17
- data/examples/word_wrap/word_wrap.rb +0 -26
- data/examples/word_wrap/word_wrap.tlf +0 -297
- 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/schema_helper.rb +0 -122
- data/test/test_helper.rb +0 -48
- data/test/tmp/.gitkeep +0 -0
- data/test/unit/core/format/test_base.rb +0 -152
- data/test/unit/core/shape/base/test_internal.rb +0 -87
- data/test/unit/core/shape/basic/test_block_format.rb +0 -23
- data/test/unit/core/shape/basic/test_block_interface.rb +0 -29
- data/test/unit/core/shape/basic/test_block_internal.rb +0 -55
- data/test/unit/core/shape/basic/test_format.rb +0 -37
- data/test/unit/core/shape/basic/test_interface.rb +0 -108
- data/test/unit/core/shape/basic/test_internal.rb +0 -55
- data/test/unit/core/shape/image_block/test_interface.rb +0 -24
- data/test/unit/core/shape/image_block/test_internal.rb +0 -31
- data/test/unit/core/shape/list/test_format.rb +0 -111
- data/test/unit/core/shape/list/test_manager.rb +0 -67
- data/test/unit/core/shape/list/test_page.rb +0 -156
- data/test/unit/core/shape/list/test_page_state.rb +0 -31
- data/test/unit/core/shape/list/test_section_format.rb +0 -36
- data/test/unit/core/shape/list/test_section_interface.rb +0 -75
- data/test/unit/core/shape/list/test_section_internal.rb +0 -50
- data/test/unit/core/shape/manager/test_format.rb +0 -38
- data/test/unit/core/shape/manager/test_internal.rb +0 -132
- data/test/unit/core/shape/manager/test_target.rb +0 -140
- data/test/unit/core/shape/page_number/test_format.rb +0 -55
- data/test/unit/core/shape/page_number/test_interface.rb +0 -33
- data/test/unit/core/shape/page_number/test_internal.rb +0 -81
- data/test/unit/core/shape/styles/test_base.rb +0 -191
- data/test/unit/core/shape/styles/test_basic.rb +0 -24
- data/test/unit/core/shape/styles/test_graphic.rb +0 -50
- data/test/unit/core/shape/styles/test_text.rb +0 -97
- data/test/unit/core/shape/text/test_format.rb +0 -44
- data/test/unit/core/shape/text/test_internal.rb +0 -20
- data/test/unit/core/shape/text_block/formatter/test_basic.rb +0 -24
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +0 -49
- data/test/unit/core/shape/text_block/formatter/test_number.rb +0 -76
- data/test/unit/core/shape/text_block/formatter/test_padding.rb +0 -77
- data/test/unit/core/shape/text_block/test_format.rb +0 -169
- data/test/unit/core/shape/text_block/test_formatter.rb +0 -28
- data/test/unit/core/shape/text_block/test_interface.rb +0 -63
- data/test/unit/core/shape/text_block/test_internal.rb +0 -128
- data/test/unit/core/test_shape.rb +0 -52
- data/test/unit/core/test_utils.rb +0 -68
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +0 -135
- data/test/unit/generator/pdf/document/graphics/test_basic.rb +0 -46
- data/test/unit/generator/pdf/document/graphics/test_image.rb +0 -46
- data/test/unit/generator/pdf/document/graphics/test_text.rb +0 -171
- data/test/unit/generator/pdf/document/test_font.rb +0 -110
- data/test/unit/generator/pdf/document/test_graphics.rb +0 -42
- data/test/unit/generator/pdf/document/test_page.rb +0 -122
- data/test/unit/generator/pdf/document/test_parse_color.rb +0 -30
- data/test/unit/generator/pdf/prawn_ext/test_calc_image_dimensions.rb +0 -41
- data/test/unit/generator/pdf/prawn_ext/test_width_of.rb +0 -22
- data/test/unit/generator/pdf/test_document.rb +0 -22
- data/test/unit/generator/test_pdf.rb +0 -26
- data/test/unit/layout/test_base.rb +0 -41
- data/test/unit/layout/test_format.rb +0 -100
- data/test/unit/layout/test_legacy_schema.rb +0 -574
- data/test/unit/layout/test_version.rb +0 -26
- data/test/unit/report/test_base.rb +0 -248
- data/test/unit/report/test_internal.rb +0 -206
- data/test/unit/test_config.rb +0 -36
- data/test/unit/test_layout.rb +0 -12
- data/test/unit/test_report.rb +0 -18
@@ -1,150 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
example :dynamic_style, 'Change styles of the object dynamically' do |t|
|
4
|
-
image = t.resource('image.png')
|
5
|
-
setup_values = Proc.new do |page|
|
6
|
-
# The Basic Style
|
7
|
-
page.values(basic_show5: 'TextBlock',
|
8
|
-
basic_show6: image,
|
9
|
-
basic_hide5: 'TextBlock',
|
10
|
-
basic_hide6: image)
|
11
|
-
# The Text Style
|
12
|
-
page.values(text_b3: 'To bold',
|
13
|
-
text_b4: 'To normal',
|
14
|
-
text_i3: 'To italic',
|
15
|
-
text_i4: 'To normal',
|
16
|
-
text_u3: 'To underline',
|
17
|
-
text_u4: 'To none',
|
18
|
-
text_l3: 'To line-through',
|
19
|
-
text_l4: 'To none')
|
20
|
-
page.values(text_a2: 'To right align',
|
21
|
-
text_a3: "To right align\n右寄せ",
|
22
|
-
text_va2: "To bottom align\n下揃え",
|
23
|
-
text_color2: '赤色')
|
24
|
-
end
|
25
|
-
|
26
|
-
Thinreports::Report.generate(filename: t.output_filename,
|
27
|
-
layout: t.layout_filename) do |r|
|
28
|
-
# In case of using dynamic_style.tlf
|
29
|
-
|
30
|
-
# Create raw-page.
|
31
|
-
r.start_new_page
|
32
|
-
r.page.item(:title).value('Original Page')
|
33
|
-
|
34
|
-
setup_values.call(r.page)
|
35
|
-
|
36
|
-
# Create styled-page.
|
37
|
-
r.start_new_page
|
38
|
-
|
39
|
-
setup_values.call(r.page)
|
40
|
-
r.page.item(:title).value('Styled Page')
|
41
|
-
|
42
|
-
# The Basic Style
|
43
|
-
6.times do |i|
|
44
|
-
r.page.item("basic_show#{i + 1}").style(:visible, true)
|
45
|
-
r.page.item("basic_hide#{i + 1}").style(:visible, false)
|
46
|
-
end
|
47
|
-
|
48
|
-
# The Graphic Style
|
49
|
-
r.page.item(:graphic_bcolor1).style(:border_color, '#ff0000')
|
50
|
-
r.page[:graphic_bcolor2].style(:border_color, 'red')
|
51
|
-
# nil or 'none'.
|
52
|
-
r.page.item(:graphic_bcolor4).style(:border_color, nil)
|
53
|
-
|
54
|
-
r.page.item(:graphic_bwidth1).style(:border_width, 5)
|
55
|
-
r.page.item(:graphic_bwidth2).style(:border_width, 5)
|
56
|
-
r.page.item(:graphic_bwidth3).style(:border_width, 5)
|
57
|
-
r.page.item(:graphic_bwidth4).style(:border_width, 2)
|
58
|
-
r.page.item(:graphic_bwidth5).style(:border_width, 0)
|
59
|
-
|
60
|
-
r.page.item(:graphic_fcolor1).style(:fill_color, '#ff0000')
|
61
|
-
# nil or 'none'
|
62
|
-
r.page.item(:graphic_fcolor3).style(:fill_color, 'none')
|
63
|
-
r.page.item(:graphic_fcolor4).style(:fill_color, 'ff0000')
|
64
|
-
|
65
|
-
# The Text Style
|
66
|
-
[1, 3].each do |i|
|
67
|
-
r.page["text_b#{i}"].style(:bold, true)
|
68
|
-
r.page.item("text_i#{i}").style(:italic, true)
|
69
|
-
r.page.item("text_u#{i}").style(:underline, true)
|
70
|
-
r.page.item("text_l#{i}").style(:linethrough, true)
|
71
|
-
end
|
72
|
-
[2, 4].each do |i|
|
73
|
-
r.page.item("text_b#{i}").style(:bold, false)
|
74
|
-
r.page.item("text_i#{i}").style(:italic, false)
|
75
|
-
r.page.item("text_u#{i}").style(:underline, false)
|
76
|
-
r.page.item("text_l#{i}").style(:linethrough, false)
|
77
|
-
end
|
78
|
-
|
79
|
-
3.times do |i|
|
80
|
-
r.page.item("text_a#{i + 1}").style(:align, :right)
|
81
|
-
end
|
82
|
-
2.times do |i|
|
83
|
-
r.page.item("text_va#{i + 1}").style(:valign, :bottom)
|
84
|
-
end
|
85
|
-
|
86
|
-
2.times do |i|
|
87
|
-
r.page["text_color#{i + 1}"].style(:color, 'ff0000')
|
88
|
-
end
|
89
|
-
|
90
|
-
# In case of using "dynamic_style_in_list.tlf"
|
91
|
-
r.start_new_page(layout: t.resource('dynamic_style_in_list.tlf'))
|
92
|
-
|
93
|
-
# Settings for Header.
|
94
|
-
r.page.list(:list).header do |header|
|
95
|
-
header.item(:rect).styles(border_color: nil,
|
96
|
-
fill_color: 'ff00ff')
|
97
|
-
header.item(:text).styles(align: :center,
|
98
|
-
valign: :middle,
|
99
|
-
bold: true)
|
100
|
-
header[:tblock].styles(align: :center,
|
101
|
-
valign: :middle,
|
102
|
-
color: 'red',
|
103
|
-
linethrough: true)
|
104
|
-
end
|
105
|
-
|
106
|
-
1.step(10, 1) do |i|
|
107
|
-
# Flag of overflowed list-page.
|
108
|
-
is_overflowed = r.page.list(:list).overflow?
|
109
|
-
|
110
|
-
# Add details.
|
111
|
-
r.page.list(:list).add_row do |row|
|
112
|
-
case
|
113
|
-
when i % 2 == 0
|
114
|
-
row.item(:rect).styles(border_color: 'ff0000',
|
115
|
-
border_width: 3,
|
116
|
-
fill_color: '0000ff')
|
117
|
-
row.item(:text).styles(color: 'red',
|
118
|
-
align: :left,
|
119
|
-
valign: :middle)
|
120
|
-
row.item(:tblock).styles(color: 'blue',
|
121
|
-
align: :left,
|
122
|
-
valign: :middle)
|
123
|
-
when i % 3 == 0
|
124
|
-
row.item(:rect).style(:visible, false)
|
125
|
-
row.item(:text).styles(color: '0000ff',
|
126
|
-
align: :right,
|
127
|
-
valign: :bottom)
|
128
|
-
row.item(:tblock).styles(color: 'ff0000',
|
129
|
-
align: :right,
|
130
|
-
valign: :bottom)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
# Change header styles when list-page was overflowed.
|
135
|
-
if is_overflowed
|
136
|
-
r.page.list(:list).header do |header|
|
137
|
-
header.item(:rect).styles(border_color: 'black',
|
138
|
-
fill_color: '#ffffff')
|
139
|
-
header.item(:text).styles(align: :left,
|
140
|
-
valign: :top,
|
141
|
-
bold: false)
|
142
|
-
header.item(:tblock).styles(align: :left,
|
143
|
-
valign: :top,
|
144
|
-
color: '#000000',
|
145
|
-
linethrough: false)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|