Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Ruby 3.3.0 and Implement GA Ruby Version Matrix Testing #148

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/versionci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Version CI
on:
pull_request:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: ["3.2.0", "3.2.2", "3.3.0"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to specify "all patch versions greater than 3.2.0"? Or better yet, "all latest stable releases greater than X"? Or will we need to update this as and when new releases have come out?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the rationale for testing 3.2.2 in addition to 3.2.0? Optimistically, a patch release should only contain backwards-compatible bug fixes. Also, the Ruby site says 3.2.4 is the latest stable, so maybe 3.2.2 is already outdated if we are sticking with testing all patched versions?
Image 2024-05-24 at 4 14 58 PM

steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rspec
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.6.5
3.3.0
139 changes: 88 additions & 51 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,68 +1,101 @@
PATH
remote: .
specs:
decanter (4.0.4)
actionpack (>= 4.2.10)
decanter (5.0.0)
actionpack (>= 7.1.3.2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change essentially restrict the usage of Decanter v5 to apps with Rails 7 and above?

activesupport
rails-html-sanitizer (>= 1.0.4)

GEM
remote: https://rubygems.org/
specs:
actionpack (5.2.4.4)
actionview (= 5.2.4.4)
activesupport (= 5.2.4.4)
rack (~> 2.0, >= 2.0.8)
actionpack (7.1.3.2)
actionview (= 7.1.3.2)
activesupport (= 7.1.3.2)
nokogiri (>= 1.8.5)
racc
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.2.4.4)
activesupport (= 5.2.4.4)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
actionview (7.1.3.2)
activesupport (= 7.1.3.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activesupport (5.2.4.4)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activesupport (7.1.3.2)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
base64 (0.2.0)
bigdecimal (3.1.7)
builder (3.2.4)
concurrent-ruby (1.1.7)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
crass (1.0.6)
diff-lcs (1.4.4)
diff-lcs (1.5.1)
docile (1.1.5)
dotenv (2.2.1)
erubi (1.9.0)
i18n (1.8.5)
dotenv (3.1.1)
drb (2.2.1)
erubi (1.12.0)
i18n (1.14.4)
concurrent-ruby (~> 1.0)
json (2.3.0)
loofah (2.7.0)
io-console (0.7.2)
irb (1.13.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.7.2)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
method_source (1.0.0)
mini_portile2 (2.4.0)
minitest (5.14.2)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.12.0)
minitest (5.22.3)
mutex_m (0.2.0)
nokogiri (1.16.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.4-x86_64-linux)
racc (~> 1.4)
psych (5.1.2)
stringio
racc (1.7.3)
rack (3.0.10)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
loofah (~> 2.3)
railties (5.2.4.4)
actionpack (= 5.2.4.4)
activesupport (= 5.2.4.4)
method_source
rake (>= 0.8.7)
thor (>= 0.19.0, < 2.0)
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.1.3.2)
actionpack (= 7.1.3.2)
activesupport (= 7.1.3.2)
irb
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rake (12.3.3)
rdoc (6.6.3.1)
psych (>= 4.0.0)
reline (0.5.5)
io-console (~> 0.5)
rspec-core (3.9.3)
rspec-support (~> 3.9.3)
rspec-expectations (3.9.3)
rspec-expectations (3.9.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-mocks (3.9.1)
Expand All @@ -82,21 +115,25 @@ GEM
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
stringio (3.1.0)
thor (1.3.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
webrick (1.8.1)
zeitwerk (2.6.13)

PLATFORMS
ruby
arm64-darwin-22
arm64-darwin-23
x86_64-linux

DEPENDENCIES
bundler (~> 1.9)
bundler (~> 2.4.22)
decanter!
dotenv
rake (~> 12.0)
rspec-rails (~> 3.9)
simplecov (~> 0.15.1)

BUNDLED WITH
1.17.3
2.4.22
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Decanter is a Ruby gem that makes it easy to transform incoming data before it hits the model. You can think of Decanter as the opposite of Active Model Serializers (AMS). While AMS transforms your outbound data into a format that your frontend consumes, Decanter transforms your incoming data into a format that your backend consumes.

```ruby
gem 'decanter', '~> 4.0'
gem 'decanter', '~> 5.0'
```

## Migration Guides
Expand Down Expand Up @@ -77,6 +77,7 @@ end
```

#### Parsers

```
rails g parser TruncatedString

Expand Down Expand Up @@ -133,8 +134,8 @@ You can use the `is_collection` option for explicit control over decanting colle
If this option is not provided, autodetect logic is used to determine if the providing incoming params holds a single object or collection of objects.

- `nil` or not provided: will try to autodetect single vs collection
- `true` will always treat the incoming params args as *collection*
- `false` will always treat incoming params args as *single object*
- `true` will always treat the incoming params args as _collection_
- `false` will always treat incoming params args as _single object_
- `truthy` will raise an error

### Nested resources
Expand Down Expand Up @@ -178,10 +179,11 @@ Some parsers can receive options that modify their behavior. These options are p
```ruby
input :start_date, :date, parse_format: '%Y-%m-%d'
```

**Available Options:**
| Parser | Option | Default | Notes
| Parser | Option | Default | Notes
| ----------- | ----------- | -----------| -----------
| `ArrayParser` | `parse_each`| N/A | Accepts a parser type, then uses that parser to parse each element in the array. If this option is not defined, each element is simply returned.
| `ArrayParser` | `parse_each`| N/A | Accepts a parser type, then uses that parser to parse each element in the array. If this option is not defined, each element is simply returned.
| `DateParser`| `parse_format` | `'%m/%d/%Y'`| Accepts any format string accepted by Ruby's `strftime` method
| `DateTimeParser` | `parse_format` | `'%m/%d/%Y %I:%M:%S %p'` | Accepts any format string accepted by Ruby's `strftime` method

Expand Down Expand Up @@ -299,7 +301,6 @@ end

_Note: we recommend using [Active Record validations](https://guides.rubyonrails.org/active_record_validations.html) to check for presence of an attribute, rather than using the `required` option. This method is intended for use in non-RESTful routes or cases where Active Record validations are not available._


### Default values

If you provide the option `:default_value` for an input in your decanter, the input key will be initialized with the given default value. Input keys not found in the incoming data parameters will be set to the provided default rather than ignoring the missing key. Note: `nil` and empty keys will not be overridden.
Expand Down
20 changes: 9 additions & 11 deletions decanter.gemspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'decanter/version'

Expand All @@ -9,29 +8,28 @@ Gem::Specification.new do |spec|
spec.authors = ['Ryan Francis', 'David Corwin']
spec.email = ['[email protected]']

spec.summary = %q{Form Parser for Rails}
spec.description = %q{Decanter aims to reduce complexity in Rails controllers by creating a place for transforming data before it hits the model and database.}
spec.summary = 'Form Parser for Rails'
spec.description = 'Decanter aims to reduce complexity in Rails controllers by creating a place for transforming data before it hits the model and database.'
spec.homepage = 'https://github.com/launchpadlab/decanter'
spec.license = 'MIT'
spec.required_ruby_version = '>= 3.2.0'

# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
# delete this section to allow pushing this gem to any host.
if spec.respond_to?(:metadata)
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
else
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
end
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)

spec.metadata['allowed_push_host'] = 'https://rubygems.org'

spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']

spec.add_dependency 'actionpack', '>= 4.2.10'
spec.add_dependency 'actionpack', '>= 7.1.3.2'
spec.add_dependency 'activesupport'
spec.add_dependency 'rails-html-sanitizer', '>= 1.0.4'

spec.add_development_dependency 'bundler', '~> 1.9'
spec.add_development_dependency 'bundler', '~> 2.4.22'
spec.add_development_dependency 'dotenv'
spec.add_development_dependency 'rake', '~> 12.0'
spec.add_development_dependency 'rspec-rails', '~> 3.9'
Expand Down
Loading
Loading