prawn-rtl-support 0.1.7 → 0.1.8

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: da391affbc37a7e52a023f3644738dd006ffecc177374e980bb2c91735721f7f
4
- data.tar.gz: 8703e5e55ef4a427ab0246667eba0b5c38fbe3c8807439cf4122f060356bcac4
3
+ metadata.gz: 1424d40245ffbe3f42623e759747cdf847a9ca998df21164a2e08c800417fe1e
4
+ data.tar.gz: abad0e4cc7958ef0f3fd4213eb50ecb02bfa121312a1cab18b2418c568ec4427
5
5
  SHA512:
6
- metadata.gz: 29ebec9291006ad1b9d9f9eb862a067b2b26136caa8cbecbfe120ff96facf3dac647c13679c59e0a5553526d79fda6910965b27621eef75cf495ff7641b0c0ba
7
- data.tar.gz: d5c27dc0a9220f14d1d8bbbf5b68ed361bc2dfce024160ccf7af71e25a15de605a8c6fbeddbcde457a60cdfc19d20dcffca643d78e334e3bc7d1d3ae72187f0c
6
+ metadata.gz: 7bef93dc5aa91ba1869881d51a109f305f1e9c4567be688333503c10714efdb448deba04634053c23351e9f8c5b8f85e87df08c6f702ba2e4347b15bd13ab5ca
7
+ data.tar.gz: fbd89cc337db56fd6c3f369c745f125b95fbaa099ab6e1783a354cb5cb90d5d3b8024692fc74a5debc3ad45e881bbf6e92e83d2716522d872a559e1ea9e4d8c3
data/CHANGELOG.md ADDED
@@ -0,0 +1,43 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.8] - 2025-09-04
9
+
10
+ ### Customer-Impacting Changes
11
+
12
+ #### Added
13
+ - **Ruby 2.7+ requirement**: Gem now explicitly requires Ruby 2.7 or higher
14
+ - **Better documentation**: All public APIs now have YARD documentation with examples
15
+
16
+ ### Internal Changes
17
+
18
+ #### Development & CI
19
+ - Migrated from Travis CI to GitHub Actions
20
+ - Added testing matrix for Ruby 2.7, 3.0, 3.1, 3.2, 3.3, and 3.4
21
+ - Added RuboCop linting to CI workflow
22
+ - Added Dependabot for automated dependency updates
23
+ - Added CLAUDE.md for AI-assisted development guidance
24
+ - Multi-factor authentication (MFA) is now required for gem publishers
25
+
26
+ #### Code Quality
27
+ - Added YARD documentation to all modules and classes
28
+ - Fixed some RuboCop violations
29
+ - Fixed typos
30
+ - Improved gemspec metadata (added source_code_uri, changelog_uri, bug_tracker_uri, documentation_uri)
31
+ - Moved development dependencies from gemspec to Gemfile
32
+ - Removed unnecessary `$LOAD_PATH` manipulation
33
+ - Internal file requires now use `require_relative` for faster loading
34
+ - Gemspec file inclusion no longer depends on git, works in any environment
35
+
36
+ #### Documentation
37
+ - Updated README with "Supported Languages" section
38
+ - Updated gemspec description to accurately reflect RTL language support
39
+ - Added comprehensive code examples in YARD documentation
40
+
41
+ ## [0.1.7] - 2020-05-10
42
+
43
+ For changes in previous versions, see the git commit history.
data/CLAUDE.md ADDED
@@ -0,0 +1,56 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ This is prawn-rtl-support, a Ruby gem that provides bidirectional text (RTL/LTR) support for the Prawn PDF generation library. It enables proper rendering of Arabic and other right-to-left languages in PDFs by:
8
+ - Using Unicode Bidirectional Algorithm via TwitterCldr for text reordering
9
+ - Connecting Arabic letters properly for visual display
10
+ - Minimally patching Prawn's text rendering pipeline
11
+
12
+ ## Development Commands
13
+
14
+ ```bash
15
+ # Install dependencies
16
+ bundle install
17
+
18
+ # Run test suite
19
+ bundle exec rake spec
20
+ # or just
21
+ rake spec
22
+
23
+ # Run linting (RuboCop)
24
+ bundle exec rubocop
25
+
26
+ # Open console for experimentation
27
+ bin/console
28
+
29
+ # Build gem locally
30
+ bundle exec rake build
31
+
32
+ # Install gem to local machine
33
+ bundle exec rake install
34
+ ```
35
+
36
+ ## Architecture
37
+
38
+ The gem patches Prawn by prepending a module to `Prawn::Text::Formatted::Box#original_text`. The core functionality:
39
+
40
+ 1. **lib/prawn/rtl/support.rb**: Main entry point that patches Prawn::Text::Formatted::Box
41
+ 2. **lib/prawn/rtl/connector.rb**: Core RTL fixing logic with three main methods:
42
+ - `fix_rtl(string)`: Main public API that detects RTL text and processes it
43
+ - `connect(string)`: Applies Arabic letter connection rules
44
+ - `reorder(string)`: Uses TwitterCldr's Bidi algorithm to reorder text visually
45
+ 3. **lib/prawn/rtl/connector/logic.rb**: Arabic letter connection logic with character mapping tables for different forms (isolated, initial, medial, final)
46
+
47
+ The gem automatically activates when required - no configuration needed. It detects RTL text and only processes strings that contain RTL characters.
48
+
49
+ ## Key Dependencies
50
+
51
+ - **prawn ~> 2.2**: The PDF generation library being patched
52
+ - **twitter_cldr >= 4.0, < 7.0**: Provides Unicode Bidirectional Algorithm implementation
53
+
54
+ ## Contributing
55
+
56
+ - Run tests `bundle exec rake` and RuboCop linting `bundle exec rubocop` before committing.
data/Gemfile CHANGED
@@ -1,4 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in prawn-rtl-support.gemspec
4
6
  gemspec
7
+
8
+ # Development dependencies
9
+ group :development, :test do
10
+ gem 'pry', '~> 0.12'
11
+ gem 'rake', '~> 13.0'
12
+ gem 'rspec', '~> 3.9'
13
+ gem 'rubocop', '1.80.2'
14
+ gem 'rubocop-performance', '1.25.0'
15
+ gem 'rubocop-rake', '0.7.1'
16
+ gem 'rubocop-rspec', '3.7.0'
17
+ gem 'rubocop-rubycw', '0.2.2'
18
+ gem 'rubocop-thread_safety', '0.7.3'
19
+ end
data/README.md CHANGED
@@ -1,15 +1,26 @@
1
1
  # Prawn::Rtl::Support
2
2
 
3
- [![Build Status](https://travis-ci.org/cropio/prawn-rtl-support.svg?branch=master)](https://travis-ci.org/cropio/prawn-rtl-support)
3
+ [![CI](https://github.com/prawn-rtl-support/prawn-rtl-support/actions/workflows/ci.yml/badge.svg)](https://github.com/prawn-rtl-support/prawn-rtl-support/actions/workflows/ci.yml)
4
4
 
5
- This gem provide bidirectional text support for Prawn. It uses Unicode Bidirectional Algorithm for displaying text from [TwitterCldr::Shared::Bidi](https://github.com/twitter/twitter-cldr-rb) and connect arabic letters using [Arabic Letter Connector](https://github.com/staii/arabic-letter-connector). Prawn patching is minimal, we patch only [`Prawn::Text::Formatted::Box#original_text`](https://github.com/prawnpdf/prawn/blob/master/lib/prawn/text/formatted/box.rb#L367).
5
+ This gem provides bidirectional text support for Prawn PDF generator. It uses the Unicode Bidirectional Algorithm from [TwitterCldr::Shared::Bidi](https://github.com/twitter/twitter-cldr-rb) for text reordering and implements Arabic letter shaping similar to [Arabic Letter Connector](https://github.com/staii/arabic-letter-connector). Prawn patching is minimal - we only patch [`Prawn::Text::Formatted::Box#original_text`](https://github.com/prawnpdf/prawn/blob/master/lib/prawn/text/formatted/box.rb#L367).
6
6
 
7
- ## Motivation
7
+ ## Supported Languages
8
8
 
9
- Ruby and Rails internally provide unicode string normalization and store normalized letters inside. But Prawn don't connect arabic glyphs back and don't suport mixet LTR and RTL string. This gem add this suport.
9
+ - **Full support** (with contextual letter shaping):
10
+ - Arabic
11
+ - Persian/Farsi
12
+ - Urdu
13
+ - Other Arabic script languages
14
+
15
+ - **RTL support** (bidirectional text reordering):
16
+ - Hebrew
17
+ - Syriac
18
+ - Thaana
19
+ - Mixed LTR/RTL text
10
20
 
11
- ## Acknowledgment
12
- This gem use same code as [Arabic Letter Connector](https://github.com/staii/arabic-letter-connector) by [@staii](https://github.com/staii) and therefore based on [Arabic-Prawn](https://rubygems.org/gems/Arabic-Prawn/versions/0.0.1) by Dynamix Solutions (Ahmed Nasser).
21
+ ## Motivation
22
+
23
+ Ruby and Rails internally provide Unicode string normalization. However, Prawn doesn't connect Arabic letters into their contextual forms and doesn't support mixed LTR and RTL strings. This gem adds this support.
13
24
 
14
25
  ## Installation
15
26
 
@@ -23,24 +34,30 @@ And that's all. Your Prawn is patched!
23
34
 
24
35
  Or install it yourself as:
25
36
 
26
- $ gem install prawn-rtl-support
37
+ ```shell
38
+ gem install prawn-rtl-support
39
+ ```
27
40
 
28
41
  ## Usage
29
42
 
30
- `prawn-rtl-support` provide method [`Prawn::Rtl::Connector#fix_rtl(string)`](https://github.com/cropio/prawn-rtl-support/blob/master/lib/prawn/rtl/connector.rb#L13) which reverse string and connect arabic letters.
43
+ `prawn-rtl-support` provide method [`Prawn::Rtl::Connector#fix_rtl(string)`](https://github.com/prawn-rtl-support/prawn-rtl-support/blob/master/lib/prawn/rtl/connector.rb#L13) which reverse string and connect arabic letters.
44
+
31
45
  Prawn patching is minimal, we patch only [`Prawn::Text::Formatted::Box#original_text`](https://github.com/prawnpdf/prawn/blob/master/lib/prawn/text/formatted/box.rb#L367).
32
46
 
33
47
  ## Development
34
48
 
49
+ Check [CLAUDE.md](CLAUDE.md) for more details about the architecture and development commands.
50
+
35
51
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
52
 
37
53
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
54
 
39
55
  ## Contributing
40
56
 
41
- Bug reports and pull requests are welcome on GitHub at https://github.com/cropio/prawn-rtl-support. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
42
-
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/prawn-rtl-support/prawn-rtl-support. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
43
58
 
59
+ ## Acknowledgment
60
+ This gem uses the same code as [Arabic Letter Connector](https://github.com/staii/arabic-letter-connector) by [@staii](https://github.com/staii) and therefore is based on [Arabic-Prawn](https://rubygems.org/gems/Arabic-Prawn/versions/0.0.1) by Dynamix Solutions (Ahmed Nasser).
44
61
 
45
62
  ## License
46
63
 
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
@@ -3,48 +3,82 @@
3
3
  module Prawn
4
4
  module Rtl
5
5
  module Connector
6
+ # Handles the logic for Arabic letter connection and contextual form selection.
7
+ #
8
+ # This module implements the core algorithm for determining which form
9
+ # (isolated, initial, medial, or final) an Arabic character should take
10
+ # based on its surrounding characters. It maintains a mapping of Arabic
11
+ # Unicode characters to their various contextual forms.
6
12
  module Logic
7
-
8
13
  @@charinfos = nil
9
14
 
15
+ # Represents information about an Arabic character and its contextual forms.
16
+ #
17
+ # Each Arabic letter can have up to four different forms depending on
18
+ # its position within a word and connection to surrounding letters.
10
19
  class CharacterInfo
11
- attr_accessor :common, :formatted
20
+ # @return [String] the base Unicode character
21
+ attr_accessor :common
22
+
23
+ # @return [Hash] the character's forms (:isolated, :final, :initial, :medial)
24
+ attr_accessor :formatted
12
25
 
26
+ # Initializes a new CharacterInfo instance.
27
+ #
28
+ # @param common [String] the base Unicode character
29
+ # @param isolated [String] the isolated form of the character
30
+ # @param final [String] the final form of the character
31
+ # @param initial [String] the initial form of the character
32
+ # @param medial [String] the medial form of the character
33
+ # @param connects [Boolean] whether this character connects to the next
34
+ # @param diacritic [Boolean] whether this character is a diacritic mark
13
35
  def initialize(common, isolated, final, initial, medial, connects, diacritic)
14
36
  @common = common
15
37
  @formatted = {
16
38
  isolated: isolated,
17
39
  final: final,
18
40
  initial: initial,
19
- medial: medial,
41
+ medial: medial
20
42
  }
21
43
  @connects = connects
22
44
  @diacritic = diacritic
23
45
  end
24
46
 
47
+ # Checks if this character connects to the following character.
48
+ #
49
+ # @return [Boolean] true if the character connects forward
25
50
  def connects?
26
51
  @connects
27
52
  end
28
53
 
54
+ # Checks if this character is a diacritic mark.
55
+ #
56
+ # @return [Boolean] true if the character is a diacritic
29
57
  def diacritic?
30
58
  @diacritic
31
59
  end
32
-
33
60
  end
34
61
 
35
- # Determine the form of the current character (:isolated, :initial, :medial,
62
+ # Determines the contextual form of an Arabic character.
63
+ #
64
+ # Determines the form of the current character (:isolated, :initial, :medial,
36
65
  # or :final), given the previous character and the next one. In Arabic, all
37
66
  # characters can connect with a previous character, but not all letters can
38
- # connect with the next character (this is determined by
39
- # CharacterInfo#connects?).
67
+ # connect with the next character (this is determined by CharacterInfo#connects?).
68
+ #
69
+ # @param previous_previous_char [String, nil] the character two positions before
70
+ # @param previous_char [String, nil] the character immediately before
71
+ # @param next_char [String, nil] the character immediately after
72
+ # @param next_next_char [String, nil] the character two positions after
73
+ # @return [Symbol] the contextual form (:isolated, :initial, :medial, or :final)
40
74
  def self.determine_form(previous_previous_char, previous_char, next_char, next_next_char)
41
75
  charinfos = self.charinfos
42
76
  next_char = next_next_char if charinfos[next_char] && charinfos[next_char].diacritic?
43
77
  previous_char = previous_previous_char if charinfos[previous_char] && charinfos[previous_char].diacritic?
44
78
  if charinfos[previous_char] && charinfos[next_char]
45
79
  charinfos[previous_char].connects? ? :medial : :initial # If the current character does not connect,
46
- # its medial form will map to its final form,
47
- # and its initial form will map to its isolated form.
80
+ # its medial form will map to its final form,
81
+ # and its initial form will map to its isolated form.
48
82
  elsif charinfos[previous_char] # The next character is not an arabic character.
49
83
  charinfos[previous_char].connects? ? :final : :isolated
50
84
  elsif charinfos[next_char] # The previous character is not an arabic character.
@@ -54,6 +88,14 @@ module Prawn
54
88
  end
55
89
  end
56
90
 
91
+ # Transforms Arabic text by applying contextual letter forms.
92
+ #
93
+ # Processes a string character by character, determining the appropriate
94
+ # contextual form for each Arabic letter based on its surrounding characters.
95
+ # Non-Arabic characters pass through unchanged.
96
+ #
97
+ # @param str [String] the text to transform
98
+ # @return [String] the transformed text with Arabic letters in their contextual forms
57
99
  def self.transform(str)
58
100
  res = ''
59
101
  charinfos = self.charinfos
@@ -69,7 +111,8 @@ module Prawn
69
111
  next_char = next_next_char
70
112
  next_next_char = char
71
113
  return unless current_char
72
- if charinfos.keys.include?(current_char)
114
+
115
+ if charinfos.key?(current_char)
73
116
  form = determine_form(previous_previous_char, previous_char, next_char, next_next_char)
74
117
  res += charinfos[current_char].formatted[form]
75
118
  else
@@ -78,13 +121,19 @@ module Prawn
78
121
  end
79
122
  str.each_char { |char| consume_character.call(char) }
80
123
  2.times { consume_character.call(nil) }
81
- return res
124
+ res
82
125
  end
83
126
 
84
- private
85
-
127
+ # Returns the character information mapping for Arabic characters.
128
+ #
129
+ # Lazily initializes and returns a hash mapping Arabic Unicode characters
130
+ # to their CharacterInfo objects containing contextual forms.
131
+ #
132
+ # @return [Hash{String => CharacterInfo}] the character information mapping
133
+ # @api private
86
134
  def self.charinfos
87
135
  return @@charinfos unless @@charinfos.nil?
136
+
88
137
  @@charinfos = {}
89
138
  add('0627', 'fe8d', 'fe8e', 'fe8d', 'fe8e', false) # Alef
90
139
  add('0628', 'fe8f', 'fe90', 'fe91', 'fe92', true) # Ba2
@@ -135,6 +184,16 @@ module Prawn
135
184
  @@charinfos
136
185
  end
137
186
 
187
+ # Adds a character and its contextual forms to the character mapping.
188
+ #
189
+ # @param common [String] hex code of the base Unicode character
190
+ # @param isolated [String] hex code of the isolated form
191
+ # @param final [String] hex code of the final form
192
+ # @param initial [String] hex code of the initial form
193
+ # @param medial [String] hex code of the medial form
194
+ # @param connects [Boolean] whether this character connects to the next
195
+ # @param diacritic [Boolean] whether this character is a diacritic mark
196
+ # @api private
138
197
  def self.add(common, isolated, final, initial, medial, connects, diacritic = false)
139
198
  charinfo = CharacterInfo.new(
140
199
  [common.hex].pack('U'),
@@ -147,7 +206,6 @@ module Prawn
147
206
  )
148
207
  @@charinfos[charinfo.common] = charinfo
149
208
  end
150
-
151
209
  end
152
210
  end
153
211
  end
@@ -1,20 +1,59 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'prawn/rtl/connector/logic'
3
+ require_relative 'connector/logic'
4
4
  require 'twitter_cldr'
5
5
 
6
6
  module Prawn
7
7
  module Rtl
8
+ # Provides bidirectional text support and Arabic letter connection for Prawn PDF generation.
9
+ #
10
+ # This module handles RTL (Right-to-Left) text processing by:
11
+ # - Connecting Arabic script letters according to their contextual forms
12
+ # - Reordering text using the Unicode Bidirectional Algorithm
13
+ # - Supporting multiple RTL languages (Arabic, Hebrew, Persian, Urdu, etc.)
14
+ # - Handling mixed LTR/RTL text properly
15
+ #
16
+ # @example Fix Arabic text for PDF rendering
17
+ # text = "مرحبا بالعالم"
18
+ # fixed_text = Prawn::Rtl::Connector.fix_rtl(text)
19
+ #
20
+ # @example Fix Hebrew text for PDF rendering
21
+ # text = "שלום עולם"
22
+ # fixed_text = Prawn::Rtl::Connector.fix_rtl(text)
23
+ #
24
+ # @example Fix mixed LTR/RTL text
25
+ # text = "Hello مرحبا World"
26
+ # fixed_text = Prawn::Rtl::Connector.fix_rtl(text)
8
27
  module Connector
28
+ # Connects Arabic letters according to their contextual forms.
29
+ #
30
+ # @param string [String] the text containing Arabic letters to connect
31
+ # @return [String] the text with properly connected Arabic letters
9
32
  def self.connect(string)
10
33
  Prawn::Rtl::Connector::Logic.transform(string)
11
34
  end
12
35
 
36
+ # Fixes RTL text by connecting Arabic letters and reordering for visual display.
37
+ #
38
+ # This is the main entry point for processing RTL text. It detects if the text
39
+ # contains RTL characters and applies both letter connection and bidirectional
40
+ # reordering if needed.
41
+ #
42
+ # @param string [String] the text to process
43
+ # @return [String] the processed text ready for PDF rendering
13
44
  def self.fix_rtl(string)
14
45
  return string unless include_rtl?(string)
46
+
15
47
  reorder(connect(string))
16
48
  end
17
49
 
50
+ # Reorders text according to the Unicode Bidirectional Algorithm.
51
+ #
52
+ # Uses TwitterCldr's Bidi implementation to visually reorder mixed
53
+ # LTR/RTL text for correct display.
54
+ #
55
+ # @param string [String] the text to reorder
56
+ # @return [String] the visually reordered text
18
57
  def self.reorder(string)
19
58
  TwitterCldr::Shared::Bidi
20
59
  .from_string(string, direction: :RTL)
@@ -22,6 +61,10 @@ module Prawn
22
61
  .to_s
23
62
  end
24
63
 
64
+ # Checks if a string contains RTL (Right-to-Left) characters.
65
+ #
66
+ # @param string [String] the text to check
67
+ # @return [Boolean] true if the text contains RTL characters, false otherwise
25
68
  def self.include_rtl?(string)
26
69
  TwitterCldr::Shared::Bidi
27
70
  .from_string(string)
@@ -3,7 +3,7 @@
3
3
  module Prawn
4
4
  module Rtl
5
5
  module Support
6
- VERSION = '0.1.7'
6
+ VERSION = '0.1.8'
7
7
  end
8
8
  end
9
9
  end
@@ -1,18 +1,32 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'pdf/core/text'
4
- require 'prawn/rtl/support/version'
5
- require 'prawn/rtl/connector'
4
+ require_relative 'support/version'
5
+ require_relative 'connector'
6
6
 
7
7
  module Prawn
8
8
  module Rtl
9
+ # Main module for RTL support functionality.
9
10
  module Support
11
+ # Patch module that intercepts Prawn's text rendering to apply RTL transformations.
12
+ #
13
+ # This module is prepended to Prawn::Text::Formatted::Box to automatically
14
+ # process RTL text before rendering. It intercepts the original_text method
15
+ # and applies Arabic letter connection and bidirectional text reordering
16
+ # to any text fragments that contain RTL characters.
17
+ #
18
+ # @example How it works internally
19
+ # # When Prawn renders text, this patch:
20
+ # # 1. Intercepts the text fragments
21
+ # # 2. Applies RTL fixes to each fragment
22
+ # # 3. Returns the processed fragments for rendering
10
23
  module PrawnTextPatch
24
+ # Overrides the original_text method to apply RTL transformations.
25
+ #
26
+ # @return [Array<Hash>] array of text fragments with RTL text properly formatted
11
27
  def original_text
12
28
  super.map do |h|
13
- if h.key?(:text)
14
- h[:text] = Prawn::Rtl::Connector.fix_rtl(h[:text])
15
- end
29
+ h[:text] = Prawn::Rtl::Connector.fix_rtl(h[:text]) if h.key?(:text)
16
30
  h
17
31
  end
18
32
  end
@@ -1,33 +1,42 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'prawn/rtl/support/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/prawn/rtl/support/version'
5
4
 
6
5
  Gem::Specification.new do |spec|
7
- spec.name = "prawn-rtl-support"
6
+ spec.name = 'prawn-rtl-support'
8
7
  spec.version = Prawn::Rtl::Support::VERSION
9
- spec.authors = ["Oleksandr Lapchenko"]
10
- spec.email = ["ozeron@me.com"]
8
+ spec.authors = ['Oleksandr Lapchenko']
9
+ spec.email = ['ozeron@me.com']
11
10
 
12
- spec.summary = 'Gem which patch prawn to provide support of arabic language.'
13
- spec.description = 'Add suport for arabic language in prawn.'
14
- spec.homepage = "https://github.com/cropio/prawn-rtl-support"
15
- spec.license = "MIT"
11
+ spec.summary = 'Bidirectional text support for Prawn PDF generator'
12
+ spec.description = 'Adds right-to-left (RTL) text support to Prawn PDF generator. ' \
13
+ 'Fully supports Arabic script languages (Arabic, Persian, Urdu) with ' \
14
+ 'contextual letter shaping and ligatures. Also supports Hebrew and other ' \
15
+ 'RTL languages with bidirectional text reordering. Handles mixed LTR/RTL text properly.'
16
+ spec.homepage = 'https://github.com/prawn-rtl-support/prawn-rtl-support'
17
+ spec.license = 'MIT'
18
+ spec.required_ruby_version = '>= 2.7.0'
16
19
 
17
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
- f.match(%r{^(test|spec|features)/})
19
- end
20
- spec.bindir = "exe"
21
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
20
+ spec.metadata = {
21
+ 'rubygems_mfa_required' => 'true',
22
+ 'source_code_uri' => 'https://github.com/prawn-rtl-support/prawn-rtl-support',
23
+ 'changelog_uri' => 'https://github.com/prawn-rtl-support/prawn-rtl-support/blob/main/CHANGELOG.md',
24
+ 'bug_tracker_uri' => 'https://github.com/prawn-rtl-support/prawn-rtl-support/issues',
25
+ 'documentation_uri' => 'https://rubydoc.info/gems/prawn-rtl-support'
26
+ }
23
27
 
24
- spec.add_development_dependency 'rake', '~> 13.0'
25
- spec.add_development_dependency 'rspec', '~> 3.9'
26
- spec.add_development_dependency 'pry', '~> 0.12'
27
- spec.add_development_dependency 'rubocop', '~> 0.77'
28
- spec.add_development_dependency 'rubocop-performance', '~> 1.5'
29
- spec.add_development_dependency 'rubocop-rspec', '~> 1.37'
28
+ # Specify which files should be included in the gem
29
+ spec.files = (Dir['{lib,exe}/**/*'] +
30
+ Dir['*.{md,txt,gemspec}'] +
31
+ %w[Gemfile Rakefile LICENSE.txt README.md CODE_OF_CONDUCT.md].select { |f| File.exist?(f) })
32
+ .reject { |f| File.directory?(f) }
33
+
34
+ spec.bindir = 'exe'
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ['lib']
37
+ spec.extra_rdoc_files = ['README.md', 'LICENSE.txt']
30
38
 
39
+ # Runtime dependencies
31
40
  spec.add_dependency 'prawn', '~> 2.2'
32
41
  spec.add_dependency 'twitter_cldr', '>= 4.0', '< 7.0'
33
42
  end
metadata CHANGED
@@ -1,99 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-rtl-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleksandr Lapchenko
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2020-05-10 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '13.0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '13.0'
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '3.9'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '3.9'
41
- - !ruby/object:Gem::Dependency
42
- name: pry
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '0.12'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '0.12'
55
- - !ruby/object:Gem::Dependency
56
- name: rubocop
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '0.77'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '0.77'
69
- - !ruby/object:Gem::Dependency
70
- name: rubocop-performance
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '1.5'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '1.5'
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop-rspec
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '1.37'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '1.37'
97
12
  - !ruby/object:Gem::Dependency
98
13
  name: prawn
99
14
  requirement: !ruby/object:Gem::Requirement
@@ -128,33 +43,39 @@ dependencies:
128
43
  - - "<"
129
44
  - !ruby/object:Gem::Version
130
45
  version: '7.0'
131
- description: Add suport for arabic language in prawn.
46
+ description: Adds right-to-left (RTL) text support to Prawn PDF generator. Fully supports
47
+ Arabic script languages (Arabic, Persian, Urdu) with contextual letter shaping and
48
+ ligatures. Also supports Hebrew and other RTL languages with bidirectional text
49
+ reordering. Handles mixed LTR/RTL text properly.
132
50
  email:
133
51
  - ozeron@me.com
134
52
  executables: []
135
53
  extensions: []
136
- extra_rdoc_files: []
54
+ extra_rdoc_files:
55
+ - LICENSE.txt
56
+ - README.md
137
57
  files:
138
- - ".gitignore"
139
- - ".rspec"
140
- - ".travis.yml"
58
+ - CHANGELOG.md
59
+ - CLAUDE.md
141
60
  - CODE_OF_CONDUCT.md
142
61
  - Gemfile
143
62
  - LICENSE.txt
144
63
  - README.md
145
64
  - Rakefile
146
- - bin/console
147
- - bin/setup
148
65
  - lib/prawn/rtl/connector.rb
149
66
  - lib/prawn/rtl/connector/logic.rb
150
67
  - lib/prawn/rtl/support.rb
151
68
  - lib/prawn/rtl/support/version.rb
152
69
  - prawn-rtl-support.gemspec
153
- homepage: https://github.com/cropio/prawn-rtl-support
70
+ homepage: https://github.com/prawn-rtl-support/prawn-rtl-support
154
71
  licenses:
155
72
  - MIT
156
- metadata: {}
157
- post_install_message:
73
+ metadata:
74
+ rubygems_mfa_required: 'true'
75
+ source_code_uri: https://github.com/prawn-rtl-support/prawn-rtl-support
76
+ changelog_uri: https://github.com/prawn-rtl-support/prawn-rtl-support/blob/main/CHANGELOG.md
77
+ bug_tracker_uri: https://github.com/prawn-rtl-support/prawn-rtl-support/issues
78
+ documentation_uri: https://rubydoc.info/gems/prawn-rtl-support
158
79
  rdoc_options: []
159
80
  require_paths:
160
81
  - lib
@@ -162,15 +83,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
83
  requirements:
163
84
  - - ">="
164
85
  - !ruby/object:Gem::Version
165
- version: '0'
86
+ version: 2.7.0
166
87
  required_rubygems_version: !ruby/object:Gem::Requirement
167
88
  requirements:
168
89
  - - ">="
169
90
  - !ruby/object:Gem::Version
170
91
  version: '0'
171
92
  requirements: []
172
- rubygems_version: 3.0.3
173
- signing_key:
93
+ rubygems_version: 3.6.7
174
94
  specification_version: 4
175
- summary: Gem which patch prawn to provide support of arabic language.
95
+ summary: Bidirectional text support for Prawn PDF generator
176
96
  test_files: []
data/.gitignore DELETED
@@ -1,14 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
-
11
- # rspec failure tracking
12
- .rspec_status
13
-
14
- *.gem
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.6
4
- - 2.5
5
- - 2.4
6
- before_install:
7
- - gem install bundler
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "prawn/rtl/support"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "pry"
14
- Pry.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here