Skip to content

Commit

Permalink
Make the gem ruby 3.1+ friendly (#121)
Browse files Browse the repository at this point in the history
* Use a new uploadcare-ruby version, bump version

* Fix rubocop offences

* Remove unsupported versions of Rails

* Use older rspec-rails for Rails 6 compatibility

* Add 3.3.0 to changelog
  • Loading branch information
kraft001 authored Mar 15, 2023
1 parent 9187e36 commit b853544
Show file tree
Hide file tree
Showing 22 changed files with 92 additions and 167 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gem-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Release Gem
if: contains(github.ref, 'refs/tags/v')
uses: cadwallion/publish-rubygems-action@v1.0.0
uses: cadwallion/publish-rubygems-action@master
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
Expand Down
63 changes: 9 additions & 54 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,82 +7,37 @@ jobs:
matrix:
gemfile:
- Gemfile
- gemfiles/Gemfile-rails-7-0
- gemfiles/Gemfile-rails-6-1
- gemfiles/Gemfile-rails-6-0
- gemfiles/Gemfile-rails-5-2
- gemfiles/Gemfile-rails-5-1
- gemfiles/Gemfile-rails-5-0
- gemfiles/Gemfile-rails-4-2
- gemfiles/Gemfile-rails-4-1
ruby:
- 2.4
- 2.5
- 2.6
- 2.7
- 3.0
exclude:
- ruby: 2.4
gemfile: Gemfile
- ruby: 2.4
gemfile: gemfiles/Gemfile-rails-6-1
- ruby: 2.4
gemfile: gemfiles/Gemfile-rails-6-0
- ruby: 2.4
gemfile: gemfiles/Gemfile-rails-4-1
- ruby: 2.5
gemfile: gemfiles/Gemfile-rails-4-1
- ruby: 2.5
gemfile: gemfiles/Gemfile-rails-6-0
- ruby: 2.5
gemfile: gemfiles/Gemfile-rails-6-1
- ruby: 2.6
gemfile: gemfiles/Gemfile-rails-4-1
- ruby: 2.6
gemfile: gemfiles/Gemfile-rails-4-2
- ruby: 2.7
gemfile: gemfiles/Gemfile-rails-4-1
- ruby: 2.7
gemfile: gemfiles/Gemfile-rails-4-2
- ruby: 2.7
gemfile: gemfiles/Gemfile-rails-5-0
- ruby: 2.7
gemfile: gemfiles/Gemfile-rails-5-1
- ruby: 2.7
gemfile: gemfiles/Gemfile-rails-5-2
- ruby: 3.0
gemfile: gemfiles/Gemfile-rails-4-1
- ruby: 3.0
gemfile: gemfiles/Gemfile-rails-4-2
- ruby: 3.0
gemfile: gemfiles/Gemfile-rails-5-0
- ruby: 3.0
gemfile: gemfiles/Gemfile-rails-5-1
- ruby: 3.0
gemfile: gemfiles/Gemfile-rails-5-2
- 3.1
- 3.2
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
UPLOADCARE_PUBLIC_KEY: demopublickey
UPLOADCARE_SECRET_KEY: demoprivatekey
steps:
- uses: actions/checkout@v2
- name: Setup Bundler 1.x for Rails 4.x
if: ${{ matrix.ruby == '2.4' || matrix.ruby == '2.5' }}
run: echo "BUNDLER_VERSION=1.17.3" >> $GITHUB_ENV
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true # runs bundle install and caches installed gems automatically
bundler: ${{ env.BUNDLER_VERSION || 'latest' }}
bundler: latest
- run: bundle exec rake

code-analysis:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.7',]
ruby-version:
- 2.7
- 3.2
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ spec/tmp

.idea
Gemfile.lock

.ruby-version
project_files
*.gem
8 changes: 8 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
AllCops:
NewCops: enable
TargetRubyVersion: 2.7
Exclude:
- 'spec/tmp/**/*.rb'
- 'vendor/**/*'
Expand Down Expand Up @@ -26,3 +28,9 @@ Style/HashTransformKeys:
Exclude:
- 'lib/uploadcare/rails/action_view/uploadcare_uploader_tags.rb'
- 'lib/uploadcare/rails/transformations/image_transformations.rb'

Style/OpenStructUse:
Exclude:
- 'spec/uploadcare/rails/active_record/mount_uploadcare_file_spec.rb'
- 'spec/uploadcare/rails/active_record/mount_uploadcare_group_spec.rb'
- 'spec/uploadcare/rails/objects/file_spec.rb'
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
The format is based now on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 3.3.0 — 2023-03-16

Guarantee support of maintainable versions of Ruby and Rails

### Breaking Сhanges

Drop support of unmaintainable Ruby 2.4, 2.5, 2.6 and Rails before 6.0

### Added

Add support of Ruby 3.1 and 3.2 and Rails 7.0

## 3.0.0 — 2022-12-29

This version supports latest Uploadcare REST API — [v0.7](https://uploadcare.com/api-refs/rest-api/v0.7.0/), which introduces new file management features:
Expand Down
13 changes: 0 additions & 13 deletions gemfiles/Gemfile-rails-4-1

This file was deleted.

13 changes: 0 additions & 13 deletions gemfiles/Gemfile-rails-4-2

This file was deleted.

8 changes: 0 additions & 8 deletions gemfiles/Gemfile-rails-5-0

This file was deleted.

8 changes: 0 additions & 8 deletions gemfiles/Gemfile-rails-5-1

This file was deleted.

8 changes: 0 additions & 8 deletions gemfiles/Gemfile-rails-5-2

This file was deleted.

3 changes: 0 additions & 3 deletions gemfiles/Gemfile-rails-6-0
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ source "https://rubygems.org"
gemspec path: ".."

gem "rails", '~> 6.0.0', github: 'rails/rails', branch: '6-0-stable'

gem 'rake', '~> 13.0.6'
gem 'rspec', '~> 3.10'
3 changes: 0 additions & 3 deletions gemfiles/Gemfile-rails-6-1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ source "https://rubygems.org"
gemspec path: ".."

gem "rails", '~> 6.1.0', github: 'rails/rails', branch: '6-1-stable'

gem 'rake', '~> 13.0.6'
gem 'rspec', '~> 3.10'
5 changes: 5 additions & 0 deletions gemfiles/Gemfile-rails-7-0
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source "https://rubygems.org"

gemspec path: ".."

gem "rails", '~> 7.0.0', github: 'rails/rails', branch: '7-0-stable'
5 changes: 3 additions & 2 deletions lib/uploadcare/rails/api/rest/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ module Uploadcare
module Rails
module Api
module Rest
class Base
end
# rubocop:disable Lint/EmptyClass
class Base; end
# rubocop:enable Lint/EmptyClass
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions lib/uploadcare/rails/api/upload/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ module Uploadcare
module Rails
module Api
module Upload
# rubocop:disable Lint/EmptyClass
class Base; end
# rubocop:enable Lint/EmptyClass
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/uploadcare/rails/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def uploader_parameters
end

def widget
OpenStruct.new(WIDGET_PARAMS.map { |param| [param, public_send(param)] }.to_h)
Struct
.new(WIDGET_PARAMS)
.new(WIDGET_PARAMS.map { |param| public_send(param) })
end

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ImageTransformations
def initialize(options = {})
raise ArgumentError, "Options argument must be a Hash, #{options.class} is given?" unless options.is_a?(Hash)

@options = options.map { |k, v| [k.to_sym, v] }.to_h
@options = options.to_h { |k, v| [k.to_sym, v] }
end

def call
Expand Down
2 changes: 1 addition & 1 deletion lib/uploadcare/rails/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Uploadcare
module Rails
VERSION = '3.0.0'
VERSION = '3.3.0'
end
end
2 changes: 1 addition & 1 deletion spec/generators/uploadcare_config_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
end

it 'checks that the config file contains the :configure method call' do
expect(File.open(config_file_path).read).to match(/Uploadcare::Rails.configure do |config|/)
expect(File.read(config_file_path)).to match(/Uploadcare::Rails.configure do |config|/)
end
end
end
2 changes: 1 addition & 1 deletion spec/uploadcare/rails/objects/group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
)
end
let(:cache) { Rails.cache }
let(:config) { OpenStruct.new(cache_files: true) }
let(:config) { Struct.new(:cache_files).new(true) }
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }

before do
Expand Down
60 changes: 30 additions & 30 deletions spec/uploadcare/rails/transformations/image_transformations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,36 +72,36 @@
end
let(:expected_string) do
"/preview/#{arguments[:preview]}/-" \
"/resize/#{arguments[:resize]}/-" \
"/smart_resize/#{arguments[:smart_resize]}/-" \
"/crop/#{arguments[:crop].values.join('/')}/-" \
"/scale_crop/#{arguments[:scale_crop].values.join('/')}/-" \
"/setfill/#{arguments[:setfill]}/-" \
"/format/#{arguments[:format]}/-" \
"/quality/#{arguments[:quality]}/-" \
"/progressive/#{arguments[:progressive]}/-" \
'/gif2video/-' \
"/brightness/#{arguments[:brightness]}/-" \
"/exposure/#{arguments[:exposure]}/-" \
"/gamma/#{arguments[:gamma]}/-" \
"/contrast/#{arguments[:contrast]}/-" \
"/saturation/#{arguments[:saturation]}/-" \
"/vibrance/#{arguments[:vibrance]}/-" \
"/warmth/#{arguments[:warmth]}/-" \
"/enhance/#{arguments[:enhance]}/-" \
'/grayscale/-' \
'/invert/-' \
"/filter/#{arguments[:filter].values.join('/')}/-" \
"/srgb/#{arguments[:srgb]}/-" \
"/max_icc_size/#{arguments[:max_icc_size]}/-" \
"/blur/#{arguments[:blur].values.join('/')}/-" \
"/blur_region/#{arguments[:blur_region].values.join('/')}/-" \
"/sharp/#{arguments[:sharp]}/-" \
"/overlay/#{arguments[:overlay].values.join('/')}/-" \
"/autorotate/#{arguments[:autorotate]}/-" \
"/rotate/#{arguments[:rotate]}/-" \
'/flip/-' \
'/mirror/'
"/resize/#{arguments[:resize]}/-" \
"/smart_resize/#{arguments[:smart_resize]}/-" \
"/crop/#{arguments[:crop].values.join('/')}/-" \
"/scale_crop/#{arguments[:scale_crop].values.join('/')}/-" \
"/setfill/#{arguments[:setfill]}/-" \
"/format/#{arguments[:format]}/-" \
"/quality/#{arguments[:quality]}/-" \
"/progressive/#{arguments[:progressive]}/-" \
'/gif2video/-' \
"/brightness/#{arguments[:brightness]}/-" \
"/exposure/#{arguments[:exposure]}/-" \
"/gamma/#{arguments[:gamma]}/-" \
"/contrast/#{arguments[:contrast]}/-" \
"/saturation/#{arguments[:saturation]}/-" \
"/vibrance/#{arguments[:vibrance]}/-" \
"/warmth/#{arguments[:warmth]}/-" \
"/enhance/#{arguments[:enhance]}/-" \
'/grayscale/-' \
'/invert/-' \
"/filter/#{arguments[:filter].values.join('/')}/-" \
"/srgb/#{arguments[:srgb]}/-" \
"/max_icc_size/#{arguments[:max_icc_size]}/-" \
"/blur/#{arguments[:blur].values.join('/')}/-" \
"/blur_region/#{arguments[:blur_region].values.join('/')}/-" \
"/sharp/#{arguments[:sharp]}/-" \
"/overlay/#{arguments[:overlay].values.join('/')}/-" \
"/autorotate/#{arguments[:autorotate]}/-" \
"/rotate/#{arguments[:rotate]}/-" \
'/flip/-' \
'/mirror/'
end

it 'builds image transformations params url' do
Expand Down
Loading

0 comments on commit b853544

Please sign in to comment.