thinreports 0.9.1 → 0.10.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/.rubocop.yml +41 -0
- data/.travis.yml +4 -6
- data/CHANGELOG.md +21 -2
- data/Gemfile +2 -4
- data/README.md +4 -5
- data/Rakefile +7 -8
- data/examples/character_spacing/character_spacing.rb +1 -1
- data/examples/dynamic_image/dynamic_image.rb +3 -3
- data/examples/dynamic_style/dynamic_style.rb +1 -1
- data/examples/eudc/eudc.rb +1 -1
- data/examples/helper.rb +2 -2
- data/examples/hidden_shapes/hidden_shapes.rb +1 -1
- data/examples/list_events/list_events.rb +1 -1
- data/examples/list_manual_generation/list_manual_generation.rb +1 -1
- data/examples/list_page_number/list_page_number.rb +1 -1
- data/examples/page_number/page_number.rb +1 -1
- data/examples/palleted_png/palleted_png.rb +1 -3
- data/examples/password_setting/password_setting.rb +1 -1
- data/examples/report_callbacks/report_callbacks.rb +1 -1
- data/examples/single_line_tblock/single_line_tblock.rb +1 -1
- data/examples/tblock_overflow/tblock_overflow.rb +1 -1
- data/examples/tblock_styles/tblock_styles.rb +1 -1
- data/examples/text_align/text_align.rb +1 -1
- data/examples/typeB_page_size/typeB_page_size.rb +1 -1
- data/examples/word_wrap/word_wrap.rb +1 -1
- data/lib/thinreports.rb +16 -15
- data/lib/thinreports/config.rb +2 -24
- data/lib/thinreports/core/errors.rb +6 -17
- data/lib/thinreports/core/format/base.rb +62 -61
- data/lib/thinreports/core/shape.rb +13 -14
- data/lib/thinreports/core/shape/base.rb +3 -12
- data/lib/thinreports/core/shape/base/interface.rb +35 -32
- data/lib/thinreports/core/shape/base/internal.rb +45 -43
- data/lib/thinreports/core/shape/basic.rb +12 -12
- data/lib/thinreports/core/shape/basic/block_format.rb +8 -6
- data/lib/thinreports/core/shape/basic/block_interface.rb +24 -22
- data/lib/thinreports/core/shape/basic/block_internal.rb +28 -26
- data/lib/thinreports/core/shape/basic/format.rb +11 -9
- data/lib/thinreports/core/shape/basic/interface.rb +79 -77
- data/lib/thinreports/core/shape/basic/internal.rb +17 -14
- data/lib/thinreports/core/shape/image_block.rb +9 -9
- data/lib/thinreports/core/shape/image_block/format.rb +7 -5
- data/lib/thinreports/core/shape/image_block/interface.rb +15 -13
- data/lib/thinreports/core/shape/image_block/internal.rb +10 -8
- data/lib/thinreports/core/shape/list.rb +13 -13
- data/lib/thinreports/core/shape/list/format.rb +83 -77
- data/lib/thinreports/core/shape/list/manager.rb +182 -176
- data/lib/thinreports/core/shape/list/page.rb +94 -93
- data/lib/thinreports/core/shape/list/page_state.rb +42 -40
- data/lib/thinreports/core/shape/list/section_format.rb +28 -26
- data/lib/thinreports/core/shape/list/section_interface.rb +42 -40
- data/lib/thinreports/core/shape/list/section_internal.rb +21 -19
- data/lib/thinreports/core/shape/manager.rb +4 -13
- data/lib/thinreports/core/shape/manager/format.rb +21 -19
- data/lib/thinreports/core/shape/manager/internal.rb +88 -84
- data/lib/thinreports/core/shape/manager/target.rb +93 -95
- data/lib/thinreports/core/shape/page_number.rb +9 -9
- data/lib/thinreports/core/shape/page_number/format.rb +20 -18
- data/lib/thinreports/core/shape/page_number/interface.rb +20 -18
- data/lib/thinreports/core/shape/page_number/internal.rb +47 -44
- data/lib/thinreports/core/shape/style.rb +5 -14
- data/lib/thinreports/core/shape/style/base.rb +121 -120
- data/lib/thinreports/core/shape/style/basic.rb +12 -10
- data/lib/thinreports/core/shape/style/graphic.rb +35 -33
- data/lib/thinreports/core/shape/style/text.rb +113 -107
- data/lib/thinreports/core/shape/text.rb +9 -9
- data/lib/thinreports/core/shape/text/format.rb +10 -9
- data/lib/thinreports/core/shape/text/interface.rb +13 -11
- data/lib/thinreports/core/shape/text/internal.rb +14 -12
- data/lib/thinreports/core/shape/text_block.rb +10 -10
- data/lib/thinreports/core/shape/text_block/format.rb +35 -33
- data/lib/thinreports/core/shape/text_block/formatter.rb +26 -24
- data/lib/thinreports/core/shape/text_block/formatter/basic.rb +25 -25
- data/lib/thinreports/core/shape/text_block/formatter/datetime.rb +15 -12
- data/lib/thinreports/core/shape/text_block/formatter/number.rb +45 -39
- data/lib/thinreports/core/shape/text_block/formatter/padding.rb +17 -14
- data/lib/thinreports/core/shape/text_block/interface.rb +25 -23
- data/lib/thinreports/core/shape/text_block/internal.rb +68 -68
- data/lib/thinreports/core/utils.rb +4 -3
- data/lib/thinreports/generator/pdf.rb +24 -25
- data/lib/thinreports/generator/pdf/document.rb +109 -110
- data/lib/thinreports/generator/pdf/document/draw_shape.rb +58 -51
- data/lib/thinreports/generator/pdf/document/draw_template_items.rb +51 -47
- data/lib/thinreports/generator/pdf/document/font.rb +62 -59
- data/lib/thinreports/generator/pdf/document/graphics.rb +32 -33
- data/lib/thinreports/generator/pdf/document/graphics/attributes.rb +122 -121
- data/lib/thinreports/generator/pdf/document/graphics/basic.rb +113 -114
- data/lib/thinreports/generator/pdf/document/graphics/image.rb +58 -150
- data/lib/thinreports/generator/pdf/document/graphics/text.rb +152 -137
- data/lib/thinreports/generator/pdf/document/page.rb +63 -64
- data/lib/thinreports/generator/pdf/document/parse_color.rb +37 -37
- data/lib/thinreports/generator/pdf/drawer/base.rb +41 -41
- data/lib/thinreports/generator/pdf/drawer/list.rb +48 -45
- data/lib/thinreports/generator/pdf/drawer/list_section.rb +42 -40
- data/lib/thinreports/generator/pdf/drawer/page.rb +101 -96
- data/lib/thinreports/generator/pdf/prawn_ext.rb +4 -30
- data/lib/thinreports/generator/pdf/prawn_ext/calc_image_dimensions.rb +34 -0
- data/lib/thinreports/generator/pdf/prawn_ext/width_of.rb +29 -0
- data/lib/thinreports/layout.rb +5 -7
- data/lib/thinreports/layout/base.rb +5 -7
- data/lib/thinreports/layout/format.rb +18 -13
- data/lib/thinreports/layout/legacy_schema.rb +18 -10
- data/lib/thinreports/layout/version.rb +22 -25
- data/lib/thinreports/report.rb +4 -6
- data/lib/thinreports/report/base.rb +24 -51
- data/lib/thinreports/report/internal.rb +9 -11
- data/lib/thinreports/report/page.rb +5 -6
- data/lib/thinreports/version.rb +2 -2
- data/test/schema_helper.rb +4 -3
- data/test/test_helper.rb +9 -3
- data/test/unit/core/format/test_base.rb +1 -1
- data/test/unit/core/shape/base/test_internal.rb +1 -1
- data/test/unit/core/shape/basic/test_block_format.rb +1 -1
- data/test/unit/core/shape/basic/test_block_interface.rb +1 -1
- data/test/unit/core/shape/basic/test_block_internal.rb +1 -1
- data/test/unit/core/shape/basic/test_format.rb +1 -1
- data/test/unit/core/shape/basic/test_interface.rb +1 -1
- data/test/unit/core/shape/basic/test_internal.rb +1 -1
- data/test/unit/core/shape/image_block/test_interface.rb +1 -1
- data/test/unit/core/shape/image_block/test_internal.rb +1 -1
- data/test/unit/core/shape/list/test_format.rb +1 -1
- data/test/unit/core/shape/list/test_manager.rb +4 -4
- data/test/unit/core/shape/list/test_page.rb +1 -1
- data/test/unit/core/shape/list/test_page_state.rb +1 -1
- data/test/unit/core/shape/list/test_section_format.rb +1 -1
- data/test/unit/core/shape/list/test_section_interface.rb +2 -2
- data/test/unit/core/shape/list/test_section_internal.rb +1 -1
- data/test/unit/core/shape/manager/test_format.rb +2 -2
- data/test/unit/core/shape/manager/test_internal.rb +3 -3
- data/test/unit/core/shape/manager/test_target.rb +1 -1
- data/test/unit/core/shape/page_number/test_format.rb +1 -1
- data/test/unit/core/shape/page_number/test_interface.rb +1 -1
- data/test/unit/core/shape/page_number/test_internal.rb +1 -1
- data/test/unit/core/shape/styles/test_base.rb +1 -1
- data/test/unit/core/shape/styles/test_basic.rb +1 -1
- data/test/unit/core/shape/styles/test_graphic.rb +1 -1
- data/test/unit/core/shape/styles/test_text.rb +1 -1
- data/test/unit/core/shape/text/test_format.rb +1 -1
- data/test/unit/core/shape/text/test_internal.rb +1 -1
- data/test/unit/core/shape/text_block/formatter/test_basic.rb +1 -1
- data/test/unit/core/shape/text_block/formatter/test_datetime.rb +1 -1
- data/test/unit/core/shape/text_block/formatter/test_number.rb +1 -1
- data/test/unit/core/shape/text_block/formatter/test_padding.rb +2 -2
- data/test/unit/core/shape/text_block/test_format.rb +1 -1
- data/test/unit/core/shape/text_block/test_formatter.rb +1 -1
- data/test/unit/core/shape/text_block/test_interface.rb +1 -1
- data/test/unit/core/shape/text_block/test_internal.rb +3 -3
- data/test/unit/core/test_shape.rb +1 -1
- data/test/unit/core/test_utils.rb +2 -2
- data/test/unit/generator/pdf/document/graphics/test_attributes.rb +1 -1
- data/test/unit/generator/pdf/document/graphics/test_basic.rb +2 -1
- data/test/unit/generator/pdf/document/graphics/test_image.rb +27 -131
- data/test/unit/generator/pdf/document/graphics/test_text.rb +1 -1
- data/test/unit/generator/pdf/document/test_font.rb +2 -2
- data/test/unit/generator/pdf/document/test_graphics.rb +1 -1
- data/test/unit/generator/pdf/document/test_page.rb +7 -7
- data/test/unit/generator/pdf/document/test_parse_color.rb +1 -1
- data/test/unit/generator/pdf/prawn_ext/test_calc_image_dimensions.rb +41 -0
- data/test/unit/generator/pdf/prawn_ext/test_width_of.rb +22 -0
- data/test/unit/generator/pdf/test_document.rb +8 -6
- data/test/unit/generator/test_pdf.rb +12 -10
- data/test/unit/layout/test_base.rb +1 -1
- data/test/unit/layout/test_format.rb +2 -2
- data/test/unit/layout/test_legacy_schema.rb +4 -4
- data/test/unit/layout/test_version.rb +11 -80
- data/test/unit/report/test_base.rb +45 -59
- data/test/unit/report/test_internal.rb +1 -1
- data/test/unit/test_config.rb +1 -16
- data/test/unit/test_layout.rb +1 -1
- data/test/unit/test_report.rb +1 -1
- data/thinreports.gemspec +11 -14
- metadata +42 -103
- data/lib/thinreports/generator.rb +0 -29
- data/lib/thinreports/generator/base.rb +0 -40
- data/lib/thinreports/generator/configuration.rb +0 -31
- data/lib/thinreports/report/events.rb +0 -32
- data/test/unit/generator/test_base.rb +0 -40
- data/test/unit/generator/test_configuration.rb +0 -21
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'test_helper'
|
|
4
4
|
|
|
@@ -26,7 +26,7 @@ class Thinreports::Generator::PDF::TestFont < Minitest::Test
|
|
|
26
26
|
pdf.font_families[original_font]
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
-
assert_equal Font::DEFAULT_FALLBACK_FONTS,
|
|
29
|
+
assert_equal Font::DEFAULT_FALLBACK_FONTS, %w[IPAMincho]
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def test_setup_fonts_with_custom_fallback_fonts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'test_helper'
|
|
4
4
|
|
|
@@ -9,20 +9,20 @@ class Thinreports::Generator::PDF::Document::TestPage < Minitest::Test
|
|
|
9
9
|
@pdf = Thinreports::Generator::PDF::Document.new
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def
|
|
13
|
-
|
|
14
|
-
assert_equal
|
|
15
|
-
assert_equal
|
|
12
|
+
def test_JIS_page_size
|
|
13
|
+
sizes = Thinreports::Generator::PDF::Document::JIS_SIZES
|
|
14
|
+
assert_equal sizes['B4'], [728.5, 1031.8]
|
|
15
|
+
assert_equal sizes['B5'], [515.9, 728.5]
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def
|
|
18
|
+
def test_B4_paper_size_should_returns_size_as_B4_JIS
|
|
19
19
|
create_pdf
|
|
20
20
|
|
|
21
21
|
format = Thinreports::Layout::Format.build(layout_file.path)
|
|
22
22
|
format.stubs(page_paper_type: 'B4')
|
|
23
23
|
|
|
24
24
|
@pdf.start_new_page(format)
|
|
25
|
-
assert_equal @pdf.internal.page.size,
|
|
25
|
+
assert_equal @pdf.internal.page.size, [728.5, 1031.8]
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def test_B4_ISO_paper_size_should_be_converted_to_B4
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Generator::PrawnExt::TestCalcImageDimensions < Minitest::Test
|
|
6
|
+
class Klass
|
|
7
|
+
prepend Thinreports::Generator::PrawnExt::CalcImageDimensions
|
|
8
|
+
|
|
9
|
+
def calc_image_dimensions(options)
|
|
10
|
+
options
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def setup
|
|
15
|
+
@klass = Klass.new
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_calc_image_dimensions
|
|
19
|
+
res_options = @klass.calc_image_dimensions(
|
|
20
|
+
auto_fit: [100, 200],
|
|
21
|
+
width: 101,
|
|
22
|
+
height: 199
|
|
23
|
+
)
|
|
24
|
+
assert_equal [100, 200], res_options[:fit]
|
|
25
|
+
refute_includes res_options.keys, :auto_fit
|
|
26
|
+
|
|
27
|
+
res_options = @klass.calc_image_dimensions(
|
|
28
|
+
auto_fit: [100, 200],
|
|
29
|
+
width: 99,
|
|
30
|
+
height: 201
|
|
31
|
+
)
|
|
32
|
+
assert_equal [100, 200], res_options[:fit]
|
|
33
|
+
|
|
34
|
+
res_options = @klass.calc_image_dimensions(
|
|
35
|
+
auto_fit: [100, 200],
|
|
36
|
+
width: 99,
|
|
37
|
+
height: 199
|
|
38
|
+
)
|
|
39
|
+
refute_includes res_options.keys, :fit
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'test_helper'
|
|
4
|
+
|
|
5
|
+
class Thinreports::Generator::PrawnExt::TestWidthOf < Minitest::Test
|
|
6
|
+
def setup
|
|
7
|
+
@pdf = Prawn::Document.new
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def test_width_of
|
|
11
|
+
text_width = @pdf.width_of('abcd')
|
|
12
|
+
|
|
13
|
+
@pdf.character_spacing(1) do
|
|
14
|
+
expected_character_space_width = 1 * 3
|
|
15
|
+
assert_equal text_width + expected_character_space_width, @pdf.width_of('abcd')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
@pdf.character_spacing(1) do
|
|
19
|
+
assert_equal 0, @pdf.width_of('')
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'test_helper'
|
|
4
4
|
|
|
@@ -8,13 +8,15 @@ class Thinreports::Generator::PDF::TestDocument < Minitest::Test
|
|
|
8
8
|
# Alias
|
|
9
9
|
Document = Thinreports::Generator::PDF::Document
|
|
10
10
|
|
|
11
|
-
def
|
|
11
|
+
def test_new
|
|
12
12
|
pdf = Document.new
|
|
13
13
|
assert_equal pdf.internal.page_count, 0
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def test_new_with_zero_margin_canvas
|
|
17
|
-
pdf = Document.new
|
|
18
14
|
assert_equal pdf.internal.page.margins.values, [0, 0, 0, 0]
|
|
15
|
+
|
|
16
|
+
pdf = Document.new(security: { owner_password: 'abc' })
|
|
17
|
+
assert_equal true, pdf.internal.state.encrypt
|
|
18
|
+
|
|
19
|
+
pdf = Document.new(title: 'Title')
|
|
20
|
+
assert_equal 'Title', pdf.internal.state.store.info.data[:Title]
|
|
19
21
|
end
|
|
20
22
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'test_helper'
|
|
4
4
|
|
|
@@ -7,18 +7,20 @@ class Thinreports::Generator::TestPDF < Minitest::Test
|
|
|
7
7
|
|
|
8
8
|
PDF = Thinreports::Generator::PDF
|
|
9
9
|
|
|
10
|
-
def
|
|
10
|
+
def test_default_layout
|
|
11
|
+
layout_filename = layout_file.path
|
|
12
|
+
report = Thinreports::Report.new layout: layout_filename
|
|
13
|
+
|
|
14
|
+
generator = PDF.new report
|
|
15
|
+
assert_equal layout_filename, generator.default_layout.filename
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def test_initialize
|
|
11
19
|
report = Thinreports::Report.new layout: layout_file.path
|
|
12
20
|
report.start_new_page
|
|
13
21
|
|
|
14
|
-
|
|
15
|
-
PDF::Document.define_singleton_method(:new) {|_options, meta|
|
|
16
|
-
actual_pdf_title = meta[:Title]
|
|
17
|
-
}
|
|
18
|
-
PDF.new report, {}
|
|
22
|
+
PDF.new(report)
|
|
19
23
|
|
|
20
|
-
assert_equal
|
|
21
|
-
ensure
|
|
22
|
-
PDF::Document.singleton_class.send(:remove_method, :new)
|
|
24
|
+
assert_equal true, report.finalized?
|
|
23
25
|
end
|
|
24
26
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'test_helper'
|
|
4
4
|
|
|
@@ -27,7 +27,7 @@ class Thinreports::Layout::TestFormat < Minitest::Test
|
|
|
27
27
|
]
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
Shape
|
|
30
|
+
Shape = Thinreports::Core::Shape
|
|
31
31
|
Layout = Thinreports::Layout
|
|
32
32
|
|
|
33
33
|
def test_attribute_readers
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'test_helper'
|
|
3
4
|
|
|
4
5
|
class Thinreports::Layout::TestLegacySchema < Minitest::Test
|
|
@@ -559,11 +560,10 @@ SVG
|
|
|
559
560
|
)
|
|
560
561
|
end
|
|
561
562
|
|
|
562
|
-
def
|
|
563
|
+
def test_cleanup_svg
|
|
563
564
|
svg = '<!--SHAPE{"id":"item1"}SHAPE--><!--LAYOUT<rect id="item2"/>LAYOUT--><!--SHAPE{"id":"item2"}SHAPE-->'
|
|
564
565
|
|
|
565
|
-
layout_legacy_schema.
|
|
566
|
-
assert_equal '<rect id="item2"/>', svg
|
|
566
|
+
assert_equal '<rect id="item2"/>', layout_legacy_schema.cleanup_svg(svg)
|
|
567
567
|
end
|
|
568
568
|
|
|
569
569
|
private
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'test_helper'
|
|
4
4
|
|
|
@@ -8,88 +8,19 @@ class Thinreports::Layout::TestVersion < Minitest::Test
|
|
|
8
8
|
# Alias
|
|
9
9
|
Version = Thinreports::Layout::Version
|
|
10
10
|
|
|
11
|
-
def
|
|
12
|
-
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def test_comparable_version_should_map_pre_to_1_when_the_given_version_is_PRE
|
|
16
|
-
assert_equal Version.comparable_version('0.6.0.pre'), '0.6.0.1'
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def test_comparable_version_should_map_pre2_to_2_when_the_given_version_is_PRE2
|
|
20
|
-
assert_equal Version.comparable_version('0.6.0.pre2'), '0.6.0.2'
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def test_compare_with_equal_rule_should_return_true_when_the_given_version_is_equal_to_the_version_of_rule
|
|
24
|
-
assert Version.compare('0.7.0', '== 0.7.0')
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def test_compare_with_equal_rule_should_return_false_when_the_given_version_is_not_equal_to_the_version_of_rule
|
|
28
|
-
refute Version.compare('0.6.0.pre3', '== 0.6.0.pre2')
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def test_compare_with_larger_rule_should_return_true_when_the_given_version_is_larger_than_the_version_of_rule
|
|
32
|
-
assert Version.compare('0.7.0', '> 0.6.0.pre3')
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def test_compare_with_larger_rule_should_return_false_when_the_given_version_is_not_larger_than_the_version_of_rule
|
|
36
|
-
refute Version.compare('0.7.0', '> 0.7.0')
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def test_compare_with_one_or_more_rule_should_return_true_when_the_given_version_is_equal_to_the_version_of_rule
|
|
40
|
-
assert Version.compare('0.7.0', '>= 0.7.0')
|
|
41
|
-
end
|
|
11
|
+
def test_compatible?
|
|
12
|
+
Version.stubs(:compatible_rules).returns(['>= 0.8.0', '< 1.0.0'])
|
|
42
13
|
|
|
43
|
-
|
|
44
|
-
assert Version.
|
|
45
|
-
|
|
14
|
+
assert Version.new('0.8.0').compatible?
|
|
15
|
+
assert Version.new('0.9.9').compatible?
|
|
16
|
+
assert Version.new('0.10.0').compatible?
|
|
46
17
|
|
|
47
|
-
|
|
48
|
-
refute Version.
|
|
18
|
+
refute Version.new('0.7.9').compatible?
|
|
19
|
+
refute Version.new('1.0.0').compatible?
|
|
49
20
|
end
|
|
50
21
|
|
|
51
|
-
def
|
|
52
|
-
assert Version.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def test_compare_with_one_or_less_rule_should_return_true_when_the_given_version_is_smaller_than_the_version_of_rule
|
|
56
|
-
assert Version.compare('0.7.0', '<= 0.7.1')
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def test_compare_with_one_or_less_rule_should_return_false_when_the_given_version_is_not_less_than_the_version_of_rule
|
|
60
|
-
refute Version.compare('0.7.0', '<= 0.6.0.pre3')
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def test_inspect_required_rules_should_properly_return_an_inspection_of_rule_when_one_rule_is_given
|
|
64
|
-
required_rules('== 0.6.0') do
|
|
65
|
-
assert_equal Version.inspect_required_rules, '(== 0.6.0)'
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def test_inspect_required_rules_should_properly_return_an_inspection_of_rules_when_multiple_rules_are_given
|
|
70
|
-
required_rules('>= 0.6.0.pre3', '< 0.8.0') do
|
|
71
|
-
assert_equal Version.inspect_required_rules, '(>= 0.6.0.pre3 and < 0.8.0)'
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def test_compatible_asker_should_return_true_when_the_given_version_matches_REEQUIRED_RULES
|
|
76
|
-
required_rules('>= 0.6.0.pre3', '< 0.8.0') do
|
|
77
|
-
assert Version.compatible?('0.7.0')
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def test_compatible_asker_should_return_false_when_the_given_version_does_not_matches_REQUIRED_RULES
|
|
82
|
-
required_rules('>= 0.6.0.pre3', '< 0.8.0') do
|
|
83
|
-
refute Version.compatible?('0.8.0')
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def required_rules(*rules, &block)
|
|
88
|
-
original_required_rules = Version::REQUIRED_RULES.dup
|
|
89
|
-
|
|
90
|
-
Version::REQUIRED_RULES.replace(rules)
|
|
91
|
-
block.call
|
|
92
|
-
ensure
|
|
93
|
-
Version::REQUIRED_RULES.replace(original_required_rules)
|
|
22
|
+
def test_legacy?
|
|
23
|
+
assert Version.new('0.8.9').legacy?
|
|
24
|
+
refute Version.new('0.9.0').legacy?
|
|
94
25
|
end
|
|
95
26
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'test_helper'
|
|
4
4
|
|
|
@@ -118,17 +118,20 @@ class Thinreports::Report::TestBase < Minitest::Test
|
|
|
118
118
|
assert_equal @report.layout(:foo).filename, @layout_file.path
|
|
119
119
|
end
|
|
120
120
|
|
|
121
|
-
def
|
|
122
|
-
report = Report::Base.new
|
|
121
|
+
def test_generate
|
|
122
|
+
report = Report::Base.new(layout: @layout_file.path)
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
generator = mock('generator')
|
|
125
|
+
generator.expects(:generate).with('result.pdf')
|
|
126
126
|
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
Thinreports::Generator::PDF.expects(:new)
|
|
128
|
+
.with(report, { security: { owner_password: 'pass' }})
|
|
129
|
+
.returns(generator)
|
|
129
130
|
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
report.generate(
|
|
132
|
+
filename: 'result.pdf',
|
|
133
|
+
security: { owner_password: 'pass' }
|
|
134
|
+
)
|
|
132
135
|
end
|
|
133
136
|
|
|
134
137
|
def test_page_should_return_the_current_page
|
|
@@ -202,61 +205,44 @@ class Thinreports::Report::TestBase < Minitest::Test
|
|
|
202
205
|
end
|
|
203
206
|
end
|
|
204
207
|
|
|
205
|
-
def test_Base_generate_with_filename
|
|
206
|
-
Report::Base.generate(:pdf, report: { layout: @layout_file.path },
|
|
207
|
-
generator: { filename: temp_path.join('result1.pdf') }) {}
|
|
208
|
-
Report::Base.generate(report: { layout: @layout_file.path },
|
|
209
|
-
generator: { filename: temp_path.join('result2.pdf') }) {}
|
|
210
|
-
|
|
211
|
-
assert_equal temp_path.join('result1.pdf').read,
|
|
212
|
-
temp_path.join('result2.pdf').read
|
|
213
|
-
end
|
|
214
|
-
|
|
215
208
|
def test_Base_generate_should_raise_when_no_block_given
|
|
216
209
|
assert_raises ArgumentError do
|
|
217
210
|
Report::Base.generate(:pdf)
|
|
218
211
|
end
|
|
219
212
|
end
|
|
220
213
|
|
|
221
|
-
def
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
Report::Base.
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
def
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
def test_Base_extract_options_should_return_all_the_values_except_the_report_option_as_a_generator_option
|
|
256
|
-
_report, generator = Report::Base.send(:extract_options!,
|
|
257
|
-
[{report: {layout: 'foo.tlf'}, layout: 'hoge.tlf',
|
|
258
|
-
generator_opt1: 'value1', generator_opt2: 'value2'}])
|
|
259
|
-
assert_equal generator.values_at(:generator_opt1, :generator_opt2),
|
|
260
|
-
['value1', 'value2']
|
|
214
|
+
def test_Base_generate_with_deprecated_arguments
|
|
215
|
+
Report::Base.expects(:create).with(layout: '/path/to/layout.tlf').returns(@report)
|
|
216
|
+
@report.expects(:generate).with(
|
|
217
|
+
filename: 'result.pdf',
|
|
218
|
+
security: { owner_password: 'pass' }
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
Report::Base.generate(
|
|
222
|
+
report: { layout: '/path/to/layout.tlf' },
|
|
223
|
+
generator: {
|
|
224
|
+
filename: 'result.pdf',
|
|
225
|
+
security: { owner_password: 'pass' }
|
|
226
|
+
}
|
|
227
|
+
) { |_| }
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def test_Base_generate_argument_priority
|
|
231
|
+
Report::Base.expects(:create).with(layout: '/path/to/layout.tlf').returns(@report)
|
|
232
|
+
@report.expects(:generate).with(
|
|
233
|
+
filename: 'result.pdf',
|
|
234
|
+
security: { owner_password: 'pass' }
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
Report::Base.generate(
|
|
238
|
+
layout: '/path/to/layout.tlf',
|
|
239
|
+
filename: 'result.pdf',
|
|
240
|
+
security: { owner_password: 'pass' },
|
|
241
|
+
report: { layout: '/path/to/deprecated.tlf' },
|
|
242
|
+
generator: {
|
|
243
|
+
filename: 'deprecated.pdf',
|
|
244
|
+
security: { owner_password: 'deprecated' }
|
|
245
|
+
}
|
|
246
|
+
) { |_| }
|
|
261
247
|
end
|
|
262
248
|
end
|