prick 0.27.1 → 0.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/builder/parser.rb +59 -31
- data/lib/prick/version.rb +1 -1
- data/lib/subcommand/prick-teardown.rb +3 -2
- 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: '022876c913aadf3a2b42646f514f51c2db481c32db42a5903f2dbce88303d423'
|
4
|
+
data.tar.gz: 1772f43a5a99fe93b97e748488f3c5bfa93fddce768176744ebb27e983cbb475
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8c647cc168aee7f0aab47d39d6ce1050331a06b6aa7a04fc8173152618432c377eb7ce42784eb95d2a70134be10bddd0ff3a43298c2e20af8a3649dc8227451
|
7
|
+
data.tar.gz: 84068d08a68d2b1177054faa4d31218bf7bc66cf437bf255a6ff2404c0126e10288e58519e11fe7c80029c7169ff9e3a59be5327c39f8fd112bc0a846519d833
|
data/lib/builder/parser.rb
CHANGED
@@ -62,11 +62,11 @@ module Prick
|
|
62
62
|
when "seed"; unit.seed_nodes
|
63
63
|
else
|
64
64
|
raise Error, "Illegal key in #{unit.path}: #{key}"
|
65
|
-
end.concat(Array(value).map { |value| parse_entry(unit, key.to_sym, dir, value) })
|
65
|
+
end.concat(Array(value).map { |value| parse_entry(unit, key.to_sym, dir, value) }.compact)
|
66
66
|
end
|
67
67
|
}
|
68
68
|
else
|
69
|
-
node = parse_entry(unit, :decl, dir, entry)
|
69
|
+
node = parse_entry(unit, :decl, dir, entry) or next
|
70
70
|
if node.kind == :fox
|
71
71
|
unit.seed_nodes << node
|
72
72
|
else
|
@@ -77,11 +77,11 @@ module Prick
|
|
77
77
|
unit
|
78
78
|
end
|
79
79
|
|
80
|
-
# Expand $ENVIRONMENT variable. The function implements a
|
81
|
-
# environments:
|
80
|
+
# Expand $ENVIRONMENT variable in file names. The function implements a
|
81
|
+
# hierarchy of environments:
|
82
82
|
#
|
83
83
|
# production
|
84
|
-
# online
|
84
|
+
# (online)
|
85
85
|
# development
|
86
86
|
# online
|
87
87
|
# offline
|
@@ -92,19 +92,26 @@ module Prick
|
|
92
92
|
# If an environment doesn't exist in #dir, then the higher level
|
93
93
|
# environments are tried in turn. Eg. if the current environment is
|
94
94
|
# 'test', the algorithm expands '$ENVIRONMENT' to 'test', 'offline', and
|
95
|
-
# 'development' until an existing file is found. If no file is found
|
96
|
-
#
|
95
|
+
# 'development' until an existing file is found. If no file is found the
|
96
|
+
# the unexpanded value is returned
|
97
|
+
#
|
98
|
+
# NOTE: This is a hardcoded feature for an internal project. It is
|
99
|
+
# configurable in the next major version
|
97
100
|
#
|
98
|
-
def
|
99
|
-
|
100
|
-
|
101
|
-
|
101
|
+
def expand_filename(dir, filename)
|
102
|
+
if File.exist?("#{dir}/#{filename}")
|
103
|
+
return filename
|
104
|
+
elsif filename =~ /\$ENVIRONMENT|\$\{ENVIRONMENT\}/
|
105
|
+
env = Prick.state.environment.to_s
|
102
106
|
while true
|
103
|
-
file = expand_variables(
|
104
|
-
|
107
|
+
file = expand_variables(filename, ENVIRONMENT: env, PWD: Dir.getwd)
|
108
|
+
return file if File.exist? "#{dir}/#{file}"
|
105
109
|
case env
|
106
|
-
when "production"
|
107
|
-
|
110
|
+
when "production"
|
111
|
+
file = expand_variables(filename, ENVIRONMENT: "online", PWD: Dir.getwd) or return nil
|
112
|
+
return file if File.exist? "#{dir}/#{file}"
|
113
|
+
return nil
|
114
|
+
when "development"; return nil
|
108
115
|
when "online"; env = "development"
|
109
116
|
when "offline"; env = "development"
|
110
117
|
when "backend"; env = "offline"
|
@@ -114,43 +121,64 @@ module Prick
|
|
114
121
|
raise Error, "Illegal env: '#{env}'"
|
115
122
|
end
|
116
123
|
end
|
124
|
+
else
|
125
|
+
return nil
|
117
126
|
end
|
118
|
-
return file
|
119
127
|
end
|
120
128
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
129
|
+
# Expand $ENVIRONMENT variable
|
130
|
+
def expand_string(string)
|
131
|
+
expand_variables(string, ENVIRONMENT: Prick.state.environment.to_s, PWD: Dir.getwd)
|
132
|
+
end
|
133
|
+
|
134
|
+
def parse_file_entry(unit, dir, entry)
|
135
|
+
entry = entry.sub(/\/$/, "")
|
136
|
+
if entry =~ /^(\S+?)(\?)?(?:\s+(.+))?\s*$/
|
137
|
+
filename = $1
|
138
|
+
optional = !$2.nil?
|
139
|
+
args = expand_string($3 || '').split
|
140
|
+
file = expand_filename(dir, filename)
|
141
|
+
file || optional or raise Error, "Can't find #{filename} in #{dir} from #{unit}"
|
142
|
+
!file.nil? or return nil
|
127
143
|
else
|
128
|
-
file
|
144
|
+
raise Error, "Not a file name: '#{entry}'"
|
129
145
|
end
|
130
146
|
path = "#{dir}/#{file}"
|
131
|
-
[path,
|
147
|
+
[path, entry, file, args].flatten
|
132
148
|
end
|
133
149
|
|
150
|
+
# def parse_file_entry(dir, entry)
|
151
|
+
# name = expand_environment(dir, entry)
|
152
|
+
# name.sub!(/\/$/, "")
|
153
|
+
# if name =~ /^(\S+)\s+(.+)$/ # has arguments -> exe
|
154
|
+
# file = $1
|
155
|
+
# args = $2.split
|
156
|
+
# else
|
157
|
+
# file = name
|
158
|
+
# end
|
159
|
+
# path = "#{dir}/#{file}"
|
160
|
+
# [path, name, file, args]
|
161
|
+
# end
|
162
|
+
|
134
163
|
def parse_entry(unit, phase, dir, entry)
|
135
164
|
if entry.is_a?(Hash)
|
136
165
|
entry.size == 1 or raise Error, "sql and module are single-line values"
|
137
166
|
key, value = entry.first
|
138
167
|
case key
|
139
168
|
when "sql"
|
140
|
-
InlineNode.new(unit, phase, unit.path, value)
|
141
|
-
when "call"
|
142
|
-
args = value
|
143
|
-
|
144
|
-
file, klass, command, args = *args
|
169
|
+
InlineNode.new(unit, phase, unit.path, expand_string(value))
|
170
|
+
when "call"
|
171
|
+
(path, name, file, klass, command, args = parse_file_entry(unit, dir, value)) or return nil
|
172
|
+
klass && command or raise "Illegal number of arguments: #{value}"
|
145
173
|
ModuleNode.new(unit, phase, "#{dir}/#{file}", klass, command, args)
|
146
174
|
when "exec"
|
147
|
-
path, name, file, args = parse_file_entry(dir, value)
|
175
|
+
(path, name, file, args = parse_file_entry(unit, dir, value)) or return nil
|
148
176
|
ExeNode.new(unit, phase, path, args)
|
149
177
|
else
|
150
178
|
raise Error, "Illegal key: #{key}"
|
151
179
|
end
|
152
180
|
else
|
153
|
-
path, name, file, args = parse_file_entry(dir, entry)
|
181
|
+
(path, name, file, args = parse_file_entry(unit, dir, entry)) or return nil
|
154
182
|
if File.directory? path
|
155
183
|
parse_directory(unit, path)
|
156
184
|
elsif File.file? path
|
data/lib/prick/version.rb
CHANGED
@@ -6,13 +6,14 @@ module Prick::SubCommand
|
|
6
6
|
def self.teardown(database, username)
|
7
7
|
conn = PgConn.new "postgres" # Superuser connection
|
8
8
|
if conn.rdbms.exist? database
|
9
|
-
conn.rdbms.drop database
|
9
|
+
conn.rdbms.drop database, force: true
|
10
10
|
end
|
11
11
|
if conn.role.exist? username
|
12
12
|
conn.role.drop username, cascade: true
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
# TODO Run builder teardown scrips
|
16
|
+
# builder = Prick::Build::Builder.new(conn, "schema")
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.28.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: semantic
|
@@ -231,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
231
231
|
- !ruby/object:Gem::Version
|
232
232
|
version: '0'
|
233
233
|
requirements: []
|
234
|
-
rubygems_version: 3.3.
|
234
|
+
rubygems_version: 3.3.7
|
235
235
|
signing_key:
|
236
236
|
specification_version: 4
|
237
237
|
summary: A release control and management system for postgresql
|