thinreports 0.14.0 → 0.14.1

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: ca00a89102c8683e9d93b0b9589cdbe9b4ad7d86105de73d22f3de41997d0fa6
4
- data.tar.gz: da3ee5c69c8b74612e18fa22d90e9ae7217111b5847f65f6e89f1f3683cef5f2
3
+ metadata.gz: 0233a79937eb8039a999b9711cef50a013311af86dd0ccde5ce94559af172235
4
+ data.tar.gz: 818dab5e4f71506ed895b2480dddfab7df13d042500322b14d68258af1cfaba8
5
5
  SHA512:
6
- metadata.gz: df0b7b69c44692865e67a2c0a59d4c4620aa88b560ad8d9bd0d6a7005af1d881b49118d76fb63e2e7e51844a882b005c6a53fe9676fe7f5e7a3bb5b2d3b948e6
7
- data.tar.gz: 596814b3d23e600193748ff728ff24e065696661ae3b1104b924516fd1bfa1fb28a79b5d0a341605c3dda0c132d46c2b62770ef3a249312204b90a542a326358
6
+ metadata.gz: 0b1a8a8d67828b3fc901d831cc6087b3dccfbc7b120578a8118ae210d782e6064d80406665e5c0911222cf81ee059692235350cde6f3bcad27bd55d27a2f921f
7
+ data.tar.gz: 8600a21f94a6851e4281c09ff4f3a0eab2db5977f5fa6100770ba6d35e6e29ad46364b0f523298d144d5e4f5006d4349c1af5b1bdaa0d88aef8bfd1926ec52d6
@@ -17,6 +17,7 @@ jobs:
17
17
  - "3.0"
18
18
  - "3.1"
19
19
  - "3.2"
20
+ - "3.3"
20
21
 
21
22
  steps:
22
23
  - uses: actions/checkout@v4
data/CHANGELOG.md CHANGED
@@ -1,13 +1,24 @@
1
1
  ## main (Unreleased)
2
2
 
3
+ ## 0.14.1
4
+
5
+ Enhancements:
6
+
7
+ * Add overflow-wrap option #129
8
+
3
9
  ## 0.14.0
4
10
 
11
+ Breaking Changes:
12
+
5
13
  * Drop Ruby 2.7 support
14
+
15
+ Bug Fixes:
16
+
6
17
  * Fix LoadError: cannot load such file -- matrix #131
7
18
 
8
19
  ## 0.13.1
9
20
 
10
- Bug fixes:
21
+ Bug Fixes:
11
22
 
12
23
  * allow title argument to be specified in Report.generate method #127
13
24
 
data/README.md CHANGED
@@ -9,7 +9,7 @@ A Ruby library for [Thinreports](https://github.com/thinreports/thinreports).
9
9
 
10
10
  ### Supported Versions
11
11
 
12
- - Ruby 3.0, 3.1, 3.2
12
+ - Ruby 3.0, 3.1, 3.2, 3.3
13
13
  - Prawn 2.4+
14
14
 
15
15
  ## Installation
@@ -25,6 +25,8 @@ module Thinreports
25
25
  # @yieldparam [Hash] attrs
26
26
  # @return [Hash]
27
27
  def build_text_attributes(style, &block)
28
+ word_wrap = word_wrap(style['word-wrap'])
29
+
28
30
  text_attributes = {
29
31
  font: font_family(style['font-family']),
30
32
  size: style['font-size'],
@@ -35,12 +37,32 @@ module Thinreports
35
37
  letter_spacing: letter_spacing(style['letter-spacing']),
36
38
  line_height: line_height(style['line-height']),
37
39
  overflow: text_overflow(style['overflow']),
38
- word_wrap: word_wrap(style['word-wrap'])
40
+ word_wrap: word_wrap,
41
+ # Deprecated: Use overflow_wrap instead of word_wrap
42
+ overflow_wrap: overflow_wrap(style['overflow-wrap'], word_wrap)
39
43
  }
40
44
  block.call(text_attributes) if block_given?
41
45
  text_attributes
42
46
  end
43
47
 
48
+ def overflow_wrap(style, computed_word_wrap)
49
+ case style || migrate_overflow_wrap_from_word_wrap(computed_word_wrap)
50
+ when 'normal', nil then :normal
51
+ when 'anywhere' then :anywhere
52
+ # Deprecated: This is a temporary value for migrating from word_wrap.
53
+ when 'disable-break-word-by-space' then :disable_break_word_by_space
54
+ else :normal
55
+ end
56
+ end
57
+
58
+ def migrate_overflow_wrap_from_word_wrap(computed_word_wrap)
59
+ case computed_word_wrap
60
+ when :none then 'disable-break-word-by-space'
61
+ when :break_word then 'normal'
62
+ else raise ArgumentError, 'Invalid computed word_wrap value'
63
+ end
64
+ end
65
+
44
66
  # @param [Array<String>] font_names
45
67
  # @return [String]
46
68
  def font_family(font_names)
@@ -23,6 +23,7 @@ module Thinreports
23
23
  # @option attrs [Boolean] :single (false)
24
24
  # @option attrs [:trancate, :shrink_to_fit, :expand] :overflow (:trancate)
25
25
  # @option attrs [:none, :break_word] :word_wrap (:none)
26
+ # @option attrs [:normal, :anywhere, :disable_break_word_by_space] :overflow_wrap (:normal)
26
27
  def text_box(content, x, y, w, h, attrs = {}, &block)
27
28
  w, h = s2f(w, h)
28
29
 
@@ -32,8 +33,7 @@ module Thinreports
32
33
  overflow: attrs[:overflow]
33
34
  )
34
35
 
35
- # Do not break by word unless :word_wrap is :break_word
36
- content = text_without_line_wrap(content) if attrs[:word_wrap] == :none
36
+ content = replace_space_to_nbsp(content) if attrs[:overflow_wrap] == :disable_break_word_by_space
37
37
 
38
38
  with_text_styles(attrs) do |built_attrs, font_styles|
39
39
  if block
@@ -112,6 +112,12 @@ module Thinreports
112
112
  spacing = attrs.delete(:letter_spacing)
113
113
  attrs[:character_spacing] = s2f(spacing) if spacing
114
114
 
115
+ # Disable line breaking on chars such as spaces and hyphens
116
+ attrs[:disable_word_break] = true if attrs.delete(:overflow_wrap) == :anywhere
117
+
118
+ # Delete unnecessary attributes
119
+ attrs.delete(:word_wrap)
120
+
115
121
  # Or... with_font_styles(attrs, fontinfo, &block)
116
122
  with_font_styles(attrs, fontinfo) do |modified_attrs, styles|
117
123
  block.call(modified_attrs, styles)
@@ -131,7 +137,7 @@ module Thinreports
131
137
 
132
138
  # @param [String] content
133
139
  # @return [String]
134
- def text_without_line_wrap(content)
140
+ def replace_space_to_nbsp(content)
135
141
  content.gsub(/ /, Prawn::Text::NBSP)
136
142
  end
137
143
 
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'prawn'
4
+ require 'prawn/disable_word_break'
5
+
6
+ Prawn::DisableWordBreak.config.default = false
4
7
 
5
8
  module Thinreports
6
9
  module BasicReport
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Thinreports
4
- VERSION = '0.14.0'
4
+ VERSION = '0.14.1'
5
5
  end
data/thinreports.gemspec CHANGED
@@ -24,5 +24,6 @@ Gem::Specification.new do |s|
24
24
 
25
25
  s.add_dependency 'prawn', '>= 2.4.0'
26
26
  s.add_dependency 'matrix', '~> 0.4'
27
+ s.add_dependency 'prawn-disable_word_break', '>= 2.3.1'
27
28
  s.add_dependency 'rexml'
28
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thinreports
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matsukei Co.,Ltd.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-30 00:00:00.000000000 Z
11
+ date: 2023-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: prawn-disable_word_break
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 2.3.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.3.1
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rexml
43
57
  requirement: !ruby/object:Gem::Requirement