prawn-disable_word_break 2.2.0 → 2.3.0

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: fe741e9c74de8e63f4652ac96a2c3c67a32ded6d34611396854b06d30aa77b50
4
- data.tar.gz: c99cd3c08e37c7fa0cfde535628214b6d9239f261d394275277fde940261baa6
3
+ metadata.gz: 0ea1ad1bbcf83c99a1fb6f05a484f892700fa89ab49062295980e5c5aa4880b1
4
+ data.tar.gz: 8176b2596ac86a88f501afb75f86c21b5921962f287f3114ec42ddac04d18f93
5
5
  SHA512:
6
- metadata.gz: b62be2f008301e4570d20ed00474d79e2066adc14e2453bd071e982242961d75c8596b5ddc79a73de8b7a3c5a8c4107f5b1009eb7771011eca5b5adaef7f8a15
7
- data.tar.gz: 11923e4ab33f1467bee0aba64e1ef1b3e253c8c1d901bd238b5cd7fdac04e457b98dfe556b80b41843fe555a5b2d75f223a0f3068d29e19c6449e74e2375a40c
6
+ metadata.gz: 2fee79aa17f0d4e96bc4791a472a3ddf5fa01babcfd258093d9aa574dd8d3de6317a3b9e08dce4d88e6bbc26cb51e2880e6132fa017588568e1608aa17d7d99f
7
+ data.tar.gz: 044623aa23ec015bba0487cebf92e9829c036b61f2fa048210f467af92c55d04a0bed3888f9d8eee9564e37a1d359f219a718e64b90067057a171b9f9783ea78
@@ -7,7 +7,8 @@ on:
7
7
 
8
8
  jobs:
9
9
  test:
10
- name: Test on ruby ${{ matrix.ruby_version }} and ${{ matrix.prawn_version }}
10
+ name: Ruby ${{ matrix.ruby_version }}
11
+
11
12
  runs-on: ubuntu-latest
12
13
  strategy:
13
14
  matrix:
@@ -15,12 +16,6 @@ jobs:
15
16
  - '3.0'
16
17
  - '3.1'
17
18
  - '3.2'
18
- prawn_version:
19
- - '2.3'
20
- - '2.4'
21
- exclude:
22
- - ruby_version: '3.0'
23
- prawn_version: '2.3'
24
19
 
25
20
  steps:
26
21
  - uses: actions/checkout@v4
@@ -29,8 +24,7 @@ jobs:
29
24
  with:
30
25
  diff-pdf-version: '0.5'
31
26
 
32
- - name: Set up Ruby ${{ matrix.ruby_version }}
33
- uses: ruby/setup-ruby@v1
27
+ - uses: ruby/setup-ruby@v1
34
28
  with:
35
29
  ruby-version: ${{ matrix.ruby_version }}
36
30
  bundler-cache: true
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/prawn-disable_word_break.svg)](https://badge.fury.io/rb/prawn-disable_word_break)
4
4
  [![Test](https://github.com/hidakatsuya/prawn-disable_word_break/actions/workflows/test.yml/badge.svg)](https://github.com/hidakatsuya/prawn-disable_word_break/actions/workflows/test.yml)
5
5
 
6
- Prawn::DisableWordBreak is an extension that disables word-breaking by character such as space and hyphen to [Prawn](https://github.com/prawnpdf/prawn).
6
+ Prawn::DisableWordBreak is an extension to [Prawn](https://github.com/prawnpdf/prawn) that provides an option to disable line breaking on characters such as spaces and hyphens.
7
7
 
8
8
  ![](https://raw.githubusercontent.com/hidakatsuya/prawn-disable_word_break/master/doc/comparison-of-word-breaking.png)
9
9
 
@@ -31,6 +31,27 @@ Or install it yourself as:
31
31
  require 'prawn/disable_word_break'
32
32
  ```
33
33
 
34
+ Or, you can set it for each method such as `text_box`.
35
+
36
+ ```ruby
37
+ # Disable the default setting.
38
+ Prawn::DisableWordBreak.config.default = false
39
+ ```
40
+
41
+ ```ruby
42
+ Prawn::Document.generate "prawn.pdf" do
43
+ text_box "text",
44
+ at: [0, cursor], width: 150, height: 50, disable_word_break: true
45
+
46
+ formatted_text_box [{ text: "text" }],
47
+ at: [0, cursor], width: 150, height: 50, disable_word_break: true
48
+
49
+ bounding_box [0, cursor], width: 150, height: 50 do
50
+ text "text", disable_word_break: true
51
+ end
52
+ end
53
+ ```
54
+
34
55
  ## Supported Versions
35
56
 
36
57
  ### Ruby
@@ -39,7 +60,7 @@ require 'prawn/disable_word_break'
39
60
 
40
61
  ### Prawn
41
62
 
42
- 2.3, 2.4
63
+ 2.4
43
64
 
44
65
  ## Development
45
66
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Prawn
4
4
  module DisableWordBreak
5
- class LineWrap < Text::Formatted::LineWrap
5
+ class LineBreakAnywhere < Text::Formatted::LineWrap
6
6
  private
7
7
 
8
8
  # Override
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Prawn
4
4
  module DisableWordBreak
5
- VERSION = '2.2.0'
5
+ VERSION = '2.3.0'
6
6
  end
7
7
  end
@@ -1,15 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'line_wrap'
3
+ require_relative 'line_break_anywhere'
4
4
 
5
5
  module Prawn
6
6
  module DisableWordBreak
7
7
  module Wrap
8
8
  # override
9
- def initialize(*)
9
+ def initialize(_, options)
10
10
  super
11
11
 
12
- @line_wrap = DisableWordBreak::LineWrap.new
12
+ @line_wrap = LineBreakAnywhere.new if DisableWordBreak.config.default || options[:disable_word_break]
13
+ end
14
+
15
+ # override
16
+ def valid_options
17
+ super + %i(disable_word_break)
13
18
  end
14
19
  end
15
20
  end
@@ -1,10 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'prawn'
4
+ require 'forwardable'
4
5
 
5
6
  require_relative 'disable_word_break/version'
6
7
  require_relative 'disable_word_break/wrap'
7
8
 
9
+ module Prawn
10
+ module DisableWordBreak
11
+ extend Forwardable
12
+
13
+ Config = Struct.new(
14
+ # Sets the default value for the disable_word_break option. Default is false.
15
+ :default,
16
+
17
+ keyword_init: true
18
+ )
19
+
20
+ def self.config
21
+ @config ||= Config.new(default: false)
22
+ end
23
+ end
24
+ end
25
+
8
26
  Prawn::DisableWordBreak::Wrap.tap do |mod|
9
27
  Prawn::Text::Formatted::Wrap.prepend(mod) unless Prawn::Text::Formatted::Wrap.include?(mod)
10
28
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  end
18
18
  spec.require_paths = ['lib']
19
19
 
20
- spec.add_dependency 'prawn', '~> 2.3'
20
+ spec.add_dependency 'prawn', '>= 2.4.0'
21
21
  spec.add_runtime_dependency 'matrix', '~> 0.4'
22
22
 
23
23
  spec.add_development_dependency 'rake', '>= 0'
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-disable_word_break
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katsuya Hidaka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-12 00:00:00.000000000 Z
11
+ date: 2023-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '2.3'
19
+ version: 2.4.0
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: '2.3'
26
+ version: 2.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: matrix
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -111,7 +111,7 @@ files:
111
111
  - Rakefile
112
112
  - doc/comparison-of-word-breaking.png
113
113
  - lib/prawn/disable_word_break.rb
114
- - lib/prawn/disable_word_break/line_wrap.rb
114
+ - lib/prawn/disable_word_break/line_break_anywhere.rb
115
115
  - lib/prawn/disable_word_break/version.rb
116
116
  - lib/prawn/disable_word_break/wrap.rb
117
117
  - prawn-disable_word_break.gemspec