pg_objects 1.0.3 → 1.2.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/.github/dependabot.yml +11 -0
- data/.github/workflows/ci.yml +1 -1
- data/.rubocop.yml +4 -1
- data/Gemfile +3 -1
- data/Gemfile.lock +189 -74
- data/lib/generators/pg_objects/install/install_generator.rb +7 -9
- data/lib/pg_objects/config.rb +8 -10
- data/lib/pg_objects/container.rb +30 -0
- data/lib/pg_objects/db_object.rb +40 -22
- data/lib/pg_objects/db_object_factory.rb +13 -0
- data/lib/pg_objects/logger.rb +7 -14
- data/lib/pg_objects/manager.rb +51 -51
- data/lib/pg_objects/parsed_object/aggregate.rb +8 -0
- data/lib/pg_objects/parsed_object/base.rb +16 -0
- data/lib/pg_objects/parsed_object/conversion.rb +8 -0
- data/lib/pg_objects/parsed_object/event_trigger.rb +8 -0
- data/lib/pg_objects/parsed_object/function.rb +8 -0
- data/lib/pg_objects/parsed_object/materialized_view.rb +8 -0
- data/lib/pg_objects/parsed_object/operator.rb +8 -0
- data/lib/pg_objects/parsed_object/operator_class.rb +8 -0
- data/lib/pg_objects/parsed_object/table.rb +8 -0
- data/lib/pg_objects/parsed_object/text_search_parser.rb +8 -0
- data/lib/pg_objects/parsed_object/text_search_template.rb +8 -0
- data/lib/pg_objects/parsed_object/trigger.rb +8 -0
- data/lib/pg_objects/parsed_object/type.rb +8 -0
- data/lib/pg_objects/parsed_object/view.rb +8 -0
- data/lib/pg_objects/parsed_object.rb +18 -0
- data/lib/pg_objects/parsed_object_factory.rb +103 -0
- data/lib/pg_objects/parser.rb +46 -43
- data/lib/pg_objects/railtie.rb +5 -10
- data/lib/pg_objects/version.rb +1 -1
- data/lib/pg_objects.rb +9 -0
- data/pg_objects.gemspec +9 -4
- metadata +100 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91c7eb71d09850bc60f89da023336a3b23da1032b708edd25d6d7c4c36cda48a
|
4
|
+
data.tar.gz: 68b0c1d67c6f8954b385bb92d9e56b4e9f26d493aeaa7ce436f853415d5df016
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58455882d344d4dff87af1855313bb2cf534408a43d8ead7c98d5eaf726cdd5d7c53576d066d018ea51932281bd7d4c38f716b21fb3a276cc859d074fc83ffd4
|
7
|
+
data.tar.gz: 74199983303ce4ef51a41c2131c5f70e384e1ebeeb730681ed8458fe8fa24da481e6240ca6efad0a18350ae9428aae06d4f884f314e0dd27cecea03116292ad1
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
3
|
+
# Please see the documentation for all configuration options:
|
4
|
+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
5
|
+
|
6
|
+
version: 2
|
7
|
+
updates:
|
8
|
+
- package-ecosystem: "bundler"
|
9
|
+
directory: "/" # Location of package manifests
|
10
|
+
schedule:
|
11
|
+
interval: "weekly"
|
data/.github/workflows/ci.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -8,7 +8,7 @@ inherit_from: .rubocop_todo.yml
|
|
8
8
|
|
9
9
|
AllCops:
|
10
10
|
# EnabledByDefault: true
|
11
|
-
TargetRubyVersion:
|
11
|
+
TargetRubyVersion: 3.1
|
12
12
|
# Cop names are not d§splayed in offense messages by default. Change behavior
|
13
13
|
# by overriding DisplayCopNames, or by giving the -D/--display-cop-names
|
14
14
|
# option.
|
@@ -210,6 +210,9 @@ Style/BisectedAttrAccessor:
|
|
210
210
|
Style/CaseLikeIf:
|
211
211
|
Enabled: true
|
212
212
|
|
213
|
+
Style/ClassAndModuleChildren:
|
214
|
+
EnforcedStyle: compact
|
215
|
+
|
213
216
|
Style/ExponentialNotation:
|
214
217
|
Enabled: true
|
215
218
|
|
data/Gemfile
CHANGED
@@ -5,9 +5,11 @@ gemspec
|
|
5
5
|
group :development, :test do
|
6
6
|
gem 'bundler', require: false
|
7
7
|
gem 'bundler-audit', require: false
|
8
|
-
gem '
|
8
|
+
gem 'faker', require: false
|
9
|
+
gem 'pry-byebug'
|
9
10
|
gem 'rake', require: false
|
10
11
|
gem 'rspec', require: false
|
12
|
+
gem 'rspec-parameterized', require: false
|
11
13
|
gem 'rubocop', require: false
|
12
14
|
gem 'rubocop-rails', require: false
|
13
15
|
gem 'rubocop-rake', require: false
|
data/Gemfile.lock
CHANGED
@@ -1,150 +1,265 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pg_objects (1.
|
5
|
-
activerecord (>= 6.
|
6
|
-
|
7
|
-
|
4
|
+
pg_objects (1.2.1)
|
5
|
+
activerecord (>= 6.1.7.0, < 8)
|
6
|
+
dry-auto_inject (~> 1)
|
7
|
+
dry-configurable (~> 1)
|
8
|
+
dry-container (= 0.11.0)
|
9
|
+
dry-monads (~> 1.6)
|
10
|
+
memery (~> 1.5.0)
|
11
|
+
pg_query (~> 5)
|
12
|
+
railties (>= 4, < 8)
|
8
13
|
rake-hooks (~> 1)
|
9
14
|
|
10
15
|
GEM
|
11
16
|
remote: https://rubygems.org/
|
12
17
|
specs:
|
13
|
-
actionpack (
|
14
|
-
actionview (=
|
15
|
-
activesupport (=
|
16
|
-
|
18
|
+
actionpack (7.1.3.4)
|
19
|
+
actionview (= 7.1.3.4)
|
20
|
+
activesupport (= 7.1.3.4)
|
21
|
+
nokogiri (>= 1.8.5)
|
22
|
+
racc
|
23
|
+
rack (>= 2.2.4)
|
24
|
+
rack-session (>= 1.0.1)
|
17
25
|
rack-test (>= 0.6.3)
|
18
|
-
rails-dom-testing (~> 2.
|
19
|
-
rails-html-sanitizer (~> 1.
|
20
|
-
actionview (
|
21
|
-
activesupport (=
|
26
|
+
rails-dom-testing (~> 2.2)
|
27
|
+
rails-html-sanitizer (~> 1.6)
|
28
|
+
actionview (7.1.3.4)
|
29
|
+
activesupport (= 7.1.3.4)
|
22
30
|
builder (~> 3.1)
|
23
|
-
erubi (~> 1.
|
24
|
-
rails-dom-testing (~> 2.
|
25
|
-
rails-html-sanitizer (~> 1.
|
26
|
-
activemodel (
|
27
|
-
activesupport (=
|
28
|
-
activerecord (
|
29
|
-
activemodel (=
|
30
|
-
activesupport (=
|
31
|
-
|
31
|
+
erubi (~> 1.11)
|
32
|
+
rails-dom-testing (~> 2.2)
|
33
|
+
rails-html-sanitizer (~> 1.6)
|
34
|
+
activemodel (7.1.3.4)
|
35
|
+
activesupport (= 7.1.3.4)
|
36
|
+
activerecord (7.1.3.4)
|
37
|
+
activemodel (= 7.1.3.4)
|
38
|
+
activesupport (= 7.1.3.4)
|
39
|
+
timeout (>= 0.4.0)
|
40
|
+
activesupport (7.1.3.4)
|
41
|
+
base64
|
42
|
+
bigdecimal
|
32
43
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
44
|
+
connection_pool (>= 2.2.5)
|
45
|
+
drb
|
33
46
|
i18n (>= 1.6, < 2)
|
34
47
|
minitest (>= 5.1)
|
48
|
+
mutex_m
|
35
49
|
tzinfo (~> 2.0)
|
36
|
-
zeitwerk (~> 2.3)
|
37
50
|
ast (2.4.2)
|
51
|
+
base64 (0.2.0)
|
52
|
+
bigdecimal (3.1.8)
|
53
|
+
binding_of_caller (1.0.1)
|
54
|
+
debug_inspector (>= 1.2.0)
|
38
55
|
builder (3.2.4)
|
39
56
|
bundler-audit (0.9.1)
|
40
57
|
bundler (>= 1.2.0, < 3)
|
41
58
|
thor (~> 1.0)
|
42
59
|
byebug (11.1.3)
|
43
|
-
|
60
|
+
coderay (1.1.3)
|
61
|
+
concurrent-ruby (1.3.1)
|
62
|
+
connection_pool (2.4.1)
|
44
63
|
crass (1.0.6)
|
45
|
-
|
64
|
+
debug_inspector (1.2.0)
|
65
|
+
diff-lcs (1.5.1)
|
66
|
+
drb (2.2.1)
|
67
|
+
dry-auto_inject (1.0.1)
|
68
|
+
dry-core (~> 1.0)
|
69
|
+
zeitwerk (~> 2.6)
|
70
|
+
dry-configurable (1.1.0)
|
71
|
+
dry-core (~> 1.0, < 2)
|
72
|
+
zeitwerk (~> 2.6)
|
73
|
+
dry-container (0.11.0)
|
74
|
+
concurrent-ruby (~> 1.0)
|
75
|
+
dry-core (1.0.1)
|
76
|
+
concurrent-ruby (~> 1.0)
|
77
|
+
zeitwerk (~> 2.6)
|
78
|
+
dry-monads (1.6.0)
|
79
|
+
concurrent-ruby (~> 1.0)
|
80
|
+
dry-core (~> 1.0, < 2)
|
81
|
+
zeitwerk (~> 2.6)
|
46
82
|
erubi (1.12.0)
|
47
|
-
|
83
|
+
faker (3.4.1)
|
84
|
+
i18n (>= 1.8.11, < 2)
|
85
|
+
google-protobuf (3.25.3)
|
86
|
+
google-protobuf (3.25.3-aarch64-linux)
|
87
|
+
google-protobuf (3.25.3-arm64-darwin)
|
88
|
+
google-protobuf (3.25.3-x86-linux)
|
89
|
+
google-protobuf (3.25.3-x86_64-darwin)
|
90
|
+
google-protobuf (3.25.3-x86_64-linux)
|
91
|
+
i18n (1.14.5)
|
48
92
|
concurrent-ruby (~> 1.0)
|
49
|
-
|
93
|
+
io-console (0.7.2)
|
94
|
+
irb (1.13.1)
|
95
|
+
rdoc (>= 4.0.0)
|
96
|
+
reline (>= 0.4.2)
|
97
|
+
json (2.7.2)
|
50
98
|
language_server-protocol (3.17.0.3)
|
51
|
-
loofah (2.
|
99
|
+
loofah (2.22.0)
|
52
100
|
crass (~> 1.0.2)
|
53
101
|
nokogiri (>= 1.12.0)
|
102
|
+
memery (1.5.0)
|
103
|
+
ruby2_keywords (~> 0.0.2)
|
54
104
|
method_source (1.0.0)
|
55
|
-
|
56
|
-
|
57
|
-
nokogiri (1.
|
58
|
-
|
105
|
+
minitest (5.23.1)
|
106
|
+
mutex_m (0.2.0)
|
107
|
+
nokogiri (1.16.5-aarch64-linux)
|
108
|
+
racc (~> 1.4)
|
109
|
+
nokogiri (1.16.5-arm-linux)
|
110
|
+
racc (~> 1.4)
|
111
|
+
nokogiri (1.16.5-arm64-darwin)
|
59
112
|
racc (~> 1.4)
|
60
|
-
|
61
|
-
|
113
|
+
nokogiri (1.16.5-x86-linux)
|
114
|
+
racc (~> 1.4)
|
115
|
+
nokogiri (1.16.5-x86_64-darwin)
|
116
|
+
racc (~> 1.4)
|
117
|
+
nokogiri (1.16.5-x86_64-linux)
|
118
|
+
racc (~> 1.4)
|
119
|
+
parallel (1.24.0)
|
120
|
+
parser (3.3.2.0)
|
62
121
|
ast (~> 2.4.1)
|
63
122
|
racc
|
64
|
-
pg_query (1.
|
65
|
-
|
66
|
-
|
123
|
+
pg_query (5.1.0)
|
124
|
+
google-protobuf (>= 3.22.3)
|
125
|
+
proc_to_ast (0.1.0)
|
126
|
+
coderay
|
127
|
+
parser
|
128
|
+
unparser
|
129
|
+
pry (0.14.2)
|
130
|
+
coderay (~> 1.1)
|
131
|
+
method_source (~> 1.0)
|
132
|
+
pry-byebug (3.10.1)
|
133
|
+
byebug (~> 11.0)
|
134
|
+
pry (>= 0.13, < 0.15)
|
135
|
+
psych (5.1.2)
|
136
|
+
stringio
|
137
|
+
racc (1.8.0)
|
138
|
+
rack (3.0.11)
|
139
|
+
rack-session (2.0.0)
|
140
|
+
rack (>= 3.0.0)
|
67
141
|
rack-test (2.1.0)
|
68
142
|
rack (>= 1.3)
|
69
|
-
|
70
|
-
|
143
|
+
rackup (2.1.0)
|
144
|
+
rack (>= 3)
|
145
|
+
webrick (~> 1.8)
|
146
|
+
rails-dom-testing (2.2.0)
|
147
|
+
activesupport (>= 5.0.0)
|
148
|
+
minitest
|
71
149
|
nokogiri (>= 1.6)
|
72
150
|
rails-html-sanitizer (1.6.0)
|
73
151
|
loofah (~> 2.21)
|
74
152
|
nokogiri (~> 1.14)
|
75
|
-
railties (
|
76
|
-
actionpack (=
|
77
|
-
activesupport (=
|
78
|
-
|
153
|
+
railties (7.1.3.4)
|
154
|
+
actionpack (= 7.1.3.4)
|
155
|
+
activesupport (= 7.1.3.4)
|
156
|
+
irb
|
157
|
+
rackup (>= 1.0.0)
|
79
158
|
rake (>= 12.2)
|
80
|
-
thor (~> 1.0)
|
159
|
+
thor (~> 1.0, >= 1.2.2)
|
160
|
+
zeitwerk (~> 2.6)
|
81
161
|
rainbow (3.1.1)
|
82
|
-
rake (13.
|
162
|
+
rake (13.2.1)
|
83
163
|
rake-hooks (1.2.3)
|
84
164
|
rake
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
165
|
+
rdoc (6.6.3.1)
|
166
|
+
psych (>= 4.0.0)
|
167
|
+
regexp_parser (2.9.2)
|
168
|
+
reline (0.5.7)
|
169
|
+
io-console (~> 0.5)
|
170
|
+
rexml (3.2.8)
|
171
|
+
strscan (>= 3.0.9)
|
172
|
+
rspec (3.13.0)
|
173
|
+
rspec-core (~> 3.13.0)
|
174
|
+
rspec-expectations (~> 3.13.0)
|
175
|
+
rspec-mocks (~> 3.13.0)
|
176
|
+
rspec-core (3.13.0)
|
177
|
+
rspec-support (~> 3.13.0)
|
178
|
+
rspec-expectations (3.13.0)
|
94
179
|
diff-lcs (>= 1.2.0, < 2.0)
|
95
|
-
rspec-support (~> 3.
|
96
|
-
rspec-mocks (3.
|
180
|
+
rspec-support (~> 3.13.0)
|
181
|
+
rspec-mocks (3.13.0)
|
97
182
|
diff-lcs (>= 1.2.0, < 2.0)
|
98
|
-
rspec-support (~> 3.
|
99
|
-
rspec-
|
100
|
-
|
183
|
+
rspec-support (~> 3.13.0)
|
184
|
+
rspec-parameterized (1.0.2)
|
185
|
+
rspec-parameterized-core (< 2)
|
186
|
+
rspec-parameterized-table_syntax (< 2)
|
187
|
+
rspec-parameterized-core (1.0.0)
|
188
|
+
parser
|
189
|
+
proc_to_ast
|
190
|
+
rspec (>= 2.13, < 4)
|
191
|
+
unparser
|
192
|
+
rspec-parameterized-table_syntax (1.0.1)
|
193
|
+
binding_of_caller
|
194
|
+
rspec-parameterized-core (< 2)
|
195
|
+
rspec-support (3.13.1)
|
196
|
+
rubocop (1.64.1)
|
101
197
|
json (~> 2.3)
|
102
198
|
language_server-protocol (>= 3.17.0)
|
103
199
|
parallel (~> 1.10)
|
104
|
-
parser (>= 3.
|
200
|
+
parser (>= 3.3.0.2)
|
105
201
|
rainbow (>= 2.2.2, < 4.0)
|
106
202
|
regexp_parser (>= 1.8, < 3.0)
|
107
203
|
rexml (>= 3.2.5, < 4.0)
|
108
|
-
rubocop-ast (>= 1.
|
204
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
109
205
|
ruby-progressbar (~> 1.7)
|
110
206
|
unicode-display_width (>= 2.4.0, < 3.0)
|
111
|
-
rubocop-ast (1.
|
112
|
-
parser (>= 3.
|
113
|
-
rubocop-capybara (2.
|
207
|
+
rubocop-ast (1.31.3)
|
208
|
+
parser (>= 3.3.1.0)
|
209
|
+
rubocop-capybara (2.20.0)
|
210
|
+
rubocop (~> 1.41)
|
211
|
+
rubocop-factory_bot (2.25.1)
|
114
212
|
rubocop (~> 1.41)
|
115
|
-
rubocop-
|
116
|
-
rubocop (~> 1.33)
|
117
|
-
rubocop-rails (2.20.2)
|
213
|
+
rubocop-rails (2.25.0)
|
118
214
|
activesupport (>= 4.2.0)
|
119
215
|
rack (>= 1.1)
|
120
216
|
rubocop (>= 1.33.0, < 2.0)
|
217
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
121
218
|
rubocop-rake (0.6.0)
|
122
219
|
rubocop (~> 1.0)
|
123
|
-
rubocop-rspec (2.
|
124
|
-
rubocop (~> 1.
|
220
|
+
rubocop-rspec (2.30.0)
|
221
|
+
rubocop (~> 1.40)
|
125
222
|
rubocop-capybara (~> 2.17)
|
126
223
|
rubocop-factory_bot (~> 2.22)
|
224
|
+
rubocop-rspec_rails (~> 2.28)
|
225
|
+
rubocop-rspec_rails (2.28.3)
|
226
|
+
rubocop (~> 1.40)
|
127
227
|
ruby-progressbar (1.13.0)
|
128
|
-
|
228
|
+
ruby2_keywords (0.0.5)
|
229
|
+
stringio (3.1.0)
|
230
|
+
strscan (3.1.0)
|
231
|
+
thor (1.3.1)
|
232
|
+
timeout (0.4.1)
|
129
233
|
tzinfo (2.0.6)
|
130
234
|
concurrent-ruby (~> 1.0)
|
131
|
-
unicode-display_width (2.
|
132
|
-
|
235
|
+
unicode-display_width (2.5.0)
|
236
|
+
unparser (0.6.13)
|
237
|
+
diff-lcs (~> 1.3)
|
238
|
+
parser (>= 3.3.0)
|
239
|
+
webrick (1.8.1)
|
240
|
+
zeitwerk (2.6.14)
|
133
241
|
|
134
242
|
PLATFORMS
|
135
|
-
|
243
|
+
aarch64-linux
|
244
|
+
arm-linux
|
245
|
+
arm64-darwin
|
246
|
+
x86-linux
|
247
|
+
x86_64-darwin
|
248
|
+
x86_64-linux
|
136
249
|
|
137
250
|
DEPENDENCIES
|
138
251
|
bundler
|
139
252
|
bundler-audit
|
140
|
-
|
253
|
+
faker
|
141
254
|
pg_objects!
|
255
|
+
pry-byebug
|
142
256
|
rake
|
143
257
|
rspec
|
258
|
+
rspec-parameterized
|
144
259
|
rubocop
|
145
260
|
rubocop-rails
|
146
261
|
rubocop-rake
|
147
262
|
rubocop-rspec
|
148
263
|
|
149
264
|
BUNDLED WITH
|
150
|
-
2.
|
265
|
+
2.5.5
|
@@ -1,11 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
empty_directory 'db/objects/after'
|
9
|
-
end
|
1
|
+
##
|
2
|
+
# Creates default directories structure
|
3
|
+
class PgObjects::InstallGenerator < Rails::Generators::Base
|
4
|
+
def create_directories
|
5
|
+
empty_directory 'db/objects'
|
6
|
+
empty_directory 'db/objects/before'
|
7
|
+
empty_directory 'db/objects/after'
|
10
8
|
end
|
11
9
|
end
|
data/lib/pg_objects/config.rb
CHANGED
@@ -5,7 +5,7 @@ module PgObjects
|
|
5
5
|
# PgObjects.configure do |config|
|
6
6
|
# # use relative from RAILS_ROOT
|
7
7
|
# config.before_path = 'db/alternate/before'
|
8
|
-
# # or full
|
8
|
+
# # or full
|
9
9
|
# config.after_path = '/var/tmp/alternate/after'
|
10
10
|
# config.extensions = ['sql', 'txt']
|
11
11
|
# # suppress output to console
|
@@ -13,22 +13,20 @@ module PgObjects
|
|
13
13
|
# end
|
14
14
|
class << self
|
15
15
|
def configure
|
16
|
-
yield config
|
16
|
+
yield Config.config
|
17
17
|
end
|
18
18
|
|
19
19
|
def config
|
20
|
-
|
20
|
+
Config.config
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
class Config
|
25
|
-
|
25
|
+
extend Dry::Configurable
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
@silent = false
|
32
|
-
end
|
27
|
+
setting :before_path, default: 'db/objects/before'
|
28
|
+
setting :after_path, default: 'db/objects/after'
|
29
|
+
setting :extensions, default: ['sql']
|
30
|
+
setting :silent, default: false
|
33
31
|
end
|
34
32
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
# Container for dependencies
|
5
|
+
#
|
6
|
+
class PgObjects::Container
|
7
|
+
extend ::Dry::Container::Mixin
|
8
|
+
|
9
|
+
register 'config' do
|
10
|
+
PgObjects::Config.config
|
11
|
+
end
|
12
|
+
|
13
|
+
register 'db_object_factory' do
|
14
|
+
PgObjects::DbObjectFactory.new
|
15
|
+
end
|
16
|
+
|
17
|
+
register 'parsed_object_factory' do
|
18
|
+
PgObjects::ParsedObjectFactory
|
19
|
+
end
|
20
|
+
|
21
|
+
register 'parser' do
|
22
|
+
PgObjects::Parser.new
|
23
|
+
end
|
24
|
+
|
25
|
+
register 'logger' do
|
26
|
+
PgObjects::Logger.new
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
Import = Dry::AutoInject(PgObjects::Container)
|
data/lib/pg_objects/db_object.rb
CHANGED
@@ -1,24 +1,42 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
1
|
+
##
|
2
|
+
# Represents DB object as it is described in file
|
3
|
+
#
|
4
|
+
# [name] name of file without extension
|
5
|
+
# [full_name] full pathname of file
|
6
|
+
# [object_name] name of function, trigger etc. if it was successfully parsed, otherwise - nil
|
7
|
+
class PgObjects::DbObject
|
8
|
+
include Memery
|
9
|
+
|
10
|
+
include Import['parser']
|
11
|
+
|
12
|
+
attr_accessor :status
|
13
|
+
attr_reader :full_name, :object_name
|
14
|
+
|
15
|
+
def initialize(path, status = :new)
|
16
|
+
@full_name = path
|
17
|
+
@status = status
|
18
|
+
end
|
19
|
+
|
20
|
+
def create
|
21
|
+
parser.load(sql_query)
|
22
|
+
@object_name = parser.fetch_object_name
|
23
|
+
@status = :pending
|
24
|
+
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
memoize
|
29
|
+
def name
|
30
|
+
File.basename(full_name, '.*')
|
31
|
+
end
|
32
|
+
|
33
|
+
memoize
|
34
|
+
def dependencies
|
35
|
+
parser.fetch_directives[:depends_on]
|
36
|
+
end
|
37
|
+
|
38
|
+
memoize
|
39
|
+
def sql_query
|
40
|
+
File.read(full_name)
|
23
41
|
end
|
24
42
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
##
|
4
|
+
# Factory for DbObject
|
5
|
+
#
|
6
|
+
class PgObjects::DbObjectFactory
|
7
|
+
include Import['parser']
|
8
|
+
|
9
|
+
def create_instance(path, status: :new)
|
10
|
+
db_object = PgObjects::DbObject.new(path, status)
|
11
|
+
db_object.create
|
12
|
+
end
|
13
|
+
end
|
data/lib/pg_objects/logger.rb
CHANGED
@@ -1,17 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
class Logger
|
7
|
-
attr_reader :silent
|
1
|
+
##
|
2
|
+
# Console output
|
3
|
+
#
|
4
|
+
class PgObjects::Logger
|
5
|
+
include Import['config']
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
def write(str)
|
14
|
-
puts "== #{str} ".ljust(80, '=') unless silent
|
15
|
-
end
|
7
|
+
def write(str)
|
8
|
+
puts "== #{str} ".ljust(80, '=') unless config.silent
|
16
9
|
end
|
17
10
|
end
|