prick 0.20.12 → 0.20.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/builder/batch.rb +3 -1
- data/lib/builder/builder.rb +7 -2
- data/lib/builder/node.rb +7 -0
- data/lib/builder/node_pool.rb +18 -0
- data/lib/builder/parser.rb +4 -1
- data/lib/prick/version.rb +1 -1
- data/lib/subcommand/prick-build.rb +21 -2
- data/prick.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4435f17e31e98bc0c62c1f7c92818f71f059bc308522ab1ed8ac6acb17825768
|
4
|
+
data.tar.gz: aaaf83164a0de30d6a134cc12159cf5fed858806a68e4dba9738da93abd24e15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b6939f154a1e04af830c9bad778deb871f6573dd729afebf776fad34b06bbda1d6debe11b3d38278ec1f09357a6218723e70e0983a93dd6f3f6db2c4311fb5e
|
7
|
+
data.tar.gz: c291aeef50d1e5a133c47c7908653762da31d047852bcdfcfe19a0a97114efeb3118f9d2c759466621ece995120e3380107b57e97614410cbc82b18f813a1d7c
|
data/lib/builder/batch.rb
CHANGED
@@ -102,11 +102,12 @@ module Prick
|
|
102
102
|
files = nodes.map(&:path)
|
103
103
|
|
104
104
|
# Load meta object
|
105
|
-
meta = PgMeta.new(conn)
|
105
|
+
meta = PgMeta.new(conn, exclude_schemas: builder.pg_graph_ignore_schemas)
|
106
106
|
|
107
107
|
# Create type object
|
108
108
|
type = PgGraph::Type.new(meta, builder.reflections_file)
|
109
109
|
|
110
|
+
# Timer
|
110
111
|
t_type.stop
|
111
112
|
t_fox = Timer.new " Parse files"
|
112
113
|
|
@@ -126,6 +127,7 @@ module Prick
|
|
126
127
|
# Dump state file
|
127
128
|
fox.write_state(FOX_STATE_PATH)
|
128
129
|
|
130
|
+
# Timer
|
129
131
|
t_fox.stop
|
130
132
|
t_exe = Timer.new " Execute SQL"
|
131
133
|
|
data/lib/builder/builder.rb
CHANGED
@@ -31,9 +31,12 @@ module Prick
|
|
31
31
|
# Pool of nodes. Initialized by #load_pool
|
32
32
|
attr_reader :pool
|
33
33
|
|
34
|
-
forward_to :pool, :
|
34
|
+
forward_to :pool, :schemas,
|
35
|
+
:nodes, :decl_nodes, :init_nodes, :term_nodes,
|
35
36
|
:seed_nodes, :fox_seed_nodes, :sql_seed_nodes,
|
36
|
-
:
|
37
|
+
:builder_nodes,
|
38
|
+
:pg_graph_ignore_schemas,
|
39
|
+
:refresh_schemas, :keep_schemas
|
37
40
|
|
38
41
|
def batches() @batches ||= group end
|
39
42
|
|
@@ -44,6 +47,7 @@ module Prick
|
|
44
47
|
@clean = clean
|
45
48
|
@pool = NodePool.new
|
46
49
|
@root = Parser.parse(conn, dir)
|
50
|
+
@pg_graph_ignore_schemas = []
|
47
51
|
load_pool(@root) # Collect nodes into pool
|
48
52
|
@batches = nil # Initialized by #group
|
49
53
|
end
|
@@ -90,6 +94,7 @@ module Prick
|
|
90
94
|
def execute(conn, create_schemas: schemas)
|
91
95
|
group if batches.nil?
|
92
96
|
conn.exec create_schemas.grep_v("public").map { |schema| "create schema #{schema}" }
|
97
|
+
conn.schema.create("public", authorization: "postgres")
|
93
98
|
for batch in batches
|
94
99
|
batch.execute
|
95
100
|
end
|
data/lib/builder/node.rb
CHANGED
@@ -142,6 +142,7 @@ module Prick
|
|
142
142
|
end
|
143
143
|
end
|
144
144
|
|
145
|
+
# A build.yml file node
|
145
146
|
class BuildNode < Node
|
146
147
|
def nodes() @nodes ||= init_nodes + decl_nodes + seed_nodes + term_nodes end
|
147
148
|
|
@@ -150,12 +151,17 @@ module Prick
|
|
150
151
|
attr_reader :term_nodes
|
151
152
|
attr_reader :seed_nodes
|
152
153
|
|
154
|
+
attr_accessor :pg_graph_ignore_schema
|
155
|
+
attr_accessor :refresh_schema
|
156
|
+
|
153
157
|
def initialize(parent, path)
|
154
158
|
super(parent, nil, :yml, path)
|
155
159
|
@decl_nodes = []
|
156
160
|
@init_nodes = []
|
157
161
|
@term_nodes = []
|
158
162
|
@seed_nodes = []
|
163
|
+
@pg_graph_ignore_schema = false
|
164
|
+
@refresh_schema = true
|
159
165
|
end
|
160
166
|
|
161
167
|
def inspect() to_s end
|
@@ -164,6 +170,7 @@ module Prick
|
|
164
170
|
puts "BuildNode #{path}"
|
165
171
|
indent {
|
166
172
|
puts "schema: #{schema}" if schema
|
173
|
+
puts "pg_graph_ignore_schema: #{pg_graph_ignore_schema}"
|
167
174
|
decl_nodes.each(&:dump)
|
168
175
|
for kind in [:init, :term, :seed]
|
169
176
|
kind_nodes = self.send("#{kind}_nodes".to_sym)
|
data/lib/builder/node_pool.rb
CHANGED
@@ -18,6 +18,24 @@ module Prick
|
|
18
18
|
def fox_seed_nodes() seed_nodes.select { |node| node.kind == :fox } end
|
19
19
|
def sql_seed_nodes() seed_nodes.select { |node| node.kind == :sql } end
|
20
20
|
|
21
|
+
# List of BuildNode nodes
|
22
|
+
def build_nodes() nodes.select { |node| node.is_a?(BuildNode) } end
|
23
|
+
|
24
|
+
# List of schemas to ignore when building PgGraph objects. This is used
|
25
|
+
# to exclude foreign schemes that doesn't follow the PgGraph naming
|
26
|
+
# conventions
|
27
|
+
def pg_graph_ignore_schemas()
|
28
|
+
build_nodes.select(&:pg_graph_ignore_schema).map(&:schema).uniq
|
29
|
+
end
|
30
|
+
|
31
|
+
def refresh_schemas()
|
32
|
+
build_nodes.select(&:refresh_schema).map(&:schema).uniq
|
33
|
+
end
|
34
|
+
|
35
|
+
def keep_schemas()
|
36
|
+
build_nodes.reject(&:refresh_schema).map(&:schema).uniq
|
37
|
+
end
|
38
|
+
|
21
39
|
def initialize()
|
22
40
|
self.clear
|
23
41
|
end
|
data/lib/builder/parser.rb
CHANGED
@@ -50,7 +50,10 @@ module Prick
|
|
50
50
|
entry.each { |key, value|
|
51
51
|
if key == "schema"
|
52
52
|
unit.schema = value
|
53
|
-
|
53
|
+
elsif key == "standard"
|
54
|
+
unit.pg_graph_ignore_schema = !value
|
55
|
+
elsif key == "refresh"
|
56
|
+
unit.refresh_schema = value
|
54
57
|
else
|
55
58
|
case key
|
56
59
|
when "init"; unit.init_nodes
|
data/lib/prick/version.rb
CHANGED
@@ -8,19 +8,38 @@ module Prick::SubCommand
|
|
8
8
|
time "Prick::Command#build" do
|
9
9
|
begin
|
10
10
|
super_conn = PgConn.new
|
11
|
+
|
11
12
|
conn = nil
|
12
13
|
builder = nil
|
13
|
-
|
14
14
|
time "Load build object" do
|
15
15
|
if super_conn.rdbms.exist? database
|
16
16
|
conn = PgConn.new(database, username)
|
17
|
-
|
17
|
+
exist = true
|
18
18
|
else
|
19
19
|
super_conn.rdbms.create database, owner: username
|
20
20
|
conn = PgConn.new(database, username)
|
21
|
+
exit = false
|
21
22
|
end
|
22
23
|
|
23
24
|
builder = Prick::Build::Builder.new(conn, builddir)
|
25
|
+
|
26
|
+
if exist
|
27
|
+
# Explicit schema is always rebuilt
|
28
|
+
refresh = [builder.refresh_schemas, schema].compact.flatten.uniq
|
29
|
+
keep = builder.keep_schemas.reject { |s| s == schema }
|
30
|
+
|
31
|
+
# Rebuild non-existing keep-schemas
|
32
|
+
keep.reject! { |schema|
|
33
|
+
refresh << schema if !conn.schema.exist?(schema)
|
34
|
+
}
|
35
|
+
|
36
|
+
# Eliminate keep schemas from build pool
|
37
|
+
builder.pool.delete_schema(keep)
|
38
|
+
|
39
|
+
# Drop refresh schemes
|
40
|
+
refresh.each { |schema| conn.schema.drop(schema, cascade: true) }
|
41
|
+
end
|
42
|
+
|
24
43
|
builder.pool.delete_schema(builder.pool.after_schema(schema)) if schema
|
25
44
|
end
|
26
45
|
|
data/prick.gemspec
CHANGED
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_dependency "bootsnap"
|
37
37
|
spec.add_dependency "fixture_fox", "~> 0.1.3"
|
38
38
|
spec.add_dependency "postspec"
|
39
|
-
spec.add_dependency "pg_graph", "~> 0.1.
|
39
|
+
spec.add_dependency "pg_graph", "~> 0.1.8"
|
40
40
|
spec.add_dependency "shellopts", "~> 2.0.23"
|
41
41
|
|
42
42
|
spec.add_development_dependency "ruby-prof"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.20.
|
4
|
+
version: 0.20.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.1.
|
117
|
+
version: 0.1.8
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.1.
|
124
|
+
version: 0.1.8
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: shellopts
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|