thinreports 0.13.1 → 0.14.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46a5ac716f23028a34055ed5812d6d9704585857378aba29d419144b1657320d
4
- data.tar.gz: c6cbc734f42cc6b4b0ddc7b7c6443b8f0cf70461e3d03cb200b7146724967725
3
+ metadata.gz: 0233a79937eb8039a999b9711cef50a013311af86dd0ccde5ce94559af172235
4
+ data.tar.gz: 818dab5e4f71506ed895b2480dddfab7df13d042500322b14d68258af1cfaba8
5
5
  SHA512:
6
- metadata.gz: 519eb3ef5e2c2aea6675cadc19bad8bad476244d5cb72248edeecc9f197c74fbf16e053cc4f0cdc7590c2b26ea480cb2fec5b4b6596635b8cac2d7e2a1e35b4e
7
- data.tar.gz: 463c5c6db3e308891cba03f393a1e95ec2df9a6e3a6f9c5cc59b7cde79f1fd81e4b6e40adf6b98ce5f562325b5a7be3f0899bfd37d0ae3ec04373c217409acd8
6
+ metadata.gz: 0b1a8a8d67828b3fc901d831cc6087b3dccfbc7b120578a8118ae210d782e6064d80406665e5c0911222cf81ee059692235350cde6f3bcad27bd55d27a2f921f
7
+ data.tar.gz: 8600a21f94a6851e4281c09ff4f3a0eab2db5977f5fa6100770ba6d35e6e29ad46364b0f523298d144d5e4f5006d4349c1af5b1bdaa0d88aef8bfd1926ec52d6
@@ -1,6 +1,9 @@
1
1
  name: Test
2
2
 
3
- on: [push, pull_request]
3
+ on:
4
+ push:
5
+ branches: [ main, dev ]
6
+ pull_request:
4
7
 
5
8
  jobs:
6
9
  setup:
@@ -8,16 +11,13 @@ jobs:
8
11
 
9
12
  runs-on: ubuntu-latest
10
13
 
11
- # Run this build only on either pull request or push.
12
- if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
13
-
14
14
  strategy:
15
15
  matrix:
16
16
  ruby:
17
- - "2.7"
18
17
  - "3.0"
19
18
  - "3.1"
20
19
  - "3.2"
20
+ - "3.3"
21
21
 
22
22
  steps:
23
23
  - uses: actions/checkout@v4
data/CHANGELOG.md CHANGED
@@ -1,8 +1,24 @@
1
1
  ## main (Unreleased)
2
2
 
3
+ ## 0.14.1
4
+
5
+ Enhancements:
6
+
7
+ * Add overflow-wrap option #129
8
+
9
+ ## 0.14.0
10
+
11
+ Breaking Changes:
12
+
13
+ * Drop Ruby 2.7 support
14
+
15
+ Bug Fixes:
16
+
17
+ * Fix LoadError: cannot load such file -- matrix #131
18
+
3
19
  ## 0.13.1
4
20
 
5
- Bug fixes:
21
+ Bug Fixes:
6
22
 
7
23
  * allow title argument to be specified in Report.generate method #127
8
24
 
data/Gemfile CHANGED
@@ -9,7 +9,6 @@ gem 'rake'
9
9
  gem 'minitest'
10
10
  gem 'mocha'
11
11
  gem 'pdf-inspector'
12
- gem 'matrix'
13
12
  gem 'pdf_matcher-testing'
14
13
 
15
14
  # suppress warning: assigned but unused variable - y1
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 2.7, 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.13.1'
4
+ VERSION = '0.14.1'
5
5
  end
data/thinreports.gemspec CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.license = 'MIT'
16
16
  s.metadata = { 'rubygems_mfa_required' => 'true' }
17
17
 
18
- s.required_ruby_version = '>= 2.7.0'
18
+ s.required_ruby_version = Gem::Requirement.new('>= 3.0.0')
19
19
 
20
20
  s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
21
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^test/}) }
@@ -23,5 +23,7 @@ Gem::Specification.new do |s|
23
23
  s.require_paths = ['lib']
24
24
 
25
25
  s.add_dependency 'prawn', '>= 2.4.0'
26
+ s.add_dependency 'matrix', '~> 0.4'
27
+ s.add_dependency 'prawn-disable_word_break', '>= 2.3.1'
26
28
  s.add_dependency 'rexml'
27
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.13.1
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-09-10 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
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.4.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: matrix
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.4'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
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
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: rexml
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -180,7 +208,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
208
  requirements:
181
209
  - - ">="
182
210
  - !ruby/object:Gem::Version
183
- version: 2.7.0
211
+ version: 3.0.0
184
212
  required_rubygems_version: !ruby/object:Gem::Requirement
185
213
  requirements:
186
214
  - - ">="