pg_objects 1.2.1 → 1.3.1
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/.rubocop.yml +6 -7
- data/Gemfile.lock +15 -24
- data/README.md +49 -10
- data/lib/generators/pg_objects/install/install_generator.rb +1 -0
- data/lib/pg_objects/config.rb +5 -0
- data/lib/pg_objects/db_object.rb +2 -1
- data/lib/pg_objects/db_object_factory.rb +1 -1
- data/lib/pg_objects/version.rb +1 -1
- data/lib/pg_objects/yaml_configurable.rb +22 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46968edaefe0dd460b86f65907df0da5e698f775713d2174ee3f353ed844ce78
|
4
|
+
data.tar.gz: c5e7a825fba2451b16369e6690114e9a7d9bee79d3ccf76b448ee06dc0c02ee7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b22eba8c6739aa46603b1226aa22d8a44b032c9ba64546c52c84b9bdd3ff84abd519029bdb1d4d1360a8dd8cfa755c661f6a68da0d6b53f62f0e00bbe7ad76b
|
7
|
+
data.tar.gz: d1219118bf8574b91372554594d7cd36afc7dc7771d6e0ded70764e2db92f0a221093f5a0ba4321d6c6ada7dfb491e6e37ff12c3d305d2f6ece13e8c4d21cbcc
|
data/.rubocop.yml
CHANGED
@@ -156,13 +156,6 @@ RSpec/ExampleWording:
|
|
156
156
|
not: does not
|
157
157
|
IgnoredWords: []
|
158
158
|
|
159
|
-
# Checks the file and folder naming of the spec file.
|
160
|
-
RSpec/FilePath:
|
161
|
-
Enabled: true
|
162
|
-
CustomTransform:
|
163
|
-
RuboCop: rubocop
|
164
|
-
RSpec: rspec
|
165
|
-
|
166
159
|
RSpec/ImplicitExpect:
|
167
160
|
EnforcedStyle: should
|
168
161
|
Enabled: true
|
@@ -187,6 +180,12 @@ RSpec/NotToNot:
|
|
187
180
|
EnforcedStyle: not_to
|
188
181
|
Enabled: true
|
189
182
|
|
183
|
+
RSpec/SpecFilePathFormat:
|
184
|
+
Enabled: true
|
185
|
+
|
186
|
+
RSpec/SpecFilePathSuffix:
|
187
|
+
Enabled: true
|
188
|
+
|
190
189
|
# Style #######################################################################
|
191
190
|
|
192
191
|
Style/AccessorGrouping:
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pg_objects (1.
|
4
|
+
pg_objects (1.3.1)
|
5
5
|
activerecord (>= 6.1.7.0, < 8)
|
6
6
|
dry-auto_inject (~> 1)
|
7
7
|
dry-configurable (~> 1)
|
@@ -58,7 +58,7 @@ GEM
|
|
58
58
|
thor (~> 1.0)
|
59
59
|
byebug (11.1.3)
|
60
60
|
coderay (1.1.3)
|
61
|
-
concurrent-ruby (1.3.
|
61
|
+
concurrent-ruby (1.3.3)
|
62
62
|
connection_pool (2.4.1)
|
63
63
|
crass (1.0.6)
|
64
64
|
debug_inspector (1.2.0)
|
@@ -67,7 +67,7 @@ GEM
|
|
67
67
|
dry-auto_inject (1.0.1)
|
68
68
|
dry-core (~> 1.0)
|
69
69
|
zeitwerk (~> 2.6)
|
70
|
-
dry-configurable (1.
|
70
|
+
dry-configurable (1.2.0)
|
71
71
|
dry-core (~> 1.0, < 2)
|
72
72
|
zeitwerk (~> 2.6)
|
73
73
|
dry-container (0.11.0)
|
@@ -102,7 +102,7 @@ GEM
|
|
102
102
|
memery (1.5.0)
|
103
103
|
ruby2_keywords (~> 0.0.2)
|
104
104
|
method_source (1.0.0)
|
105
|
-
minitest (5.
|
105
|
+
minitest (5.24.1)
|
106
106
|
mutex_m (0.2.0)
|
107
107
|
nokogiri (1.16.5-aarch64-linux)
|
108
108
|
racc (~> 1.4)
|
@@ -116,8 +116,8 @@ GEM
|
|
116
116
|
racc (~> 1.4)
|
117
117
|
nokogiri (1.16.5-x86_64-linux)
|
118
118
|
racc (~> 1.4)
|
119
|
-
parallel (1.
|
120
|
-
parser (3.3.
|
119
|
+
parallel (1.25.1)
|
120
|
+
parser (3.3.4.0)
|
121
121
|
ast (~> 2.4.1)
|
122
122
|
racc
|
123
123
|
pg_query (5.1.0)
|
@@ -135,7 +135,7 @@ GEM
|
|
135
135
|
psych (5.1.2)
|
136
136
|
stringio
|
137
137
|
racc (1.8.0)
|
138
|
-
rack (3.
|
138
|
+
rack (3.1.6)
|
139
139
|
rack-session (2.0.0)
|
140
140
|
rack (>= 3.0.0)
|
141
141
|
rack-test (2.1.0)
|
@@ -167,8 +167,8 @@ GEM
|
|
167
167
|
regexp_parser (2.9.2)
|
168
168
|
reline (0.5.7)
|
169
169
|
io-console (~> 0.5)
|
170
|
-
rexml (3.2
|
171
|
-
strscan
|
170
|
+
rexml (3.3.2)
|
171
|
+
strscan
|
172
172
|
rspec (3.13.0)
|
173
173
|
rspec-core (~> 3.13.0)
|
174
174
|
rspec-expectations (~> 3.13.0)
|
@@ -193,37 +193,28 @@ GEM
|
|
193
193
|
binding_of_caller
|
194
194
|
rspec-parameterized-core (< 2)
|
195
195
|
rspec-support (3.13.1)
|
196
|
-
rubocop (1.
|
196
|
+
rubocop (1.65.0)
|
197
197
|
json (~> 2.3)
|
198
198
|
language_server-protocol (>= 3.17.0)
|
199
199
|
parallel (~> 1.10)
|
200
200
|
parser (>= 3.3.0.2)
|
201
201
|
rainbow (>= 2.2.2, < 4.0)
|
202
|
-
regexp_parser (>=
|
202
|
+
regexp_parser (>= 2.4, < 3.0)
|
203
203
|
rexml (>= 3.2.5, < 4.0)
|
204
204
|
rubocop-ast (>= 1.31.1, < 2.0)
|
205
205
|
ruby-progressbar (~> 1.7)
|
206
206
|
unicode-display_width (>= 2.4.0, < 3.0)
|
207
207
|
rubocop-ast (1.31.3)
|
208
208
|
parser (>= 3.3.1.0)
|
209
|
-
rubocop-
|
210
|
-
rubocop (~> 1.41)
|
211
|
-
rubocop-factory_bot (2.25.1)
|
212
|
-
rubocop (~> 1.41)
|
213
|
-
rubocop-rails (2.25.0)
|
209
|
+
rubocop-rails (2.25.1)
|
214
210
|
activesupport (>= 4.2.0)
|
215
211
|
rack (>= 1.1)
|
216
212
|
rubocop (>= 1.33.0, < 2.0)
|
217
213
|
rubocop-ast (>= 1.31.1, < 2.0)
|
218
214
|
rubocop-rake (0.6.0)
|
219
215
|
rubocop (~> 1.0)
|
220
|
-
rubocop-rspec (
|
221
|
-
rubocop (~> 1.
|
222
|
-
rubocop-capybara (~> 2.17)
|
223
|
-
rubocop-factory_bot (~> 2.22)
|
224
|
-
rubocop-rspec_rails (~> 2.28)
|
225
|
-
rubocop-rspec_rails (2.28.3)
|
226
|
-
rubocop (~> 1.40)
|
216
|
+
rubocop-rspec (3.0.3)
|
217
|
+
rubocop (~> 1.61)
|
227
218
|
ruby-progressbar (1.13.0)
|
228
219
|
ruby2_keywords (0.0.5)
|
229
220
|
stringio (3.1.0)
|
@@ -237,7 +228,7 @@ GEM
|
|
237
228
|
diff-lcs (~> 1.3)
|
238
229
|
parser (>= 3.3.0)
|
239
230
|
webrick (1.8.1)
|
240
|
-
zeitwerk (2.6.
|
231
|
+
zeitwerk (2.6.16)
|
241
232
|
|
242
233
|
PLATFORMS
|
243
234
|
aarch64-linux
|
data/README.md
CHANGED
@@ -17,17 +17,27 @@ gem 'pg_objects'
|
|
17
17
|
|
18
18
|
And then execute:
|
19
19
|
|
20
|
-
|
20
|
+
```shell
|
21
|
+
bundle install
|
22
|
+
```
|
21
23
|
|
22
24
|
Or install it yourself as:
|
23
25
|
|
24
|
-
|
26
|
+
```shell
|
27
|
+
gem install pg_objects
|
28
|
+
```
|
29
|
+
|
30
|
+
Run the installation procedure to initialize directories structure and configuration file:
|
31
|
+
|
32
|
+
```shell
|
33
|
+
bundle exec rails generate pg_objects:install
|
34
|
+
```
|
25
35
|
|
26
36
|
## Usage
|
27
37
|
|
28
|
-
|
38
|
+
Store DB objects as CREATE (or CREATE OR UPDATE) queries in files within a directory structure (default: *db/objects*).
|
29
39
|
|
30
|
-
You can control order of
|
40
|
+
You can control the order of creation by using the directive *depends_on* in an SQL comment:
|
31
41
|
|
32
42
|
```sql
|
33
43
|
--!depends_on my_another_func
|
@@ -35,23 +45,52 @@ CREATE FUNCTION my_func()
|
|
35
45
|
...
|
36
46
|
```
|
37
47
|
|
38
|
-
The string after directive should be
|
48
|
+
The string after the directive should be the name of the file that the dependency refers to, without the file extension.
|
39
49
|
|
40
50
|
## Configuration
|
41
51
|
|
42
|
-
|
52
|
+
You have the option to configure the gem using either a YAML file or a Ruby initializer. The priority order for configuration is as follows:
|
53
|
+
1. Ruby initializer
|
54
|
+
2. YAML config
|
55
|
+
3. Default values
|
56
|
+
|
57
|
+
### YAML
|
58
|
+
|
59
|
+
Create `pg_objects.yml` in the application *config* directory:
|
60
|
+
|
61
|
+
```yaml
|
62
|
+
# pg_objects.yml
|
63
|
+
|
64
|
+
# Specify the directories where the DB objects files are located
|
65
|
+
directories:
|
66
|
+
before: path/to/objects/before # executed before the migrations
|
67
|
+
after: path/to/objects/after # executed after the migrations
|
68
|
+
|
69
|
+
# Specify the file extensions of the DB objects files
|
70
|
+
extensions:
|
71
|
+
- sql
|
72
|
+
- txt
|
73
|
+
|
74
|
+
# Specify whether to suppress output to console
|
75
|
+
silent: false
|
76
|
+
```
|
77
|
+
|
78
|
+
### Initializer
|
79
|
+
|
80
|
+
Create file in *config/initializers* directory with the following content:
|
43
81
|
|
44
82
|
```ruby
|
45
83
|
PgObjects.configure do |config|
|
46
|
-
config.
|
84
|
+
config.before_path = 'path/to/objects/before' # default: 'db/objects/before'
|
85
|
+
config.after_path = 'path/to/objects/after' # default: 'db/objects/after'
|
47
86
|
config.extensions = ['sql', 'txt'] # default: 'sql'
|
48
|
-
config.silent =
|
87
|
+
config.silent = true # whether to suppress output to console, default: false
|
49
88
|
end
|
50
89
|
```
|
51
90
|
|
52
|
-
Otherwise default values will be used.
|
91
|
+
Otherwise, the default values will be used.
|
53
92
|
|
54
|
-
|
93
|
+
Please make sure to verify that the specified directories actually exist.
|
55
94
|
|
56
95
|
## Development
|
57
96
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
##
|
2
2
|
# Creates default directories structure
|
3
3
|
class PgObjects::InstallGenerator < Rails::Generators::Base
|
4
|
+
desc 'Creates directories structure in `db` directory of the Rails application and initializes configuration files'
|
4
5
|
def create_directories
|
5
6
|
empty_directory 'db/objects'
|
6
7
|
empty_directory 'db/objects/before'
|
data/lib/pg_objects/config.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative 'yaml_configurable'
|
2
|
+
|
1
3
|
module PgObjects
|
2
4
|
##
|
3
5
|
# Use to set custom configuration:
|
@@ -23,10 +25,13 @@ module PgObjects
|
|
23
25
|
|
24
26
|
class Config
|
25
27
|
extend Dry::Configurable
|
28
|
+
extend YamlConfigurable
|
26
29
|
|
27
30
|
setting :before_path, default: 'db/objects/before'
|
28
31
|
setting :after_path, default: 'db/objects/after'
|
29
32
|
setting :extensions, default: ['sql']
|
30
33
|
setting :silent, default: false
|
34
|
+
|
35
|
+
load_from_yaml 'config/pg_objects.yml'
|
31
36
|
end
|
32
37
|
end
|
data/lib/pg_objects/db_object.rb
CHANGED
@@ -12,9 +12,10 @@ class PgObjects::DbObject
|
|
12
12
|
attr_accessor :status
|
13
13
|
attr_reader :full_name, :object_name
|
14
14
|
|
15
|
-
def initialize(path, status = :new)
|
15
|
+
def initialize(path, status = :new, parser:)
|
16
16
|
@full_name = path
|
17
17
|
@status = status
|
18
|
+
@parser = parser
|
18
19
|
end
|
19
20
|
|
20
21
|
def create
|
data/lib/pg_objects/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
# A module that provides a method to load configuration settings from a YAML file.
|
2
|
+
module YamlConfigurable
|
3
|
+
# Loads configuration settings from a YAML file.
|
4
|
+
#
|
5
|
+
# @param file_path [String] The path to the YAML file.
|
6
|
+
def load_from_yaml(file_path)
|
7
|
+
return unless File.exist?(file_path)
|
8
|
+
|
9
|
+
config_hash = YAML.load_file(file_path)
|
10
|
+
|
11
|
+
set_if_present(config, :before_path, config_hash.dig('directories', 'before'))
|
12
|
+
set_if_present(config, :after_path, config_hash.dig('directories', 'after'))
|
13
|
+
set_if_present(config, :extensions, config_hash['extensions'])
|
14
|
+
set_if_present(config, :silent, config_hash['silent'])
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def set_if_present(config, key, value)
|
20
|
+
config.public_send("#{key}=", value) if value.present?
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg_objects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Kiselyov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- lib/pg_objects/parser.rb
|
198
198
|
- lib/pg_objects/railtie.rb
|
199
199
|
- lib/pg_objects/version.rb
|
200
|
+
- lib/pg_objects/yaml_configurable.rb
|
200
201
|
- lib/tasks/pg_objects_tasks.rake
|
201
202
|
- pg_objects.gemspec
|
202
203
|
homepage: https://github.com/marinazzio/pg_objects
|