Skip to content

Commit d7c1cb0

Browse files
committed
Adds ruby 3.0 support.
- drops ruby < 2.5 support required version now > 2.5 - removes travis - adds GH actions
1 parent 5c71861 commit d7c1cb0

File tree

8 files changed

+43
-49
lines changed

8 files changed

+43
-49
lines changed

.github/workflows/ruby.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Ruby
2+
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
pull_request:
8+
branches:
9+
- '*'
10+
11+
jobs:
12+
rspec:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
ruby-version: ['2.6', '2.7', '3.0']
17+
grape-version: [1.5.2, 1.4.0, 1.3.3]
18+
model-parser: [grape-swagger-entity, grape-swagger-representable]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Set up Ruby
23+
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
24+
with:
25+
ruby-version: ${{ matrix.ruby-version }}
26+
GRAPE_VERSION: ${{ matrix.grape-version }}
27+
MODEL_PARSER: ${{ matrix.model-parser }}
28+
bundler-cache: true
29+
- name: Run rspec
30+
run: bundle exec rspec
31+
- name: Run rubocop
32+
run: bundle exec rubocop

.rubocop.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ AllCops:
55
- vendor/**/*
66
- example/**/*
77
NewCops: enable
8-
TargetRubyVersion: 2.7
8+
TargetRubyVersion: 3.0
9+
SuggestExtensions: false
910

1011
# Layout stuff
1112
#

.travis.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

grape-swagger.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
1313
s.summary = 'Add auto generated documentation to your Grape API that can be displayed with Swagger.'
1414
s.license = 'MIT'
1515

16-
s.required_ruby_version = '>= 2.4'
16+
s.required_ruby_version = '>= 2.5'
1717
s.add_runtime_dependency 'grape', '~> 1.3'
1818

1919
s.files = `git ls-files`.split("\n")

lib/grape-swagger/endpoint.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ def build_root(route, reference, response_model, settings)
329329
end
330330

331331
def file_response?(value)
332-
value.to_s.casecmp('file').zero? ? true : false
332+
value.to_s.casecmp('file').zero?
333333
end
334334

335335
def build_file_response(memo)

lib/grape-swagger/model_parsers.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ def insert_before(before_klass, klass, ancestor)
1616
subhash = @parsers.except(klass).to_a
1717
insert_at = subhash.index(subhash.assoc(before_klass))
1818
insert_at = subhash.length - 1 if insert_at.nil?
19-
@parsers = Hash[subhash.insert(insert_at, [klass, ancestor])]
19+
@parsers = subhash.insert(insert_at, [klass, ancestor]).to_h
2020
end
2121

2222
def insert_after(after_klass, klass, ancestor)
2323
subhash = @parsers.except(klass).to_a
2424
insert_at = subhash.index(subhash.assoc(after_klass))
2525
insert_at = subhash.length - 1 if insert_at.nil?
26-
@parsers = Hash[subhash.insert(insert_at + 1, [klass, ancestor])]
26+
@parsers = subhash.insert(insert_at + 1, [klass, ancestor]).to_h
2727
end
2828

2929
def each

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
require 'grape'
2020
require 'grape-swagger'
2121

22-
Dir[File.join(Dir.getwd, 'spec/support/*.rb')].sort.each { |f| require f }
22+
Dir[File.join(Dir.getwd, 'spec/support/*.rb')].each { |f| require f }
2323
require "grape-swagger/#{MODEL_PARSER}" if MODEL_PARSER != 'mock'
2424
require File.join(Dir.getwd, "spec/support/model_parsers/#{MODEL_PARSER}_parser.rb")
2525

spec/swagger_v2/api_swagger_v2_response_with_headers_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ class ResponseApiHeaders < Grape::API
1919
end
2020

2121
desc 'A 204 can have headers too' do
22-
success Hash[status: 204, message: 'No content', headers: { 'Location' => { description: 'Location of resource', type: 'string' } }]
22+
foo = { status: 204, message: 'No content', headers: { 'Location' => { description: 'Location of resource', type: 'string' } } }
23+
success foo
2324
failure [[400, 'Bad Request', Entities::ApiError, { 'application/json' => { code: 400, message: 'Bad request' } }, { 'Date' => { description: 'Date of failure', type: 'string' } }]]
2425
end
2526
delete '/no_content_response_headers' do
2627
{ 'declared_params' => declared(params) }
2728
end
2829

2930
desc 'A file can have headers too' do
30-
success Hash[status: 200, model: 'File', headers: { 'Cache-Control' => { description: 'Directive for caching', type: 'string' } }]
31+
foo = { status: 200, model: 'File', headers: { 'Cache-Control': { description: 'Directive for caching', type: 'string' } } }
32+
success foo
3133
failure [[404, 'NotFound', Entities::ApiError, { 'application/json' => { code: 404, message: 'Not found' } }, { 'Date' => { description: 'Date of failure', type: 'string' } }]]
3234
end
3335
get '/file_response_headers' do

0 commit comments

Comments
 (0)