Skip to content

Commit

Permalink
ci: Target Ruby 3.0 as minimum (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxveldink authored Mar 5, 2024
1 parent 5179abe commit 5c12b65
Show file tree
Hide file tree
Showing 15 changed files with 794 additions and 661 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
strategy:
matrix:
ruby:
- '3.0'
- '3.1'
- '3.2'
- '3.3'
Expand Down
3 changes: 1 addition & 2 deletions .standard.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
parallel: true
ruby_version: 3.1
ruby_version: 3.0
ignore:
- 'vendor/**/*'
plugins:
- standard-performance
- standard-sorbet
28 changes: 14 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ GEM
rdoc (6.6.2)
psych (>= 4.0.0)
regexp_parser (2.9.0)
reline (0.4.2)
reline (0.4.3)
io-console (~> 0.5)
rexml (3.2.6)
rubocop (1.60.2)
rubocop (1.61.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand All @@ -64,24 +64,24 @@ GEM
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-ast (1.31.1)
parser (>= 3.3.0.4)
rubocop-performance (1.20.2)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-sorbet (0.7.7)
rubocop (>= 0.90.0)
ruby-progressbar (1.13.0)
sorbet (0.5.11262)
sorbet-static (= 0.5.11262)
sorbet (0.5.11284)
sorbet-static (= 0.5.11284)
sorbet-result (1.1.0)
sorbet-runtime (~> 0.5)
sorbet-runtime (0.5.11262)
sorbet-static (0.5.11262-universal-darwin)
sorbet-static (0.5.11262-x86_64-linux)
sorbet-static-and-runtime (0.5.11262)
sorbet (= 0.5.11262)
sorbet-runtime (= 0.5.11262)
sorbet-runtime (0.5.11284)
sorbet-static (0.5.11284-universal-darwin)
sorbet-static (0.5.11284-x86_64-linux)
sorbet-static-and-runtime (0.5.11284)
sorbet (= 0.5.11284)
sorbet-runtime (= 0.5.11284)
sorbet-struct-comparable (1.3.0)
sorbet-runtime (>= 0.5)
spoom (1.2.4)
Expand Down Expand Up @@ -116,9 +116,9 @@ GEM
spoom (~> 1.2.0, >= 1.2.0)
thor (>= 1.2.0)
yard-sorbet
thor (1.3.0)
thor (1.3.1)
unicode-display_width (2.5.0)
yard (0.9.34)
yard (0.9.36)
yard-sorbet (0.8.1)
sorbet-runtime (>= 0.5)
yard (>= 0.9)
Expand Down
2 changes: 1 addition & 1 deletion lib/sorbet-schema/struct_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.create_schema
Typed::Schema.new(
target: self,
fields: props.map do |name, properties|
Typed::Field.new(name:, type: properties[:type], required: !properties[:fully_optional])
Typed::Field.new(name: name, type: properties[:type], required: !properties[:fully_optional])
end
)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/typed/coercion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ module Coercion
sig { type_parameters(:U).params(field: Field, value: Value).returns(Result[Value, CoercionError]) }
def self.coerce(field:, value:)
if field.type < T::Struct
StructCoercer.coerce(field:, value:)
StructCoercer.coerce(field: field, value: value)
elsif field.type == String
StringCoercer.coerce(field:, value:)
StringCoercer.coerce(field: field, value: value)
else
Failure.new(CoercionNotSupportedError.new)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/typed/field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def optional?

sig { params(value: Value).returns(Validations::ValidationResult) }
def validate(value)
Validations::FieldTypeValidator.new.validate(field: self, value:)
Validations::FieldTypeValidator.new.validate(field: self, value: value)
end
end
end
4 changes: 2 additions & 2 deletions lib/typed/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def deserialize_from_creation_params(creation_params)
if value.nil?
field.validate(value)
elsif value.class != field.type
coercion_result = Coercion.coerce(field:, value:)
coercion_result = Coercion.coerce(field: field, value: value)

if coercion_result.success?
field.validate(coercion_result.payload)
Expand All @@ -51,7 +51,7 @@ def deserialize_from_creation_params(creation_params)
end

Validations::ValidationResults
.new(results:)
.new(results: results)
.combine
.and_then do |validated_params|
Success.new(schema.target.new(**validated_params))
Expand Down
4 changes: 2 additions & 2 deletions lib/typed/validations/field_type_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class FieldTypeValidator
sig { override.params(field: Field, value: Value).returns(ValidationResult) }
def validate(field:, value:)
if field.type == value.class
Success.new(ValidatedValue.new(name: field.name, value:))
Success.new(ValidatedValue.new(name: field.name, value: value))
elsif field.required? && value.nil?
Failure.new(RequiredFieldError.new(field_name: field.name))
elsif field.optional? && value.nil?
Success.new(ValidatedValue.new(name: field.name, value:))
Success.new(ValidatedValue.new(name: field.name, value: value))
else
Failure.new(TypeMismatchError.new(field_name: field.name, field_type: field.type, given_type: value.class))
end
Expand Down
2 changes: 1 addition & 1 deletion sorbet-schema.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
spec.summary = "Serialization and deserialization library into Sorbet structs."
spec.homepage = "https://github.com/maxveldink/sorbet-schema"
spec.license = "MIT"
spec.required_ruby_version = ">= 3.1"
spec.required_ruby_version = ">= 3.0"

spec.metadata["allowed_push_host"] = "https://rubygems.org"
spec.metadata["rubygems_mfa_required"] = "true"
Expand Down
File renamed without changes.
Loading

0 comments on commit 5c12b65

Please sign in to comment.