Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby 3.3 #67

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['3.0', '3.1', '3.2']
ruby-version: ['3.0', '3.1', '3.2', '3.3']

steps:
- uses: actions/checkout@v3
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
uses: ruby/setup-ruby@360dc864d5da99d54fcb8e9148c14a84b90d3e88 # v1.165.1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
Expand Down
11 changes: 7 additions & 4 deletions lib/multi_xml.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require "base64"
require "bigdecimal"
require "date"
require "stringio"
Expand Down Expand Up @@ -43,7 +42,7 @@ def initialize(type)
"boolean" => proc { |boolean| !%w[0 false].include?(boolean.strip) },
"string" => proc { |string| string.to_s },
"yaml" => proc { |yaml| YAML.load(yaml) rescue yaml }, # rubocop:disable Style/RescueModifier, Security/YAMLLoad
"base64Binary" => proc { |binary| ::Base64.decode64(binary) },
"base64Binary" => proc { |binary| base64_decode(binary) },
"binary" => proc { |binary, entity| parse_binary(binary, entity) },
"file" => proc { |file, entity| parse_file(file, entity) }
}.freeze
Expand Down Expand Up @@ -176,20 +175,24 @@ def content_type
def parse_binary(binary, entity) # :nodoc:
case entity["encoding"]
when "base64"
Base64.decode64(binary)
base64_decode(binary)
else
binary
end
end

def parse_file(file, entity)
f = StringIO.new(Base64.decode64(file))
f = StringIO.new(base64_decode(file))
f.extend(FileLike)
f.original_filename = entity["name"]
f.content_type = entity["content_type"]
f
end

def base64_decode(input)
input.unpack1("m")
end

def symbolize_keys(params)
case params
when Hash
Expand Down
2 changes: 2 additions & 0 deletions multi_xml.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ Gem::Specification.new do |spec|
# For more information and examples about making a new gem, check out our
# guide at: https://bundler.io/guides/creating_gem.html
spec.metadata["rubygems_mfa_required"] = "true"

spec.add_runtime_dependency("bigdecimal")
end