rails-on-sorbet 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -1
- data/README.md +16 -3
- data/lib/rails/on/sorbet/current_attributes.rb +18 -24
- data/lib/rails/on/sorbet/map.rb +0 -10
- data/lib/rails/on/sorbet/version.rb +1 -1
- data/lib/tapioca/dsl/compilers/rails_on_sorbet_currrent_attributes.rb +2 -2
- metadata +1 -3
- data/lib/rails/on/sorbet/map.rbi +0 -935
- data/lib/rails/on/sorbet/shims.rbi +0 -598
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 829640700a30c44c134bd05f675cfbf4eb45f43c78d90cd87f52a25f1a8983bd
|
4
|
+
data.tar.gz: 7f50468584b1edc3c2d419c91758bb2f731468bcff1f22642dd81000484f7c77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b98bee4beaaaf076fa5380d796fd80fa6f257f67a1ad6e52fb38264cc696b12803b9ac0a5020024372207a1c2e8627d684ab997aebd62f5dc3ed9238d55d495e
|
7
|
+
data.tar.gz: cd792edc2489914c401f3832ef28b7a69ebe54b15a28ae3ac5fe7bcef24759715b5958e4ae106d37562b6dbf211e542dcc0d8ec4b9a07f1b94b3ada12dd34522
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,34 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
1
8
|
## [Unreleased]
|
2
9
|
|
3
|
-
|
10
|
+
Add changes in new features here. Do not change the gem's version in pull/merge requests.
|
11
|
+
|
12
|
+
### Changes
|
13
|
+
-
|
14
|
+
|
15
|
+
## [0.2.0] - 18.09.2025
|
16
|
+
|
17
|
+
[Diff](https://github.com/espago/rails-on-sorbet/compare/v0.1.1...v0.2.0)
|
18
|
+
|
19
|
+
### Changes
|
20
|
+
- Change `Rails::On::Sorbet::CurrentAttributes` from a module to a class
|
21
|
+
- Favour using `Rails::On::Sorbet::CurrentAttributes` instead of `ActiveSupport::CurrentAttributes`
|
22
|
+
|
23
|
+
## [0.1.1] - 18.09.2025
|
24
|
+
|
25
|
+
[Diff](https://github.com/espago/rails-on-sorbet/compare/v0.1.0...v0.1.1)
|
26
|
+
|
27
|
+
### Changes
|
28
|
+
- Fix `.rbi` file placing
|
29
|
+
|
30
|
+
## [0.1.0] - 18.09.2025
|
31
|
+
|
32
|
+
[Diff](https://github.com/espago/rails-on-sorbet/compare/v0.0.0...v0.1.0)
|
4
33
|
|
5
34
|
- Initial release
|
data/README.md
CHANGED
@@ -16,6 +16,17 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
16
16
|
gem install rails-on-sorbet
|
17
17
|
```
|
18
18
|
|
19
|
+
It is recommended to disable strict typechecking for this gem's RBI files
|
20
|
+
generated by tapioca.
|
21
|
+
|
22
|
+
This can be done by adding these lines to `sorbet/tapioca/config.yml`:
|
23
|
+
|
24
|
+
```yml
|
25
|
+
gem:
|
26
|
+
typed_overrides:
|
27
|
+
rails-on-sorbet: "false"
|
28
|
+
```
|
29
|
+
|
19
30
|
## Usage
|
20
31
|
|
21
32
|
This gem adds additional signatures to Rails types and builtin Ruby types that
|
@@ -90,15 +101,17 @@ Example:
|
|
90
101
|
f.owner == f.user #=> true
|
91
102
|
```
|
92
103
|
|
93
|
-
###
|
104
|
+
### Rails::On::Sorbet::CurrentAttributes
|
105
|
+
|
106
|
+
This is a subclass of `ActiveSupport::CurrentAttributes` with tapioca/sorbet support.
|
94
107
|
|
95
|
-
New optional keyword arguments have been added to `
|
108
|
+
New optional keyword arguments have been added to `attribute`:
|
96
109
|
- `type`: the sorbet type of the getter/setter
|
97
110
|
- `doc`: a docstring whose content will be used to generate a comment above the rbi signature created by tapioca
|
98
111
|
|
99
112
|
Example:
|
100
113
|
```rb
|
101
|
-
class Current <
|
114
|
+
class Current < Rails::On::Sorbet::CurrentAttributes
|
102
115
|
attribute :session_counter, type: T.nilable(Integer), doc: <<~DOC
|
103
116
|
A counter that gets incremented when a new session is created.
|
104
117
|
DOC
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# typed: false
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
require 'active_support'
|
5
|
+
|
4
6
|
module Rails::On::Sorbet
|
5
7
|
# Shim for ActiveSupport::CurrentAttributes to support sorbet
|
6
|
-
|
7
|
-
# @requires_ancestor: singleton(ActiveSupport::CurrentAttributes)
|
8
|
-
module CurrentAttributes
|
8
|
+
class CurrentAttributes < ActiveSupport::CurrentAttributes
|
9
9
|
# Holds the data of a single attribute definition
|
10
10
|
class Attribute
|
11
11
|
#: Symbol
|
@@ -25,29 +25,23 @@ module Rails::On::Sorbet
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
28
|
+
class << self
|
29
|
+
# Get a map with all defined attributes and their types
|
30
|
+
#
|
31
|
+
#: -> Hash[Symbol, Attribute]
|
32
|
+
def attribute_map
|
33
|
+
@attribute_map ||= {}
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
36
|
+
# Declare a new attribute with a sorbet type
|
37
|
+
#
|
38
|
+
#: (*Symbol, ?type: untyped, ?doc: String?, ?default: untyped) -> void
|
39
|
+
def attribute(*names, type: nil, doc: nil, default: ::ActiveSupport::CurrentAttributes::NOT_SET)
|
40
|
+
names.each do |name|
|
41
|
+
attribute_map[name] = Attribute.new(name, type, doc)
|
42
|
+
end
|
43
|
+
super(*names, default: default)
|
41
44
|
end
|
42
|
-
super(*names, default: default)
|
43
45
|
end
|
44
46
|
end
|
45
47
|
end
|
46
|
-
|
47
|
-
require 'active_support'
|
48
|
-
|
49
|
-
module ActiveSupport
|
50
|
-
class CurrentAttributes # rubocop:disable Style/StaticClass
|
51
|
-
extend Rails::On::Sorbet::CurrentAttributes
|
52
|
-
end
|
53
|
-
end
|
data/lib/rails/on/sorbet/map.rb
CHANGED
@@ -9,13 +9,3 @@ module Map
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def Map(val) = val # rubocop:disable Style/TopLevelMethodDefinition,Naming/MethodName
|
12
|
-
|
13
|
-
#: [K = String, V = untyped]
|
14
|
-
class ActionController::Parameters
|
15
|
-
include Map
|
16
|
-
end
|
17
|
-
|
18
|
-
#: [K = String, V = untyped]
|
19
|
-
class ActiveSupport::HashWithIndifferentAccess
|
20
|
-
include Map
|
21
|
-
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
module Tapioca
|
5
5
|
module Compilers
|
6
|
-
#: [ConstantType =
|
6
|
+
#: [ConstantType = singleton(::Rails::On::Sorbet::CurrentAttributes)]
|
7
7
|
class RailsOnSorbetCurrentAttributes < Tapioca::Dsl::Compiler
|
8
8
|
|
9
9
|
class << self
|
@@ -11,7 +11,7 @@ module Tapioca
|
|
11
11
|
#: -> Enumerable[Module]
|
12
12
|
def gather_constants
|
13
13
|
all_classes.select do |klass|
|
14
|
-
klass
|
14
|
+
klass < ::Rails::On::Sorbet::CurrentAttributes
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-on-sorbet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mateusz Drewniak
|
@@ -68,8 +68,6 @@ files:
|
|
68
68
|
- lib/rails/on/sorbet/alias_association.rb
|
69
69
|
- lib/rails/on/sorbet/current_attributes.rb
|
70
70
|
- lib/rails/on/sorbet/map.rb
|
71
|
-
- lib/rails/on/sorbet/map.rbi
|
72
|
-
- lib/rails/on/sorbet/shims.rbi
|
73
71
|
- lib/rails/on/sorbet/timelike.rb
|
74
72
|
- lib/rails/on/sorbet/version.rb
|
75
73
|
- lib/tapioca/dsl/compilers/rails_on_sorbet_active_record_serializer.rb
|