thinreports 0.7.7 → 0.8.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/.gitignore +3 -6
- data/.travis.yml +4 -10
- data/CHANGELOG.md +220 -0
- data/Gemfile +3 -3
- data/MIT-LICENSE +1 -1
- data/README.md +286 -0
- data/Rakefile +38 -8
- data/examples/character_spacing/character_spacing.rb +8 -0
- data/examples/character_spacing/character_spacing.tlf +1 -0
- data/examples/dynamic_image/dynamic_image.rb +31 -0
- data/examples/dynamic_image/dynamic_image.tlf +1 -0
- data/{test/case → examples}/dynamic_image/img200x100.png +0 -0
- data/{test/case → examples}/dynamic_image/img50x50.png +0 -0
- data/examples/dynamic_style/dynamic_style.rb +150 -0
- data/examples/dynamic_style/dynamic_style.tlf +1 -0
- data/examples/dynamic_style/dynamic_style_in_list.tlf +1 -0
- data/{test/case → examples}/dynamic_style/image.png +0 -0
- data/examples/eudc/eudc.rb +20 -0
- data/examples/eudc/eudc.tlf +1 -0
- data/{test/case → examples}/eudc/eudc.ttf +0 -0
- data/{test/case → examples}/helper.rb +14 -12
- data/examples/hidden_shapes/hidden_shapes.rb +9 -0
- data/examples/hidden_shapes/hidden_shapes.tlf +1 -0
- data/examples/list_events/list_events.rb +59 -0
- data/examples/list_events/list_events_0_7_7.tlf +1 -0
- data/examples/list_events/list_events_0_8.tlf +1 -0
- data/{test/case → examples}/list_manual_generation/list_manual_generation.rb +4 -4
- data/examples/list_manual_generation/list_manual_generation.tlf +1 -0
- data/{test/case → examples}/list_page_number/list_page_number.rb +3 -3
- data/examples/list_page_number/list_page_number.tlf +1 -0
- data/examples/page_number/page_number.rb +33 -0
- data/examples/page_number/page_number.tlf +1 -0
- data/examples/password_setting/password_setting.rb +10 -0
- data/examples/password_setting/password_setting.tlf +1 -0
- data/examples/report_callbacks/report_callbacks.rb +31 -0
- data/examples/report_callbacks/report_callbacks.tlf +1 -0
- data/{test/case → examples}/single_line_tblock/single_line_tblock.rb +2 -2
- data/examples/single_line_tblock/single_line_tblock.tlf +1 -0
- data/examples/tblock_overflow/tblock_overflow.rb +20 -0
- data/examples/tblock_overflow/tblock_overflow.tlf +1 -0
- data/examples/tblock_styles/font_size.tlf +1 -0
- data/examples/tblock_styles/tblock_styles.rb +43 -0
- data/examples/tblock_styles/tblock_styles.tlf +1 -0
- data/examples/text_align/text_align.rb +8 -0
- data/examples/text_align/text_align.tlf +1 -0
- data/examples/typeB_page_size/B4_ISO.tlf +1 -0
- data/examples/typeB_page_size/B4_JIS.tlf +1 -0
- data/{test/case → examples}/typeB_page_size/typeB_page_size.rb +3 -3
- data/examples/word_wrap/word_wrap.rb +26 -0
- data/examples/word_wrap/word_wrap.tlf +1 -0
- data/{resources/fonts → fonts}/IPA_Font_License_Agreement_v1.0.txt +0 -0
- data/{resources/fonts → fonts}/ipag.ttf +0 -0
- data/{resources/fonts → fonts}/ipagp.ttf +0 -0
- data/{resources/fonts → fonts}/ipam.ttf +0 -0
- data/{resources/fonts → fonts}/ipamp.ttf +0 -0
- data/lib/thinreports.rb +14 -2
- data/lib/thinreports/config.rb +30 -10
- data/lib/thinreports/core/errors.rb +23 -20
- data/lib/thinreports/core/events.rb +18 -19
- data/lib/thinreports/core/format/base.rb +20 -20
- data/lib/thinreports/core/format/builder.rb +14 -22
- data/lib/thinreports/core/shape.rb +9 -13
- data/lib/thinreports/core/shape/base.rb +4 -5
- data/lib/thinreports/core/shape/base/interface.rb +15 -15
- data/lib/thinreports/core/shape/base/internal.rb +15 -20
- data/lib/thinreports/core/shape/basic.rb +1 -1
- data/lib/thinreports/core/shape/basic/block_format.rb +3 -4
- data/lib/thinreports/core/shape/basic/block_interface.rb +9 -4
- data/lib/thinreports/core/shape/basic/block_internal.rb +9 -10
- data/lib/thinreports/core/shape/basic/format.rb +11 -10
- data/lib/thinreports/core/shape/basic/interface.rb +3 -3
- data/lib/thinreports/core/shape/basic/internal.rb +4 -5
- data/lib/thinreports/core/shape/image_block.rb +1 -1
- data/lib/thinreports/core/shape/image_block/format.rb +5 -6
- data/lib/thinreports/core/shape/image_block/interface.rb +9 -7
- data/lib/thinreports/core/shape/image_block/internal.rb +5 -6
- data/lib/thinreports/core/shape/list.rb +1 -1
- data/lib/thinreports/core/shape/list/configuration.rb +30 -15
- data/lib/thinreports/core/shape/list/events.rb +11 -11
- data/lib/thinreports/core/shape/list/format.rb +27 -28
- data/lib/thinreports/core/shape/list/manager.rb +128 -95
- data/lib/thinreports/core/shape/list/page.rb +54 -50
- data/lib/thinreports/core/shape/list/page_state.rb +15 -16
- data/lib/thinreports/core/shape/list/section_format.rb +14 -15
- data/lib/thinreports/core/shape/list/section_interface.rb +15 -16
- data/lib/thinreports/core/shape/list/section_internal.rb +7 -8
- data/lib/thinreports/core/shape/list/store.rb +10 -11
- data/lib/thinreports/core/shape/manager.rb +1 -1
- data/lib/thinreports/core/shape/manager/format.rb +10 -11
- data/lib/thinreports/core/shape/manager/internal.rb +21 -20
- data/lib/thinreports/core/shape/manager/target.rb +63 -34
- data/lib/thinreports/core/shape/page_number.rb +1 -1
- data/lib/thinreports/core/shape/page_number/format.rb +3 -3
- data/lib/thinreports/core/shape/page_number/interface.rb +2 -2
- data/lib/thinreports/core/shape/page_number/internal.rb +3 -3
- data/lib/thinreports/core/shape/style.rb +1 -1
- data/lib/thinreports/core/shape/style/base.rb +29 -29
- data/lib/thinreports/core/shape/style/basic.rb +1 -1
- data/lib/thinreports/core/shape/style/graphic.rb +10 -25
- data/lib/thinreports/core/shape/style/text.rb +36 -30
- data/lib/thinreports/core/shape/text.rb +1 -1
- data/lib/thinreports/core/shape/text/format.rb +8 -9
- data/lib/thinreports/core/shape/text/interface.rb +2 -2
- data/lib/thinreports/core/shape/text/internal.rb +6 -7
- data/lib/thinreports/core/shape/text_block.rb +1 -1
- data/lib/thinreports/core/shape/text_block/format.rb +17 -18
- data/lib/thinreports/core/shape/text_block/formatter.rb +7 -8
- data/lib/thinreports/core/shape/text_block/formatter/basic.rb +13 -12
- data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +8 -9
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +11 -12
- data/lib/thinreports/core/shape/text_block/formatter/padding.rb +9 -32
- data/lib/thinreports/core/shape/text_block/interface.rb +2 -2
- data/lib/thinreports/core/shape/text_block/internal.rb +19 -20
- data/lib/thinreports/core/utils.rb +33 -32
- data/lib/thinreports/generator.rb +6 -8
- data/lib/thinreports/generator/base.rb +15 -24
- data/lib/thinreports/generator/configuration.rb +10 -9
- data/lib/thinreports/generator/pdf.rb +27 -30
- data/lib/thinreports/generator/pdf/configuration.rb +11 -6
- data/lib/thinreports/generator/pdf/document.rb +28 -28
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +30 -31
- data/lib/thinreports/generator/pdf/document/font.rb +53 -44
- data/lib/thinreports/generator/pdf/document/graphics.rb +8 -9
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +25 -25
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +25 -25
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +15 -15
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +40 -41
- data/lib/thinreports/generator/pdf/document/page.rb +20 -21
- data/lib/thinreports/generator/pdf/document/parse_color.rb +9 -10
- data/lib/thinreports/generator/pdf/document/parse_svg.rb +14 -15
- data/lib/thinreports/generator/pdf/drawer/base.rb +13 -14
- data/lib/thinreports/generator/pdf/drawer/list.rb +13 -14
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +13 -14
- data/lib/thinreports/generator/pdf/drawer/page.rb +16 -17
- data/lib/thinreports/generator/pdf/prawn_ext.rb +17 -33
- data/lib/thinreports/layout.rb +2 -2
- data/lib/thinreports/layout/base.rb +22 -36
- data/lib/thinreports/layout/configuration.rb +11 -9
- data/lib/thinreports/layout/format.rb +26 -27
- data/lib/thinreports/layout/version.rb +8 -9
- data/lib/thinreports/report.rb +10 -14
- data/lib/thinreports/report/base.rb +104 -126
- data/lib/thinreports/report/events.rb +5 -5
- data/lib/thinreports/report/internal.rb +41 -33
- data/lib/thinreports/{core → report}/page.rb +38 -30
- data/lib/thinreports/version.rb +2 -3
- data/test/data/font.ttf +0 -0
- data/test/data/layout_block.tlf +1 -0
- data/test/data/layout_list.tlf +1 -0
- data/test/data/layout_list_noheader.tlf +1 -0
- data/test/data/layout_text1.tlf +1 -0
- data/test/data/layout_text2.tlf +1 -0
- data/test/test_helper.rb +74 -0
- data/test/{unit/tmp → tmp}/.gitkeep +0 -0
- data/test/unit/core/format/test_base.rb +14 -14
- data/test/unit/core/format/test_builder.rb +19 -23
- data/test/unit/core/shape/base/test_internal.rb +34 -37
- data/test/unit/core/shape/basic/test_basic_format.rb +4 -4
- data/test/unit/core/shape/basic/test_basic_interface.rb +15 -13
- data/test/unit/core/shape/basic/test_basic_internal.rb +19 -16
- data/test/unit/core/shape/basic/test_format.rb +4 -4
- data/test/unit/core/shape/basic/test_interface.rb +36 -46
- data/test/unit/core/shape/basic/test_internal.rb +23 -20
- data/test/unit/core/shape/image_block/test_format.rb +5 -5
- data/test/unit/core/shape/image_block/test_interface.rb +17 -16
- data/test/unit/core/shape/image_block/test_internal.rb +19 -16
- data/test/unit/core/shape/list/test_configuration.rb +45 -33
- data/test/unit/core/shape/list/test_events.rb +7 -7
- data/test/unit/core/shape/list/test_format.rb +16 -18
- data/test/unit/core/shape/list/test_manager.rb +5 -5
- data/test/unit/core/shape/list/test_page.rb +80 -22
- data/test/unit/core/shape/list/test_page_state.rb +12 -12
- data/test/unit/core/shape/list/test_section_format.rb +16 -17
- data/test/unit/core/shape/list/test_section_interface.rb +30 -22
- data/test/unit/core/shape/list/test_section_internal.rb +21 -19
- data/test/unit/core/shape/list/test_store.rb +7 -7
- data/test/unit/core/shape/manager/test_format.rb +11 -15
- data/test/unit/core/shape/manager/test_internal.rb +9 -9
- data/test/unit/core/shape/manager/test_target.rb +85 -57
- data/test/unit/core/shape/page_number/test_format.rb +4 -4
- data/test/unit/core/shape/page_number/test_interface.rb +11 -8
- data/test/unit/core/shape/page_number/test_internal.rb +5 -5
- data/test/unit/core/shape/styles/test_base.rb +9 -9
- data/test/unit/core/shape/styles/test_basic.rb +5 -5
- data/test/unit/core/shape/styles/test_graphic.rb +19 -33
- data/test/unit/core/shape/styles/test_text.rb +18 -7
- data/test/unit/core/shape/text/test_format.rb +6 -6
- data/test/unit/core/shape/text/test_internal.rb +11 -12
- data/test/unit/core/shape/text_block/formatter/test_basic.rb +16 -16
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +4 -4
- data/test/unit/core/shape/text_block/formatter/test_number.rb +34 -34
- data/test/unit/core/shape/text_block/formatter/test_padding.rb +44 -44
- data/test/unit/core/shape/text_block/test_format.rb +8 -8
- data/test/unit/core/shape/text_block/test_formatter.rb +17 -17
- data/test/unit/core/shape/text_block/test_interface.rb +37 -20
- data/test/unit/core/shape/text_block/test_internal.rb +38 -38
- data/test/unit/core/test_events.rb +5 -5
- data/test/unit/core/test_shape.rb +6 -6
- data/test/unit/core/test_utils.rb +68 -0
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +4 -4
- data/test/unit/generator/pdf/document/graphics/test_text.rb +60 -53
- data/test/unit/generator/pdf/document/test_draw_shape.rb +9 -7
- data/test/unit/generator/pdf/document/test_font.rb +79 -58
- data/test/unit/generator/pdf/document/test_graphics.rb +18 -19
- data/test/unit/generator/pdf/document/test_page.rb +44 -45
- data/test/unit/generator/pdf/document/test_parse_color.rb +5 -5
- data/test/unit/generator/pdf/test_configuration.rb +16 -9
- data/test/unit/generator/pdf/test_document.rb +8 -16
- data/test/unit/generator/test_base.rb +31 -42
- data/test/unit/generator/test_configuration.rb +6 -6
- data/test/unit/generator/test_pdf.rb +17 -14
- data/test/unit/layout/test_base.rb +34 -79
- data/test/unit/layout/test_configuration.rb +12 -37
- data/test/unit/layout/test_format.rb +36 -39
- data/test/unit/layout/test_version.rb +4 -4
- data/test/unit/report/test_base.rb +134 -213
- data/test/unit/report/test_events.rb +4 -4
- data/test/unit/report/test_internal.rb +84 -86
- data/test/unit/test_config.rb +31 -12
- data/test/unit/test_layout.rb +7 -7
- data/test/unit/test_report.rb +12 -24
- data/thinreports.gemspec +18 -22
- metadata +101 -200
- data/LICENSE +0 -1
- data/README.rdoc +0 -166
- data/doc/yardoc_templates/default/layout/html/footer.erb +0 -10
- data/lib/thinreports/core.rb +0 -20
- data/lib/thinreports/core/ext.rb +0 -5
- data/lib/thinreports/core/ext/array.rb +0 -19
- data/lib/thinreports/core/ext/hash.rb +0 -19
- data/lib/thinreports/core/ext/object.rb +0 -25
- data/lib/thinreports/core/format.rb +0 -14
- data/lib/thinreports/core/ordered_hash.rb +0 -39
- data/lib/thinreports/generator/pdf/drawer.rb +0 -16
- data/tasks/doc.rake +0 -12
- data/tasks/test.rake +0 -56
- data/test/benchmark/basic_estimate.tlf +0 -1
- data/test/benchmark/bench_basic_estimate.rb +0 -95
- data/test/case/character_spacing/character_spacing.rb +0 -8
- data/test/case/character_spacing/character_spacing.tlf +0 -1
- data/test/case/dynamic_image/dynamic_image.rb +0 -41
- data/test/case/dynamic_image/dynamic_image.tlf +0 -1
- data/test/case/dynamic_style/dynamic_style.rb +0 -154
- data/test/case/dynamic_style/dynamic_style.tlf +0 -1
- data/test/case/dynamic_style/dynamic_style_in_list.tlf +0 -1
- data/test/case/eudc/eudc.rb +0 -20
- data/test/case/eudc/eudc.tlf +0 -1
- data/test/case/hidden_shapes/hidden_shapes.rb +0 -9
- data/test/case/hidden_shapes/hidden_shapes.tlf +0 -1
- data/test/case/list_events/list_events.rb +0 -32
- data/test/case/list_events/list_events.tlf +0 -1
- data/test/case/list_manual_generation/list_manual_generation.tlf +0 -1
- data/test/case/list_page_number/list_page_number.tlf +0 -1
- data/test/case/page_number/page_number.rb +0 -33
- data/test/case/page_number/page_number.tlf +0 -1
- data/test/case/password_setting/password_setting.rb +0 -10
- data/test/case/password_setting/password_setting.tlf +0 -1
- data/test/case/single_line_tblock/single_line_tblock.tlf +0 -1
- data/test/case/tblock_overflow/tblock_overflow.rb +0 -20
- data/test/case/tblock_overflow/tblock_overflow.tlf +0 -1
- data/test/case/tblock_styles/tblock_styles.rb +0 -27
- data/test/case/tblock_styles/tblock_styles.tlf +0 -1
- data/test/case/text_align/text_align.rb +0 -8
- data/test/case/text_align/text_align.tlf +0 -1
- data/test/case/typeB_page_size/B4_ISO.tlf +0 -1
- data/test/case/typeB_page_size/B4_JIS.tlf +0 -1
- data/test/case/word_wrap/word_wrap.rb +0 -26
- data/test/case/word_wrap/word_wrap.tlf +0 -1
- data/test/unit/core/ext/array_spec.rb +0 -29
- data/test/unit/core/ext/hash_spec.rb +0 -29
- data/test/unit/core/ext/object_spec.rb +0 -30
- data/test/unit/core/ordered_hash_spec.rb +0 -51
- data/test/unit/core/shape/base/test_interface.rb +0 -52
- data/test/unit/core/utils_spec.rb +0 -56
- data/test/unit/data/basic_layout1.tlf +0 -1
- data/test/unit/data/basic_layout2.tlf +0 -1
- data/test/unit/data/basic_list_layout.tlf +0 -1
- data/test/unit/data/basic_list_noheader_layout.tlf +0 -1
- data/test/unit/helper.rb +0 -87
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
include
|
|
5
|
+
class Thinreports::Core::Shape::PageNumber::TestFormat < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
8
|
TEST_PAGENO_FORMAT = {
|
|
9
9
|
"type" => "s-pageno",
|
|
@@ -37,7 +37,7 @@ class ThinReports::Core::Shape::PageNumber::TestFormat < MiniTest::Unit::TestCas
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
Format =
|
|
40
|
+
Format = Thinreports::Core::Shape::PageNumber::Format
|
|
41
41
|
|
|
42
42
|
def format(raw_format = nil)
|
|
43
43
|
Format.new(raw_format || TEST_PAGENO_FORMAT)
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
include
|
|
5
|
+
class Thinreports::Core::Shape::PageNumber::TestInterface < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
|
-
PageNumber =
|
|
8
|
+
PageNumber = Thinreports::Core::Shape::PageNumber
|
|
9
9
|
|
|
10
|
-
def
|
|
11
|
-
|
|
10
|
+
def create_pageno(format = {})
|
|
11
|
+
report = new_report 'layout_text1'
|
|
12
|
+
parent = report.start_new_page
|
|
13
|
+
|
|
14
|
+
PageNumber::Interface.new parent, PageNumber::Format.new(format)
|
|
12
15
|
end
|
|
13
16
|
|
|
14
17
|
def test_format
|
|
15
|
-
pageno =
|
|
18
|
+
pageno = create_pageno 'format' => '{page}'
|
|
16
19
|
|
|
17
20
|
assert_equal pageno.format, '{page}'
|
|
18
21
|
pageno.format('{page} / {total}')
|
|
@@ -20,7 +23,7 @@ class ThinReports::Core::Shape::PageNumber::TestInterface < MiniTest::Unit::Test
|
|
|
20
23
|
end
|
|
21
24
|
|
|
22
25
|
def test_reset_format
|
|
23
|
-
pageno =
|
|
26
|
+
pageno = create_pageno 'format' => '{page}'
|
|
24
27
|
|
|
25
28
|
pageno.format('-- {page} --')
|
|
26
29
|
pageno.reset_format
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
include
|
|
5
|
+
class Thinreports::Core::Shape::PageNumber::TestInternal < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
|
-
PageNumber =
|
|
8
|
+
PageNumber = Thinreports::Core::Shape::PageNumber
|
|
9
9
|
|
|
10
10
|
def setup
|
|
11
|
-
@report =
|
|
11
|
+
@report = new_report('layout_text1.tlf')
|
|
12
12
|
@report.start_new_page
|
|
13
13
|
end
|
|
14
14
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
include
|
|
5
|
+
class Thinreports::Core::Shape::Style::TestBase < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
8
|
# Alias
|
|
9
|
-
Style =
|
|
9
|
+
Style = Thinreports::Core::Shape::Style::Base
|
|
10
10
|
|
|
11
11
|
def create_basic_format(attrs = {})
|
|
12
|
-
|
|
12
|
+
Thinreports::Core::Shape::Basic::Format.new('svg' => {'attrs' => attrs})
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def create_style(base = {})
|
|
@@ -178,17 +178,17 @@ class ThinReports::Core::Shape::Style::TestBase < MiniTest::Unit::TestCase
|
|
|
178
178
|
end
|
|
179
179
|
|
|
180
180
|
def test_reader_method_caller_should_raise_when_style_is_not_accessible
|
|
181
|
-
assert_raises
|
|
181
|
+
assert_raises Thinreports::Errors::UnknownShapeStyleName do
|
|
182
182
|
create_new_style[:unknown]
|
|
183
183
|
end
|
|
184
184
|
end
|
|
185
185
|
|
|
186
186
|
def test_writer_method_caller_should_raise_when_style_is_not_accessible
|
|
187
|
-
assert_raises
|
|
187
|
+
assert_raises Thinreports::Errors::UnknownShapeStyleName do
|
|
188
188
|
create_new_style[:unknown] = 'value'
|
|
189
189
|
end
|
|
190
190
|
end
|
|
191
|
-
|
|
191
|
+
|
|
192
192
|
def test_copy_should_return_the_instance_of_the_same_class_as_itself
|
|
193
193
|
style = create_style
|
|
194
194
|
assert_instance_of Style, style.copy
|
|
@@ -216,4 +216,4 @@ class ThinReports::Core::Shape::Style::TestBase < MiniTest::Unit::TestCase
|
|
|
216
216
|
|
|
217
217
|
assert_equal style.identifier, style.styles.hash.to_s
|
|
218
218
|
end
|
|
219
|
-
end
|
|
219
|
+
end
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
include
|
|
5
|
+
class Thinreports::Core::Shape::Style::TestBasic < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
8
|
def create_basic_style(format_config = {})
|
|
9
|
-
format =
|
|
10
|
-
|
|
9
|
+
format = Thinreports::Core::Shape::Basic::Format.new(format_config)
|
|
10
|
+
Thinreports::Core::Shape::Style::Basic.new(format)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def test_visible_should_return_visibility_of_format_as_default
|
|
@@ -1,69 +1,55 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::Style::TestGraphic < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
4
7
|
|
|
5
|
-
class ThinReports::Core::Shape::Style::TestGraphic < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
8
|
def create_graphic_style
|
|
9
|
-
format =
|
|
10
|
-
|
|
9
|
+
format = Thinreports::Core::Shape::Basic::Format.new({})
|
|
10
|
+
Thinreports::Core::Shape::Style::Graphic.new(format)
|
|
11
11
|
end
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
def test_border_color_should_properly_set_to_internal_styles_as_stroke_style
|
|
14
14
|
style = create_graphic_style
|
|
15
15
|
style.border_color = '#ff0000'
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
assert_equal style.styles['stroke'], '#ff0000'
|
|
18
18
|
end
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
def test_border_width_should_properly_set_to_internal_styles_as_stroke_width_style
|
|
21
21
|
style = create_graphic_style
|
|
22
22
|
style.border_width = 1
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
assert_equal style.styles['stroke-width'], 1
|
|
25
25
|
end
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
def test_border_width_should_set_stroke_opacity_to_1_when_width_is_not_zero
|
|
28
28
|
style = create_graphic_style
|
|
29
29
|
style.border_width = 5
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
assert_equal style.styles['stroke-opacity'], '1'
|
|
32
32
|
end
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
def test_fill_color_should_properly_set_to_internal_styles_as_fill_style
|
|
35
35
|
style = create_graphic_style
|
|
36
36
|
style.fill_color = '#0000ff'
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
assert_equal style.styles['fill'], '#0000ff'
|
|
39
39
|
end
|
|
40
|
-
|
|
41
|
-
def test_fill_should_operate_like_the_fill_color_method
|
|
42
|
-
style = create_graphic_style
|
|
43
|
-
style.fill = '#ff0000'
|
|
44
|
-
|
|
45
|
-
assert_same style.fill_color, style.fill
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def test_stroke_should_operate_like_the_border_width_method
|
|
49
|
-
style = create_graphic_style
|
|
50
|
-
style.stroke = 5
|
|
51
|
-
|
|
52
|
-
assert_same style.border_width, style.stroke
|
|
53
|
-
end
|
|
54
|
-
|
|
40
|
+
|
|
55
41
|
def test_border_should_return_an_Array_included_border_width_and_border_color
|
|
56
42
|
style = create_graphic_style
|
|
57
43
|
style.border_width = 1
|
|
58
44
|
style.border_color = '#ff0000'
|
|
59
|
-
|
|
45
|
+
|
|
60
46
|
assert_equal style.border, [style.border_width, style.border_color]
|
|
61
47
|
end
|
|
62
|
-
|
|
48
|
+
|
|
63
49
|
def test_border_should_properly_set_both_border_width_and_border_color_from_the_specified_array_argument
|
|
64
50
|
style = create_graphic_style
|
|
65
51
|
style.border = [5, '#000000']
|
|
66
|
-
|
|
52
|
+
|
|
67
53
|
assert_equal style.border, [5, '#000000']
|
|
68
54
|
end
|
|
69
|
-
end
|
|
55
|
+
end
|
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
include
|
|
5
|
+
class Thinreports::Core::Shape::Style::TestText < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
8
|
def create_format(format = {})
|
|
9
|
-
|
|
9
|
+
Thinreports::Core::Shape::Text::Format.new(format)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def create_text_style(format = nil)
|
|
13
13
|
format ||= create_format
|
|
14
|
-
|
|
14
|
+
Thinreports::Core::Shape::Style::Text.new(format)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def test_font_size
|
|
18
|
+
format = create_format('svg' => {'attrs' => {'font-size' => '12'}})
|
|
19
|
+
style = create_text_style(format)
|
|
20
|
+
|
|
21
|
+
assert_equal style.font_size, '12'
|
|
22
|
+
|
|
23
|
+
style.font_size = 19
|
|
24
|
+
|
|
25
|
+
assert_equal style.styles['font-size'], 19
|
|
15
26
|
end
|
|
16
27
|
|
|
17
28
|
def test_bold_should_return_true_when_font_weight_property_of_format_is_bold
|
|
@@ -304,7 +315,7 @@ class ThinReports::Core::Shape::Style::TestText < MiniTest::Unit::TestCase
|
|
|
304
315
|
end
|
|
305
316
|
|
|
306
317
|
def test_initialize
|
|
307
|
-
klass = Class.new(
|
|
318
|
+
klass = Class.new(Thinreports::Core::Shape::Style::Text)
|
|
308
319
|
klass.class_eval do
|
|
309
320
|
accessible_styles.delete(:valign)
|
|
310
321
|
end
|
|
@@ -326,4 +337,4 @@ class ThinReports::Core::Shape::Style::TestText < MiniTest::Unit::TestCase
|
|
|
326
337
|
assert_equal style.identifier,
|
|
327
338
|
style.send(:create_identifier, style.styles) + 'bottom'
|
|
328
339
|
end
|
|
329
|
-
end
|
|
340
|
+
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
include
|
|
5
|
+
class Thinreports::Core::Shape::Text::TestFormat < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
8
|
TEST_TEXT_FORMAT = {
|
|
9
9
|
"type" => "s-text",
|
|
@@ -44,14 +44,14 @@ class ThinReports::Core::Shape::Text::TestFormat < MiniTest::Unit::TestCase
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
# Alias
|
|
47
|
-
Format =
|
|
47
|
+
Format = Thinreports::Core::Shape::Text::Format
|
|
48
48
|
|
|
49
49
|
def test_build_format
|
|
50
50
|
build_format
|
|
51
51
|
rescue => e
|
|
52
52
|
flunk exception_details(e, 'Building failed.')
|
|
53
53
|
end
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
def test_config_readers
|
|
56
56
|
format = Format.new(TEST_TEXT_FORMAT)
|
|
57
57
|
|
|
@@ -70,4 +70,4 @@ class ThinReports::Core::Shape::Text::TestFormat < MiniTest::Unit::TestCase
|
|
|
70
70
|
def build_format
|
|
71
71
|
Format.build(TEST_TEXT_FORMAT)
|
|
72
72
|
end
|
|
73
|
-
end
|
|
73
|
+
end
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
include
|
|
5
|
+
class Thinreports::Core::Shape::Text::TestInternal < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
|
-
Text =
|
|
8
|
+
Text = Thinreports::Core::Shape::Text
|
|
9
9
|
|
|
10
|
-
def
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@internal = Text::Internal.new(flexmock('parent'), format)
|
|
10
|
+
def create_internal(format_config = {})
|
|
11
|
+
report = new_report('layout_text1.tlf')
|
|
12
|
+
Text::Internal.new(report.start_new_page, Text::Format.new(format_config))
|
|
15
13
|
end
|
|
16
14
|
|
|
17
15
|
def test_type_of?
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
assert create_internal.type_of?(:text), true
|
|
17
|
+
refute create_internal.type_of?(:basic), false
|
|
20
18
|
end
|
|
21
|
-
|
|
19
|
+
|
|
20
|
+
end
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::TextBlock::Formatter::TestBasic < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
4
7
|
|
|
5
|
-
class ThinReports::Core::Shape::TextBlock::Formatter::TestBasic < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
8
|
# Alias
|
|
9
|
-
Formatter =
|
|
10
|
-
|
|
9
|
+
Formatter = Thinreports::Core::Shape::TextBlock::Formatter::Basic
|
|
10
|
+
|
|
11
11
|
def test_apply_simple_format
|
|
12
|
-
format =
|
|
13
|
-
|
|
14
|
-
assert_equal Formatter.new(format).apply('
|
|
15
|
-
'Hello
|
|
12
|
+
format = stub(format_base: 'Hello {value}!')
|
|
13
|
+
|
|
14
|
+
assert_equal Formatter.new(format).apply('Thinreports'),
|
|
15
|
+
'Hello Thinreports!'
|
|
16
16
|
end
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
def test_apply_multiple_format
|
|
19
|
-
format =
|
|
20
|
-
|
|
21
|
-
assert_equal Formatter.new(format).apply('
|
|
22
|
-
'Hello
|
|
19
|
+
format = stub(format_base: 'Hello {value}! And good bye {value}.')
|
|
20
|
+
|
|
21
|
+
assert_equal Formatter.new(format).apply('Thinreports'),
|
|
22
|
+
'Hello Thinreports! And good bye Thinreports.'
|
|
23
23
|
end
|
|
24
|
-
end
|
|
24
|
+
end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
4
|
|
|
5
|
-
class
|
|
6
|
-
include
|
|
5
|
+
class Thinreports::Core::Shape::TextBlock::Formatter::TestDatetime < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
7
7
|
|
|
8
8
|
# Aliases
|
|
9
|
-
TextBlock =
|
|
9
|
+
TextBlock = Thinreports::Core::Shape::TextBlock
|
|
10
10
|
Formatter = TextBlock::Formatter::Datetime
|
|
11
11
|
|
|
12
12
|
def setup
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Core::Shape::TextBlock::Formatter::TestNumber < Minitest::Test
|
|
6
|
+
include Thinreports::TestHelper
|
|
4
7
|
|
|
5
|
-
class ThinReports::Core::Shape::TextBlock::Formatter::TestNumber < MiniTest::Unit::TestCase
|
|
6
|
-
include ThinReports::TestHelpers
|
|
7
|
-
|
|
8
8
|
# Alias
|
|
9
|
-
Formatter =
|
|
10
|
-
|
|
9
|
+
Formatter = Thinreports::Core::Shape::TextBlock::Formatter::Number
|
|
10
|
+
|
|
11
11
|
def init_formatter(expect_formats)
|
|
12
|
-
format =
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
format = stub({ format_base: '',
|
|
13
|
+
format_number_precision: nil,
|
|
14
|
+
format_number_delimiter: nil }.merge(expect_formats))
|
|
15
15
|
Formatter.new(format)
|
|
16
16
|
end
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
def test_apply_precision_formats
|
|
19
19
|
# When precision is 2
|
|
20
|
-
formatter = init_formatter(:
|
|
21
|
-
|
|
20
|
+
formatter = init_formatter(format_number_precision: 2)
|
|
21
|
+
|
|
22
22
|
assert_equal formatter.apply(1.005), '1.01'
|
|
23
23
|
assert_equal formatter.apply(1.004), '1.00'
|
|
24
24
|
assert_equal formatter.apply(1), '1.00'
|
|
@@ -28,49 +28,49 @@ class ThinReports::Core::Shape::TextBlock::Formatter::TestNumber < MiniTest::Uni
|
|
|
28
28
|
assert_equal formatter.apply('9'), '9.00'
|
|
29
29
|
# Cannot apply, Return the raw value
|
|
30
30
|
assert_equal formatter.apply('invalid value'), 'invalid value'
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
# When precision is 0
|
|
33
|
-
formatter = init_formatter(:
|
|
34
|
-
|
|
33
|
+
formatter = init_formatter(format_number_precision: 0)
|
|
34
|
+
|
|
35
35
|
assert_equal formatter.apply(1.5), '2'
|
|
36
36
|
end
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
def test_apply_precision_format_with_basic_format
|
|
39
|
-
formatter = init_formatter(:
|
|
40
|
-
:
|
|
41
|
-
|
|
39
|
+
formatter = init_formatter(format_base: '$ {value}',
|
|
40
|
+
format_number_precision: 0)
|
|
41
|
+
|
|
42
42
|
assert_equal formatter.apply(199.5), '$ 200'
|
|
43
43
|
end
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
def test_apply_delimiter_formats
|
|
46
46
|
# When delimiter is ','
|
|
47
|
-
formatter = init_formatter(:
|
|
48
|
-
|
|
47
|
+
formatter = init_formatter(format_number_delimiter: ',')
|
|
48
|
+
|
|
49
49
|
assert_equal formatter.apply(1000000), '1,000,000'
|
|
50
50
|
assert_equal formatter.apply(-1000000), '-1,000,000'
|
|
51
51
|
assert_equal formatter.apply('1000.0'), '1,000.0'
|
|
52
52
|
assert_equal formatter.apply('-1000.0'), '-1,000.0'
|
|
53
53
|
# Cannot apply, Return the raw value
|
|
54
54
|
assert_equal formatter.apply('invalid value'), 'invalid value'
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
# When delimiter is whitespace
|
|
57
|
-
formatter = init_formatter(:
|
|
58
|
-
|
|
57
|
+
formatter = init_formatter(format_number_delimiter: ' ')
|
|
58
|
+
|
|
59
59
|
assert_equal formatter.apply(99999), '99 999'
|
|
60
60
|
end
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
def test_apply_delimiter_format_with_basic_format
|
|
63
|
-
formatter = init_formatter(:
|
|
64
|
-
:
|
|
65
|
-
|
|
63
|
+
formatter = init_formatter(format_base: '¥{value}',
|
|
64
|
+
format_number_delimiter: ',')
|
|
65
|
+
|
|
66
66
|
assert_equal formatter.apply(199800), '¥199,800'
|
|
67
67
|
end
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
def test_apply_all_format
|
|
70
|
-
formatter = init_formatter(:
|
|
71
|
-
:
|
|
72
|
-
:
|
|
70
|
+
formatter = init_formatter(format_base: '-- {value} --',
|
|
71
|
+
format_number_delimiter: ',',
|
|
72
|
+
format_number_precision: 2)
|
|
73
73
|
|
|
74
74
|
assert_equal formatter.apply(95618.88567), '-- 95,618.89 --'
|
|
75
75
|
end
|
|
76
|
-
end
|
|
76
|
+
end
|