diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index 46585bb..819b631 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -15,6 +15,9 @@ jobs: - macos ruby: + - "2.3" + - "2.4" + - "2.5" - "2.6" - "2.7" - "3.0" @@ -43,4 +46,6 @@ jobs: - name: Run tests timeout-minutes: 5 - run: ${{matrix.env}} bundle exec rspec + run: | + gem update --system + ${{matrix.env}} bundle exec rspec diff --git a/gems.rb b/gems.rb index bfccdec..b0919e5 100644 --- a/gems.rb +++ b/gems.rb @@ -4,7 +4,9 @@ gem "bake" -group :maintenance, optional: true do - gem "bake-gem" - gem "bake-modernize" +if RUBY_VERSION >= "2.7.0" + group :maintenance, optional: true do + gem "bake-gem" + gem "bake-modernize" + end end diff --git a/lib/multipart/post/multipartable.rb b/lib/multipart/post/multipartable.rb index 976c3e5..ff69a8b 100644 --- a/lib/multipart/post/multipartable.rb +++ b/lib/multipart/post/multipartable.rb @@ -44,11 +44,10 @@ def self.secure_boundary def initialize(path, params, headers={}, boundary = Multipartable.secure_boundary) headers = headers.clone # don't want to modify the original variable - parts_headers = headers.delete(:parts) || {} - parts_headers.transform_keys!(&:to_sym) + parts_headers = symbolize_keys(headers.delete(:parts) || {}) super(path, headers) - parts = params.transform_keys(&:to_sym).map do |k,v| + parts = symbolize_keys(params).map do |k,v| case v when Array v.map {|item| Parts::Part.new(boundary, k, item, parts_headers[k]) } @@ -67,6 +66,18 @@ def initialize(path, params, headers={}, boundary = Multipartable.secure_boundar end attr :boundary + + private + + if RUBY_VERSION >= "2.5.0" + def symbolize_keys(hash) + hash.transform_keys(&:to_sym) + end + else + def symbolize_keys(hash) + hash.map{|key,value| [key.to_sym, value]}.to_h + end + end end end end diff --git a/multipart-post.gemspec b/multipart-post.gemspec index 2e8905e..d01835f 100644 --- a/multipart-post.gemspec +++ b/multipart-post.gemspec @@ -10,16 +10,15 @@ Gem::Specification.new do |spec| spec.authors = ["Nick Sieger", "Samuel Williams", "Olle Jonsson", "McClain Looney", "Lewis Cowles", "Gustav Ernberg", "Patrick Davey", "Steven Davidovitz", "Alex Koppel", "Ethan Turkeltaub", "Jagtesh Chadha", "Jason York", "Nick", "VincWebwag", "hasimo", "hexfet", "Christine Yen", "David Moles", "Eric Hutzelman", "Feuda Nan", "Gerrit Riessen", "Jan Piotrowski", "Jan-Joost Spanjers", "Jason Moore", "Jeff Hodges", "Johannes Wagener", "Jordi Massaguer Pla", "Lachlan Priest", "Leo Cassarani", "Lonre Wang", "Luke Redpath", "Matt Colyer", "Mislav Marohnić", "Socrates Vicente", "Steffen Grunwald", "Tim Barkley"] spec.license = "MIT" - spec.required_ruby_version = ">= 2.6.0" + spec.required_ruby_version = ">= 2.3.0" spec.cert_chain = ['release.cert'] spec.signing_key = File.expand_path('~/.gem/release.pem') spec.homepage = "https://github.com/socketry/multipart-post" - spec.files = Dir.glob('{lib}/**/*', File::FNM_DOTMATCH, base: __dir__) + spec.files = Dir.glob('{lib}/**/*', File::FNM_DOTMATCH) spec.add_development_dependency "bundler" - spec.add_development_dependency "rake" spec.add_development_dependency "rspec", "~> 3.4" end