arfi 0.3.1 → 0.5.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/README.md +139 -35
- data/Steepfile +35 -0
- data/lib/arfi/cli.rb +8 -1
- data/lib/arfi/commands/f_idx.rb +88 -34
- data/lib/arfi/commands/project.rb +20 -3
- data/lib/arfi/extensions/active_record/base.rb +18 -2
- data/lib/arfi/extensions/active_record/connection_adapters/postgresql/database_statements.rb +1 -0
- data/lib/arfi/railtie.rb +1 -1
- data/lib/arfi/sql_function_loader.rb +99 -8
- data/lib/arfi/tasks/db.rake +23 -2
- data/lib/arfi/version.rb +1 -1
- data/rakelib/yard_docs_generator.rake +29 -0
- data/rbs_collection.lock.yaml +452 -0
- data/rbs_collection.yaml +19 -0
- data/sig/lib/arfi/cli.rbs +6 -0
- data/sig/lib/arfi/commands/f_idx.rbs +20 -7
- data/sig/lib/arfi/commands/project.rbs +15 -1
- data/sig/lib/arfi/railtie.rbs +4 -0
- data/sig/lib/arfi/sql_function_loader.rbs +53 -1
- data/sig/lib/arfi/version.rbs +1 -1
- metadata +42 -7
@@ -1,6 +1,8 @@
|
|
1
1
|
module Arfi
|
2
2
|
module Commands
|
3
3
|
class FIdx < Thor
|
4
|
+
ADAPTERS: Array[Symbol]
|
5
|
+
|
4
6
|
# +Arfi::Commands::FIdx#create+ -> void
|
5
7
|
#
|
6
8
|
# This command is used to create the functional index.
|
@@ -21,13 +23,24 @@ module Arfi
|
|
21
23
|
# @example
|
22
24
|
# bundle exec arfi f_idx destroy some_function [revision index (just an integer, 1 is by default)]
|
23
25
|
# @param index_name [String] Name of the index.
|
24
|
-
# @param revision [String] Revision of the index.
|
25
26
|
# @return [void]
|
26
27
|
# @raise [Arfi::Errors::InvalidSchemaFormat] if ActiveRecord.schema_format is not :ruby
|
27
|
-
def destroy: (string index_name
|
28
|
+
def destroy: (string index_name) -> untyped
|
28
29
|
|
29
30
|
private
|
30
31
|
|
32
|
+
# +Arfi::Commands::FIdx#build_from_file+ -> String
|
33
|
+
#
|
34
|
+
# Helper method to build the SQL function. Used with flag `--template`.
|
35
|
+
#
|
36
|
+
# @!visibility private
|
37
|
+
# @private
|
38
|
+
# @param index_name [String] Name of the index.
|
39
|
+
# @return [String] SQL function body.
|
40
|
+
# @see Arfi::Commands::FIdx#create
|
41
|
+
# @see Arfi::Commands::FIdx#build_sql_function
|
42
|
+
def build_from_file: (string index_name) -> String
|
43
|
+
|
31
44
|
# +Arfi::Commands::FIdx#functions_dir+ -> Pathname
|
32
45
|
#
|
33
46
|
# Helper method to get path to `db/functions` directory.
|
@@ -57,7 +70,7 @@ module Arfi
|
|
57
70
|
# @return [String] SQL function body.
|
58
71
|
def build_sql_function: (string index_name) -> ::String
|
59
72
|
|
60
|
-
# +Arfi::Commands::FIdx#
|
73
|
+
# +Arfi::Commands::FIdx#create_function_file+ -> void
|
61
74
|
#
|
62
75
|
# Helper method to create the index file.
|
63
76
|
#
|
@@ -66,7 +79,7 @@ module Arfi
|
|
66
79
|
# @param index_name [String] Name of the index.
|
67
80
|
# @param content [String] SQL function body.
|
68
81
|
# @return [void]
|
69
|
-
def
|
82
|
+
def create_function_file: (string index_name, ::String content) -> untyped
|
70
83
|
|
71
84
|
# +Arfi::Commands::FIdx#extract_latest_version+ -> String
|
72
85
|
#
|
@@ -76,7 +89,7 @@ module Arfi
|
|
76
89
|
# @private
|
77
90
|
# @param files [Array<String>] List of files.
|
78
91
|
# @return [String] Latest version of the index.
|
79
|
-
def extract_latest_version: (Array[String] files) ->
|
92
|
+
def extract_latest_version: (Array[String] files) -> String
|
80
93
|
|
81
94
|
# +Arfi::Commands::FIdx#write_file+ -> void
|
82
95
|
#
|
@@ -86,9 +99,9 @@ module Arfi
|
|
86
99
|
# @private
|
87
100
|
# @param index_name [String] Name of the index.
|
88
101
|
# @param content [String] SQL function body.
|
89
|
-
# @param version [Integer] Version of the index.
|
102
|
+
# @param version [String|Integer] Version of the index.
|
90
103
|
# @return [void]
|
91
|
-
def write_file: (string index_name,
|
104
|
+
def write_file: (string index_name, ::String content, (::String | ::Integer) version) -> void
|
92
105
|
end
|
93
106
|
end
|
94
107
|
end
|
@@ -1,11 +1,25 @@
|
|
1
1
|
module Arfi
|
2
2
|
module Commands
|
3
|
-
class Project
|
3
|
+
class Project
|
4
|
+
ADAPTERS: Array[Symbol]
|
5
|
+
|
6
|
+
# +Arfi::Commands::Project#create+ -> void
|
7
|
+
#
|
8
|
+
# This command is used to create `db/functions` directory.
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# bundle exec arfi project create
|
4
12
|
# @return [void]
|
13
|
+
# @raise [Arfi::Errors::InvalidSchemaFormat] if ActiveRecord.schema_format is not :ruby.
|
5
14
|
def create: () -> void
|
6
15
|
|
7
16
|
private
|
8
17
|
|
18
|
+
# +Arfi::Commands::Project#functions_dir+ -> Pathname
|
19
|
+
#
|
20
|
+
# Helper method to get path to `db/functions` directory.
|
21
|
+
#
|
22
|
+
# @!visibility private
|
9
23
|
# @private
|
10
24
|
# @return [Pathname] Path to `db/functions` directory
|
11
25
|
def functions_dir: () -> Pathname
|
@@ -1,14 +1,66 @@
|
|
1
1
|
module Arfi
|
2
2
|
# +Arfi::SqlFunctionLoader+ is a class which loads user defined SQL functions into database.
|
3
3
|
class SqlFunctionLoader
|
4
|
+
attr_accessor self.task_name: nil | String
|
5
|
+
|
4
6
|
# +Arfi::SqlFunctionLoader.load!+ -> (nil | void)
|
5
7
|
#
|
6
8
|
# Loads user defined SQL functions into database.
|
7
9
|
#
|
10
|
+
# @param task_name [String|nil] Name of the task.
|
8
11
|
# @return [nil] if there is no `db/functions` directory.
|
9
12
|
# @return [void] if there is no errors.
|
10
13
|
# @raise [Arfi::Errors::AdapterNotSupported] if database adapter is SQLite.
|
11
|
-
def self.load!: () -> (nil | untyped)
|
14
|
+
def self.load!: (task_name: nil | String) -> (nil | untyped)
|
15
|
+
|
16
|
+
# +Arfi::SqlFunctionLoader#sql_functions_by_adapter+ -> Array<String>
|
17
|
+
#
|
18
|
+
# Helper method to get list of SQL files for specific database adapter.
|
19
|
+
#
|
20
|
+
# @!visibility private
|
21
|
+
# @private
|
22
|
+
# @return [Array<String>] List of SQL files.
|
23
|
+
# @raise [Arfi::Errors::AdapterNotSupported] if database adapter is not supported.
|
24
|
+
def self.sql_functions_by_adapter: -> Array[String]
|
25
|
+
|
26
|
+
# +Arfi::SqlFunctionLoader#multi_db?+ -> Boolean
|
27
|
+
#
|
28
|
+
# Checks if the application has been configured to work with multiple databases.
|
29
|
+
#
|
30
|
+
# @return [Boolean]
|
31
|
+
def self.multi_db?: -> bool
|
32
|
+
|
33
|
+
# +Arfi::SqlFunctionLoader#populate_multiple_db+ -> void
|
34
|
+
#
|
35
|
+
# Loads user defined SQL functions into all databases.
|
36
|
+
#
|
37
|
+
# @!visibility private
|
38
|
+
# @private
|
39
|
+
# @return [void]
|
40
|
+
# @see Arfi::SqlFunctionLoader#multi_db?
|
41
|
+
# @see Arfi::SqlFunctionLoader#populate_db
|
42
|
+
def self.populate_multiple_db: -> void
|
43
|
+
|
44
|
+
# +Arfi::SqlFunctionLoader#raise_unless_supported_adapter+ -> void
|
45
|
+
#
|
46
|
+
# Checks if the database adapter is supported.
|
47
|
+
#
|
48
|
+
# @return [void]
|
49
|
+
# @raise [Arfi::Errors::AdapterNotSupported]
|
50
|
+
def self.raise_unless_supported_adapter: -> void
|
51
|
+
|
52
|
+
# +Arfi::SqlFunctionLoader#handle_db_population+ -> void
|
53
|
+
#
|
54
|
+
# Loads user defined SQL functions into database. This conditional branch was written this way because if we
|
55
|
+
# call db:migrate:db_name, then task_name will not be nil, but it will be zero if we call db:migrate. Then we
|
56
|
+
# check that the application has been configured to work with multiple databases in order to populate all
|
57
|
+
# databases, and only after this check can we populate the database in case the db:migrate (or any other) task
|
58
|
+
# has been called for configuration with a single database. Go to `lib/arfi/tasks/db.rake` for additional info.
|
59
|
+
#
|
60
|
+
# @!visibility private
|
61
|
+
# @private
|
62
|
+
# @return [void]
|
63
|
+
def self.handle_db_population: -> untyped
|
12
64
|
|
13
65
|
private
|
14
66
|
|
data/sig/lib/arfi/version.rbs
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arfi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- unurgunite
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - ">="
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: '
|
18
|
+
version: '6.0'
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - ">="
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: '
|
25
|
+
version: '6.0'
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rake
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,8 +107,37 @@ dependencies:
|
|
107
107
|
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '1.21'
|
110
|
-
|
111
|
-
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: steep
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '1.3'
|
117
|
+
type: :development
|
118
|
+
prerelease: false
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '1.3'
|
124
|
+
- !ruby/object:Gem::Dependency
|
125
|
+
name: yard
|
126
|
+
requirement: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 0.9.37
|
131
|
+
type: :development
|
132
|
+
prerelease: false
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 0.9.37
|
138
|
+
description: 'ARFI — ActiveRecord Functional Indexes. Provides the ability to create
|
139
|
+
and maintain functions that can be used as indexes, as well as in other parts of
|
140
|
+
the project without switching to structure.sql.
|
112
141
|
|
113
142
|
'
|
114
143
|
email:
|
@@ -126,6 +155,7 @@ files:
|
|
126
155
|
- LICENSE.txt
|
127
156
|
- README.md
|
128
157
|
- Rakefile
|
158
|
+
- Steepfile
|
129
159
|
- exe/arfi
|
130
160
|
- lib/arfi.rb
|
131
161
|
- lib/arfi/Rakefile
|
@@ -140,11 +170,16 @@ files:
|
|
140
170
|
- lib/arfi/sql_function_loader.rb
|
141
171
|
- lib/arfi/tasks/db.rake
|
142
172
|
- lib/arfi/version.rb
|
173
|
+
- rakelib/yard_docs_generator.rake
|
174
|
+
- rbs_collection.lock.yaml
|
175
|
+
- rbs_collection.yaml
|
143
176
|
- sig/arfi.rbs
|
177
|
+
- sig/lib/arfi/cli.rbs
|
144
178
|
- sig/lib/arfi/commands/f_idx.rbs
|
145
179
|
- sig/lib/arfi/commands/project.rbs
|
146
180
|
- sig/lib/arfi/errors.rbs
|
147
181
|
- sig/lib/arfi/extensions/active_record/base.rbs
|
182
|
+
- sig/lib/arfi/railtie.rbs
|
148
183
|
- sig/lib/arfi/sql_function_loader.rbs
|
149
184
|
- sig/lib/arfi/version.rbs
|
150
185
|
homepage: https://github.com/unurgunite/arfi
|
@@ -163,14 +198,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
163
198
|
requirements:
|
164
199
|
- - ">="
|
165
200
|
- !ruby/object:Gem::Version
|
166
|
-
version: 3.1
|
201
|
+
version: '3.1'
|
167
202
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
203
|
requirements:
|
169
204
|
- - ">="
|
170
205
|
- !ruby/object:Gem::Version
|
171
206
|
version: '0'
|
172
207
|
requirements: []
|
173
|
-
rubygems_version: 3.6.
|
208
|
+
rubygems_version: 3.6.9
|
174
209
|
specification_version: 4
|
175
210
|
summary: ActiveRecord Functional Indexes.
|
176
211
|
test_files: []
|