active_record_in_time_scope 0.1.7
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 +7 -0
- data/.rubocop.yml +47 -0
- data/.rulesync/commands/translate-readme.md +46 -0
- data/.rulesync/rules/project.md +87 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +191 -0
- data/Rakefile +10 -0
- data/Steepfile +25 -0
- data/docs/book.toml +14 -0
- data/docs/de/SUMMARY.md +5 -0
- data/docs/de/index.md +192 -0
- data/docs/de/point-system.md +295 -0
- data/docs/de/user-name-history.md +164 -0
- data/docs/fr/SUMMARY.md +5 -0
- data/docs/fr/index.md +192 -0
- data/docs/fr/point-system.md +295 -0
- data/docs/fr/user-name-history.md +164 -0
- data/docs/ja/SUMMARY.md +5 -0
- data/docs/ja/index.md +192 -0
- data/docs/ja/point-system.md +295 -0
- data/docs/ja/user-name-history.md +164 -0
- data/docs/src/SUMMARY.md +5 -0
- data/docs/src/index.md +194 -0
- data/docs/src/point-system.md +295 -0
- data/docs/src/user-name-history.md +164 -0
- data/docs/zh/SUMMARY.md +5 -0
- data/docs/zh/index.md +192 -0
- data/docs/zh/point-system.md +295 -0
- data/docs/zh/user-name-history.md +164 -0
- data/lib/active_record_in_time_scope/class_methods.rb +457 -0
- data/lib/active_record_in_time_scope/version.rb +6 -0
- data/lib/active_record_in_time_scope.rb +132 -0
- data/mise.toml +2 -0
- data/rbs_collection.yaml +16 -0
- data/rulesync.jsonc +6 -0
- data/sig/active_record_in_time_scope.rbs +95 -0
- metadata +223 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Type definitions for ActiveRecordInTimeScope gem
|
|
2
|
+
|
|
3
|
+
module ActiveRecordInTimeScope
|
|
4
|
+
VERSION: String
|
|
5
|
+
|
|
6
|
+
# Base error class for ActiveRecordInTimeScope errors
|
|
7
|
+
class Error < StandardError
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Raised when a specified column does not exist on the table
|
|
11
|
+
class ColumnNotFoundError < Error
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Raised when the scope configuration is invalid
|
|
15
|
+
class ConfigurationError < Error
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.included: (Class model) -> void
|
|
19
|
+
|
|
20
|
+
# Configuration options for start_at column
|
|
21
|
+
type start_at_config = {
|
|
22
|
+
?column: Symbol?,
|
|
23
|
+
?null: bool
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
# Configuration options for end_at column
|
|
27
|
+
type end_at_config = {
|
|
28
|
+
?column: Symbol?,
|
|
29
|
+
?null: bool
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# Class methods added to ActiveRecord models when ActiveRecordInTimeScope is included
|
|
33
|
+
module ClassMethods
|
|
34
|
+
# Defines time-window scopes for the model
|
|
35
|
+
#
|
|
36
|
+
# @param scope_name [Symbol] The name of the scope (default: :in_time)
|
|
37
|
+
# @param start_at [Hash] Configuration for the start column
|
|
38
|
+
# @param end_at [Hash] Configuration for the end column
|
|
39
|
+
# @return [void]
|
|
40
|
+
# @raise [ColumnNotFoundError] When a specified column doesn't exist
|
|
41
|
+
# @raise [ConfigurationError] When the configuration is invalid (at scope call time)
|
|
42
|
+
def in_time_scope: (
|
|
43
|
+
?Symbol scope_name,
|
|
44
|
+
?start_at: start_at_config,
|
|
45
|
+
?end_at: end_at_config
|
|
46
|
+
) -> void
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
# Private implementation methods
|
|
51
|
+
# These use ActiveRecord internals and are typed as untyped for flexibility
|
|
52
|
+
def fetch_null_option: (untyped config, untyped column, untyped table_column_hash) -> untyped
|
|
53
|
+
def start_only_pattern?: (Symbol? start_at_column, Symbol? end_at_column) -> bool
|
|
54
|
+
def end_only_pattern?: (Symbol? start_at_column, Symbol? end_at_column) -> bool
|
|
55
|
+
def define_scope_methods: (String suffix, start_at_column: untyped, start_at_null: untyped, end_at_column: untyped, end_at_null: untyped) -> void
|
|
56
|
+
def define_error_scope_and_method: (String suffix, String message) -> void
|
|
57
|
+
def define_start_only_scope: (String suffix, Symbol column) -> void
|
|
58
|
+
def define_latest_one_scope: (String suffix, Symbol column) -> void
|
|
59
|
+
def define_earliest_one_scope: (String suffix, Symbol column) -> void
|
|
60
|
+
def define_end_only_scope: (String suffix, Symbol column) -> void
|
|
61
|
+
def define_full_scope: (String suffix, Symbol start_column, untyped start_null, Symbol end_column, untyped end_null) -> void
|
|
62
|
+
def define_instance_method: (String suffix, Symbol? start_column, untyped start_null, Symbol? end_column, untyped end_null) -> void
|
|
63
|
+
def define_before_scope: (String suffix, Symbol? start_column, untyped start_null) -> void
|
|
64
|
+
def define_after_scope: (String suffix, Symbol? end_column, untyped end_null) -> void
|
|
65
|
+
def define_out_of_time_scope: (String suffix) -> void
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Generated scope methods (dynamically defined)
|
|
70
|
+
# When you call `in_time_scope` on a model, it creates these methods:
|
|
71
|
+
#
|
|
72
|
+
# Class methods (primary - records in time window):
|
|
73
|
+
# Model.in_time(time = Time.current) -> ActiveRecord::Relation
|
|
74
|
+
# Model.in_time_<name>(time = Time.current) -> ActiveRecord::Relation (for named scopes)
|
|
75
|
+
# Model.latest_in_time(foreign_key, time = Time.current) -> ActiveRecord::Relation (start-only/end-only)
|
|
76
|
+
# Model.earliest_in_time(foreign_key, time = Time.current) -> ActiveRecord::Relation (start-only/end-only)
|
|
77
|
+
#
|
|
78
|
+
# Class methods (inverse - records outside time window):
|
|
79
|
+
# Model.before_in_time(time = Time.current) -> ActiveRecord::Relation (not yet started)
|
|
80
|
+
# Model.after_in_time(time = Time.current) -> ActiveRecord::Relation (already ended)
|
|
81
|
+
# Model.out_of_time(time = Time.current) -> ActiveRecord::Relation (before OR after)
|
|
82
|
+
#
|
|
83
|
+
# Instance methods (primary):
|
|
84
|
+
# model.in_time?(time = Time.current) -> bool
|
|
85
|
+
# model.in_time_<name>?(time = Time.current) -> bool (for named scopes)
|
|
86
|
+
#
|
|
87
|
+
# Instance methods (inverse):
|
|
88
|
+
# model.before_in_time?(time = Time.current) -> bool
|
|
89
|
+
# model.after_in_time?(time = Time.current) -> bool
|
|
90
|
+
# model.out_of_time?(time = Time.current) -> bool
|
|
91
|
+
|
|
92
|
+
# Extend ActiveRecord::Base to include ActiveRecordInTimeScope
|
|
93
|
+
class ActiveRecord::Base
|
|
94
|
+
extend ActiveRecordInTimeScope::ClassMethods
|
|
95
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: active_record_in_time_scope
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.7
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- kyohah
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: activerecord
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '6.1'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '6.1'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: irb
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: rake
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '13.0'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '13.0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: rbs
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: rspec
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0'
|
|
75
|
+
type: :development
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '0'
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: rubocop
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "~>"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '1.21'
|
|
89
|
+
type: :development
|
|
90
|
+
prerelease: false
|
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - "~>"
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '1.21'
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: sqlite3
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - ">="
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '0'
|
|
103
|
+
type: :development
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - ">="
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0'
|
|
110
|
+
- !ruby/object:Gem::Dependency
|
|
111
|
+
name: steep
|
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
|
113
|
+
requirements:
|
|
114
|
+
- - ">="
|
|
115
|
+
- !ruby/object:Gem::Version
|
|
116
|
+
version: '0'
|
|
117
|
+
type: :development
|
|
118
|
+
prerelease: false
|
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - ">="
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '0'
|
|
124
|
+
- !ruby/object:Gem::Dependency
|
|
125
|
+
name: timecop
|
|
126
|
+
requirement: !ruby/object:Gem::Requirement
|
|
127
|
+
requirements:
|
|
128
|
+
- - ">="
|
|
129
|
+
- !ruby/object:Gem::Version
|
|
130
|
+
version: '0'
|
|
131
|
+
type: :development
|
|
132
|
+
prerelease: false
|
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
134
|
+
requirements:
|
|
135
|
+
- - ">="
|
|
136
|
+
- !ruby/object:Gem::Version
|
|
137
|
+
version: '0'
|
|
138
|
+
- !ruby/object:Gem::Dependency
|
|
139
|
+
name: yard
|
|
140
|
+
requirement: !ruby/object:Gem::Requirement
|
|
141
|
+
requirements:
|
|
142
|
+
- - ">="
|
|
143
|
+
- !ruby/object:Gem::Version
|
|
144
|
+
version: '0'
|
|
145
|
+
type: :development
|
|
146
|
+
prerelease: false
|
|
147
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
148
|
+
requirements:
|
|
149
|
+
- - ">="
|
|
150
|
+
- !ruby/object:Gem::Version
|
|
151
|
+
version: '0'
|
|
152
|
+
description: ActiveRecordInTimeScope provides time-window scopes for ActiveRecord
|
|
153
|
+
models.
|
|
154
|
+
email:
|
|
155
|
+
- 3257272+kyohah@users.noreply.github.com
|
|
156
|
+
executables: []
|
|
157
|
+
extensions: []
|
|
158
|
+
extra_rdoc_files: []
|
|
159
|
+
files:
|
|
160
|
+
- ".rubocop.yml"
|
|
161
|
+
- ".rulesync/commands/translate-readme.md"
|
|
162
|
+
- ".rulesync/rules/project.md"
|
|
163
|
+
- CHANGELOG.md
|
|
164
|
+
- CODE_OF_CONDUCT.md
|
|
165
|
+
- LICENSE.txt
|
|
166
|
+
- README.md
|
|
167
|
+
- Rakefile
|
|
168
|
+
- Steepfile
|
|
169
|
+
- docs/book.toml
|
|
170
|
+
- docs/de/SUMMARY.md
|
|
171
|
+
- docs/de/index.md
|
|
172
|
+
- docs/de/point-system.md
|
|
173
|
+
- docs/de/user-name-history.md
|
|
174
|
+
- docs/fr/SUMMARY.md
|
|
175
|
+
- docs/fr/index.md
|
|
176
|
+
- docs/fr/point-system.md
|
|
177
|
+
- docs/fr/user-name-history.md
|
|
178
|
+
- docs/ja/SUMMARY.md
|
|
179
|
+
- docs/ja/index.md
|
|
180
|
+
- docs/ja/point-system.md
|
|
181
|
+
- docs/ja/user-name-history.md
|
|
182
|
+
- docs/src/SUMMARY.md
|
|
183
|
+
- docs/src/index.md
|
|
184
|
+
- docs/src/point-system.md
|
|
185
|
+
- docs/src/user-name-history.md
|
|
186
|
+
- docs/zh/SUMMARY.md
|
|
187
|
+
- docs/zh/index.md
|
|
188
|
+
- docs/zh/point-system.md
|
|
189
|
+
- docs/zh/user-name-history.md
|
|
190
|
+
- lib/active_record_in_time_scope.rb
|
|
191
|
+
- lib/active_record_in_time_scope/class_methods.rb
|
|
192
|
+
- lib/active_record_in_time_scope/version.rb
|
|
193
|
+
- mise.toml
|
|
194
|
+
- rbs_collection.yaml
|
|
195
|
+
- rulesync.jsonc
|
|
196
|
+
- sig/active_record_in_time_scope.rbs
|
|
197
|
+
homepage: https://github.com/kyohah/active_record_in_time_scope
|
|
198
|
+
licenses:
|
|
199
|
+
- MIT
|
|
200
|
+
metadata:
|
|
201
|
+
allowed_push_host: https://rubygems.org
|
|
202
|
+
rubygems_mfa_required: 'true'
|
|
203
|
+
homepage_uri: https://github.com/kyohah/active_record_in_time_scope
|
|
204
|
+
source_code_uri: https://github.com/kyohah/active_record_in_time_scope
|
|
205
|
+
changelog_uri: https://github.com/kyohah/active_record_in_time_scope/blob/main/CHANGELOG.md
|
|
206
|
+
rdoc_options: []
|
|
207
|
+
require_paths:
|
|
208
|
+
- lib
|
|
209
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
210
|
+
requirements:
|
|
211
|
+
- - ">="
|
|
212
|
+
- !ruby/object:Gem::Version
|
|
213
|
+
version: 4.0.0
|
|
214
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
|
+
requirements:
|
|
216
|
+
- - ">="
|
|
217
|
+
- !ruby/object:Gem::Version
|
|
218
|
+
version: '0'
|
|
219
|
+
requirements: []
|
|
220
|
+
rubygems_version: 4.0.7
|
|
221
|
+
specification_version: 4
|
|
222
|
+
summary: Add time-window scopes to ActiveRecord models
|
|
223
|
+
test_files: []
|