hexapdf-extras 1.2.0 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 33a96708a4a5370678eefced16946538c63b6a078631d0f5c6b431a997874ff1
4
- data.tar.gz: 82dadc4117398db36f731c1aeb0fe2a360f299a1d4cc19ae039297ec39129efa
3
+ metadata.gz: f67123484ebe9ff4b442a3928cc727d19b7b3e9767536c08775d9f8bbd679d41
4
+ data.tar.gz: 5d7cc27bb1537f22465fb1ca8fd6396629575a4ffec9c49a64c52e7ad0c31d31
5
5
  SHA512:
6
- metadata.gz: 7182df01f81a1712c18e8145ca27f0a2b33fc05b7c1dedc6f725be302029938afb76d35d2d3c08d15145bdf240963b20dcf1e4e641aed450327d704a3f765e45
7
- data.tar.gz: 6473c0cbf68559279f377fdfc2862050d7ebb2ab0521d97c8fe1660321a7636a1a9aed992bc669afac25c8d15f5fbaa9b4b7092a4fff9369afde4bf2ab0fe2aa
6
+ metadata.gz: f717ebe411c150d4da8edafedf19739305d11a18d9e164a3db9f68ef535ba02cdb5374753414f0cd05bbbc92f51547b32cde1eceee845c568c87c3a7be662a00
7
+ data.tar.gz: 25c2b45c6ed7b614c6c32a5b7fdc3f30ed1700162baff8c1b9450ee08b010fea3142ffeab41f7ccf370b71d3c9038ae9a9ec738929bac4fac0229b67d0d2690c
data/Rakefile CHANGED
@@ -11,6 +11,7 @@ end
11
11
 
12
12
  CLOBBER << 'webgen-out'
13
13
  CLOBBER << 'webgen-tmp'
14
+ CLOBBER << 'coverage'
14
15
 
15
16
  task default: 'test'
16
17
 
@@ -27,7 +28,7 @@ task publish_files: [:package] do
27
28
  end
28
29
 
29
30
  task :test_all do
30
- versions = `rbenv versions --bare | grep -i 2.[7]\\\\\\|3.`.split("\n")
31
+ versions = `rbenv versions --bare | grep -i 3.`.split("\n")
31
32
  versions.each do |version|
32
33
  sh "eval \"$(rbenv init -)\"; rbenv shell #{version} && ruby -v && rake test"
33
34
  end
@@ -42,17 +42,16 @@ module HexaPDF
42
42
  )
43
43
  end
44
44
 
45
+ private
46
+
45
47
  # Fits the QRCode into the given area.
46
- def fit(available_width, available_height, _frame)
47
- super
48
+ def fit_content(available_width, available_height, _frame)
48
49
  @qr_code.size = [content_width, content_height].min
49
50
  @width = @qr_code.size + reserved_width
50
51
  @height = @qr_code.size + reserved_height
51
- @fit_successful = (@width <= available_width && @height <= available_height)
52
+ fit_result.success! if @width <= available_width && @height <= available_height
52
53
  end
53
54
 
54
- private
55
-
56
55
  # Draws the QR code onto the canvas at position [x, y].
57
56
  def draw_content(canvas, x, y)
58
57
  @qr_code.at = [x, y]
@@ -404,7 +404,7 @@ module HexaPDF
404
404
 
405
405
  box_fitter.fit(receipt(layout, styles))
406
406
  box_fitter.fit(payment(layout, styles, qr_code_cross(canvas.context.document)))
407
- unless box_fitter.fit_successful?
407
+ unless box_fitter.success?
408
408
  raise HexaPDF::Error, "The Swiss QR-bill could not be fit"
409
409
  end
410
410
 
@@ -43,8 +43,10 @@ module HexaPDF
43
43
  @barcode = GraphicObject::Zint.configure(**data)
44
44
  end
45
45
 
46
+ private
47
+
46
48
  # Fits the barcode into the given area.
47
- def fit(available_width, available_height, frame)
49
+ def fit_content(available_width, available_height, frame)
48
50
  @image ||= @barcode.form_xobject(frame.document)
49
51
  super
50
52
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module HexaPDF
4
4
  module Extras
5
- VERSION = '1.2.0'
5
+ VERSION = '1.2.2'
6
6
  end
7
7
  end
@@ -29,7 +29,7 @@ describe HexaPDF::Extras::Layout::QRCodeBox do
29
29
  it "uses the smaller value of width/height for the dimensions if smaller than available_width/height" do
30
30
  [{width: 10}, {width: 10, height: 50}, {height: 10}, {width: 50, height: 10}].each do |args|
31
31
  box = create_box(**args)
32
- assert(box.fit(100, 100, @frame))
32
+ assert(box.fit(100, 100, @frame).success?)
33
33
  assert_equal(10, box.width)
34
34
  assert_equal(10, box.height)
35
35
  assert_equal(10, box.qr_code.size)
@@ -38,12 +38,12 @@ describe HexaPDF::Extras::Layout::QRCodeBox do
38
38
 
39
39
  it "uses the smaller value of available_width/height for the dimensions" do
40
40
  box = create_box
41
- assert(box.fit(10, 20, @frame))
41
+ assert(box.fit(10, 20, @frame).success?)
42
42
  assert_equal(10, box.width)
43
43
  assert_equal(10, box.height)
44
44
  assert_equal(10, box.qr_code.size)
45
45
 
46
- assert(box.fit(20, 15, @frame))
46
+ assert(box.fit(20, 15, @frame).success?)
47
47
  assert_equal(15, box.width)
48
48
  assert_equal(15, box.height)
49
49
  assert_equal(15, box.qr_code.size)
@@ -51,19 +51,19 @@ describe HexaPDF::Extras::Layout::QRCodeBox do
51
51
 
52
52
  it "takes the border and padding into account for the QR code size" do
53
53
  box = create_box(style: {padding: [1, 2], border: {width: [3, 4]}})
54
- assert(box.fit(100, 100, @frame))
54
+ assert(box.fit(100, 100, @frame).success?)
55
55
  assert_equal(88, box.qr_code.size)
56
56
  assert_equal(100, box.width)
57
57
  assert_equal(96, box.height)
58
58
 
59
59
  box = create_box(style: {padding: [2, 1], border: {width: [4, 3]}})
60
- assert(box.fit(100, 100, @frame))
60
+ assert(box.fit(100, 100, @frame).success?)
61
61
  assert_equal(88, box.qr_code.size)
62
62
  assert_equal(96, box.width)
63
63
  assert_equal(100, box.height)
64
64
 
65
65
  box = create_box(style: {padding: [5, 5, 5, 0], border: {width: [2, 2, 2, 0]}})
66
- assert(box.fit(50, 100, @frame))
66
+ assert(box.fit(50, 100, @frame).success?)
67
67
  assert_equal(43, box.qr_code.size)
68
68
  assert_equal(50, box.width)
69
69
  assert_equal(57, box.height)
@@ -73,7 +73,7 @@ describe HexaPDF::Extras::Layout::QRCodeBox do
73
73
  describe "draw" do
74
74
  it "draws the qrcode" do
75
75
  box = create_box(width: 10)
76
- box.fit(100, 100, @frame)
76
+ assert(box.fit(100, 100, @frame).success?)
77
77
 
78
78
  canvas = Minitest::Mock.new
79
79
  canvas.expect(:draw, nil, [box.qr_code])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hexapdf-extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Leitner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-14 00:00:00.000000000 Z
11
+ date: 2024-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hexapdf
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.42'
19
+ version: '0.44'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.42'
26
+ version: '0.44'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rqrcode_core
29
29
  requirement: !ruby/object:Gem::Requirement