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 +4 -4
- data/.github/workflows/test.yml +3 -9
- data/README.md +23 -2
- data/lib/prawn/disable_word_break/{line_wrap.rb → line_break_anywhere.rb} +1 -1
- data/lib/prawn/disable_word_break/version.rb +1 -1
- data/lib/prawn/disable_word_break/wrap.rb +8 -3
- data/lib/prawn/disable_word_break.rb +18 -0
- data/prawn-disable_word_break.gemspec +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ea1ad1bbcf83c99a1fb6f05a484f892700fa89ab49062295980e5c5aa4880b1
|
4
|
+
data.tar.gz: 8176b2596ac86a88f501afb75f86c21b5921962f287f3114ec42ddac04d18f93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fee79aa17f0d4e96bc4791a472a3ddf5fa01babcfd258093d9aa574dd8d3de6317a3b9e08dce4d88e6bbc26cb51e2880e6132fa017588568e1608aa17d7d99f
|
7
|
+
data.tar.gz: 044623aa23ec015bba0487cebf92e9829c036b61f2fa048210f467af92c55d04a0bed3888f9d8eee9564e37a1d359f219a718e64b90067057a171b9f9783ea78
|
data/.github/workflows/test.yml
CHANGED
@@ -7,7 +7,8 @@ on:
|
|
7
7
|
|
8
8
|
jobs:
|
9
9
|
test:
|
10
|
-
name:
|
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
|
-
-
|
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
|
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.
|
63
|
+
2.4
|
43
64
|
|
44
65
|
## Development
|
45
66
|
|
@@ -1,15 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
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
|
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', '
|
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.
|
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-
|
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:
|
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:
|
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/
|
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
|