Skip to content

Commit

Permalink
Merge pull request #361 from interagent/bf/sinatra-4
Browse files Browse the repository at this point in the history
add support for Sinatra 4
  • Loading branch information
beanieboi committed Feb 13, 2024
2 parents 85a5171 + 3f95c2c commit 0d48376
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
matrix:
ruby-version: ['3.0', '3.1', '3.2']
activesupport-version: ['6', '7']
sinatra-version: ['2', '3']
sinatra-version: ['2', '3', '4']
env:
ACTIVESUPPORT_MAJOR: ${{ matrix.activesupport-version }}
SINATRA_MAJOR: ${{ matrix.sinatra-version }}
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased] - 🔜
### Added
- Add support for Sinatra 4 ([#361](https://github.com/interagent/pliny/pull/361))

### Changed
- Switched branch from master to main ([#362](https://github.com/interagent/pliny/pull/362))

Expand Down
2 changes: 1 addition & 1 deletion lib/pliny/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Error < StandardError
attr_accessor :id

def self.render(error)
headers = { "Content-Type" => "application/json; charset=utf-8" }
headers = { "content-type" => "application/json; charset=utf-8" }
data = { id: error.id, message: error.message }
[error.status, headers, [MultiJson.encode(data)]]
end
Expand Down
12 changes: 6 additions & 6 deletions lib/pliny/middleware/cors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ def allow_headers

def cors_headers(env)
{
'Access-Control-Allow-Origin' => env["HTTP_ORIGIN"],
'Access-Control-Allow-Methods' => ALLOW_METHODS.join(', '),
'Access-Control-Allow-Headers' => allow_headers.join(', '),
'Access-Control-Allow-Credentials' => "true",
'Access-Control-Max-Age' => "1728000",
'Access-Control-Expose-Headers' => EXPOSE_HEADERS.join(', ')
'access-control-allow-origin' => env["HTTP_ORIGIN"],
'access-control-allow-methods' => ALLOW_METHODS.join(', '),
'access-control-allow-headers' => allow_headers.join(', '),
'access-control-allow-credentials' => "true",
'access-control-max-age' => "1728000",
'access-control-expose-headers' => EXPOSE_HEADERS.join(', ')
}
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/pliny/middleware/versioning.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def detect_api_version(env)
error = { id: :bad_version, message: <<-eos }
Please specify a version along with the MIME type. For example, `Accept: application/vnd.#{@app_name}+json; version=1`.
eos
return [400, { "Content-Type" => "application/json; charset=utf-8" },
return [400, { "content-type" => "application/json; charset=utf-8" },
[MultiJson.encode(error)]]
end

Expand Down
6 changes: 3 additions & 3 deletions pliny.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ Gem::Specification.new do |gem|
gem.add_dependency "prmd", "~> 0.11", ">= 0.11.4"


gem.add_dependency "sinatra", ">= 2.0", "< 4.0"
gem.add_dependency "sinatra", ">= 2.0", "< 5.0"
gem.add_dependency "http_accept", "~> 0.1", ">= 0.1.5"
gem.add_dependency "sinatra-router", "~> 0.2", ">= 0.2.4"
gem.add_dependency "thor", ">= 0.19", "< 2.0"

gem.add_development_dependency "rake", "~> 13.0"
gem.add_development_dependency "rack-test", "~> 1.1.0"
gem.add_development_dependency "rack-test", "~> 2"
gem.add_development_dependency "rspec", "~> 3.1", ">= 3.1.0"
gem.add_development_dependency "sinatra-contrib", ">= 2.0", "< 4.0"
gem.add_development_dependency "sinatra-contrib", ">= 2.0", "< 5.0"
gem.add_development_dependency "timecop", "~> 0.7", ">= 0.7.1"
gem.add_development_dependency "pry"
gem.add_development_dependency "pry-byebug"
Expand Down

0 comments on commit 0d48376

Please sign in to comment.