Skip to content

Commit

Permalink
Add support for Ruby back to 2.3. (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix authored Jun 10, 2022
1 parent e52ef1e commit 31ed0ed
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
- macos

ruby:
- "2.3"
- "2.4"
- "2.5"
- "2.6"
- "2.7"
- "3.0"
Expand Down Expand Up @@ -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
8 changes: 5 additions & 3 deletions gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 14 additions & 3 deletions lib/multipart/post/multipartable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]) }
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions multipart-post.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 31ed0ed

Please sign in to comment.