Skip to content

Commit

Permalink
Merge pull request #319 from sebastianludwig/ruby3.4
Browse files Browse the repository at this point in the history
Necessary adjustments to work with Ruby 3.4
  • Loading branch information
scelis authored Mar 1, 2025
2 parents c8f01a5 + 06d7f3f commit 9163696
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.6', '2.7', '3.0', '3.1']
ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.4']

steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions lib/twine/formatters/android.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def format_value(value)

# capture xliff tags and replace them with a placeholder
xliff_tags = []
value.gsub! /<xliff:g.+?<\/xliff:g>/ do
value.gsub!(/<xliff:g.+?<\/xliff:g>/) do
xliff_tags << $&
'TWINE_XLIFF_TAG_PLACEHOLDER'
end
Expand All @@ -163,7 +163,7 @@ def format_value(value)
# put xliff tags back into place
xliff_tags.each do |xliff_tag|
# escape content of xliff tags
xliff_tag.gsub! /(<xliff:g.*?>)(.*)(<\/xliff:g>)/ do "#{$1}#{escape_value($2)}#{$3}" end
xliff_tag.gsub!(/(<xliff:g.*?>)(.*)(<\/xliff:g>)/) do "#{$1}#{escape_value($2)}#{$3}" end
value.sub! 'TWINE_XLIFF_TAG_PLACEHOLDER', xliff_tag
end

Expand Down
2 changes: 1 addition & 1 deletion lib/twine/placeholders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def convert_placeholders_from_twine_to_flash(input)
end

def convert_placeholders_from_flash_to_twine(input)
input.gsub /\{\d+\}/, '%@'
input.gsub(/\{\d+\}/, '%@')
end

# Python supports placeholders in the form of `%(amount)03d`
Expand Down
2 changes: 1 addition & 1 deletion lib/twine/twine_file.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Twine
class TwineDefinition
attr_reader :key
attr_accessor :comment
attr_writer :comment
attr_accessor :tags
attr_reader :translations
attr_accessor :reference
Expand Down
2 changes: 1 addition & 1 deletion test/test_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def parse_with(parameters)
def assert_help
parse_with '--help'
assert_equal @options, false
assert_match /Usage: twine.*Examples:/m, Twine::stdout.string
assert_match(/Usage: twine.*Examples:/m, Twine::stdout.string)
end

def assert_option_consume_all
Expand Down
10 changes: 8 additions & 2 deletions test/test_validate_twine_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ def test_reports_duplicate_keys
end

def test_reports_invalid_characters_in_keys
random_definition.key[0] = "!?;:,^`´'\"\\|/(){}[]~-+*=#$%".chars.to_a.sample
invalid_character = "!?;:,^`´'\"\\|/(){}[]~-+*=#$%".chars.to_a.sample

twine_file = build_twine_file 'en' do
add_section 'Section' do
add_definition "key#{invalid_character}" => 'value'
end
end

assert_raises Twine::Error do
Twine::Runner.new(@options, @twine_file).validate_twine_file
Twine::Runner.new(@options, twine_file).validate_twine_file
end
end

Expand Down
3 changes: 2 additions & 1 deletion twine.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ Gem::Specification.new do |s|
s.add_runtime_dependency('rexml', "~> 3.2")
s.add_runtime_dependency('rubyzip', "~> 2.0")
s.add_runtime_dependency('safe_yaml', "~> 1.0")
s.add_runtime_dependency('base64', "~> 0.2")
s.add_development_dependency('rake', "~> 13.0")
s.add_development_dependency('minitest', "~> 5.5")
s.add_development_dependency('minitest-ci', "~> 3.0")
s.add_development_dependency('mocha', "~> 1.1")
s.add_development_dependency('mocha', "~> 2.7")

s.executables = %w( twine )
s.description = <<desc
Expand Down

0 comments on commit 9163696

Please sign in to comment.