prick 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/prick +1 -1
- data/lib/prick/builder.rb +10 -2
- data/lib/prick/rdbms.rb +5 -6
- data/lib/prick/version.rb +1 -1
- data/share/schema/schema.sql +0 -2
- data/share/schema/schema/prick/schema.sql +0 -2
- data/share/schema/schema/public/build.yml +0 -1
- metadata +2 -3
- data/share/schema/schema/public/schema.sql +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fa13b0150bd8e2a403643947215116be13d78d33f053e15c766a258574cf79e
|
4
|
+
data.tar.gz: 8b817641aff64c1ad488ce7562ac03a26c8d2144b3bf79999ef0af0ae910d298
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b0896b4d9d38984cee6f3a3d6481ed4b9607c54101a120aaa4344b701ed649fe7ef5ca25bcb1214aa1802700e80e0bee41aa47157039f4f2774825d0af04f44
|
7
|
+
data.tar.gz: e19f8f4b6529bc1463f01fdcb5077ddfd55fe970ac062ef8fbbfd79dd31d1c8f74dcef759222cfdbaf4890158ef6b7993ddeb369d8c0499ead2265f20073769a
|
data/exe/prick
CHANGED
data/lib/prick/builder.rb
CHANGED
@@ -20,6 +20,8 @@ module Prick
|
|
20
20
|
# If a directory doesn't contain a build resource, the resources in the
|
21
21
|
# directory are built in alphabetic order
|
22
22
|
#
|
23
|
+
# Build SQL scripts are executed with search path set to containing schema
|
24
|
+
#
|
23
25
|
class Builder
|
24
26
|
attr_reader :database
|
25
27
|
attr_reader :directory
|
@@ -57,11 +59,11 @@ module Prick
|
|
57
59
|
Dir.chdir(dir) { yield(file) }
|
58
60
|
end
|
59
61
|
|
60
|
-
def do_sql(path)
|
62
|
+
def do_sql(path, schema: nil)
|
61
63
|
# puts "do_sql(#{path})"
|
62
64
|
do_dir(path) { |file|
|
63
65
|
if @execute
|
64
|
-
Rdbms.exec_file(database.name, file, user: database.user)
|
66
|
+
Rdbms.exec_file(database.name, file, user: database.user, schema: schema)
|
65
67
|
else
|
66
68
|
@lines += IO.readlines(file).map(&:chomp)
|
67
69
|
end
|
@@ -159,6 +161,12 @@ module Prick
|
|
159
161
|
end
|
160
162
|
|
161
163
|
def self.yml_file(directory) File.join(directory, "build") + ".yml" end
|
164
|
+
|
165
|
+
protected
|
166
|
+
def do_sql(path)
|
167
|
+
schema = Dir.getwd.sub(/^.*schema\/([^\/]+)(?:\/.*)?$/, '\1')
|
168
|
+
super(path, schema: schema)
|
169
|
+
end
|
162
170
|
end
|
163
171
|
end
|
164
172
|
|
data/lib/prick/rdbms.rb
CHANGED
@@ -4,16 +4,15 @@ require 'csv'
|
|
4
4
|
|
5
5
|
module Prick
|
6
6
|
module Rdbms
|
7
|
-
# extend Ensure
|
8
|
-
|
9
7
|
### EXECUTE SQL
|
10
8
|
|
11
9
|
# Execute the SQL statement and return stdout as an array of tuples
|
12
|
-
def self.exec_sql(db, sql, user: ENV['USER'])
|
10
|
+
def self.exec_sql(db, sql, user: ENV['USER'], schema: nil)
|
11
|
+
schema ||= "public"
|
13
12
|
stdout = Command.command %(
|
14
13
|
{
|
15
14
|
echo "set role #{user};"
|
16
|
-
echo "set search_path to
|
15
|
+
echo "set search_path to #{schema};"
|
17
16
|
cat <<'EOF'
|
18
17
|
#{sql}
|
19
18
|
EOF
|
@@ -23,8 +22,8 @@ EOF
|
|
23
22
|
end
|
24
23
|
|
25
24
|
# Execute the given file and return stdout as an array of tuples
|
26
|
-
def self.exec_file(db, file, user: ENV['USER'])
|
27
|
-
self.exec_sql(db, File.read(file), user: user)
|
25
|
+
def self.exec_file(db, file, user: ENV['USER'], schema: nil)
|
26
|
+
self.exec_sql(db, File.read(file), user: user, schema: schema)
|
28
27
|
end
|
29
28
|
|
30
29
|
# Execute the SQL statement and return the result as an array of record tuples
|
data/lib/prick/version.rb
CHANGED
data/share/schema/schema.sql
CHANGED
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.10.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: 2021-02-
|
11
|
+
date: 2021-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shellopts
|
@@ -133,7 +133,6 @@ files:
|
|
133
133
|
- share/schema/schema/prick/tables.sql
|
134
134
|
- share/schema/schema/public/.keep
|
135
135
|
- share/schema/schema/public/build.yml
|
136
|
-
- share/schema/schema/public/schema.sql
|
137
136
|
- test_assorted
|
138
137
|
- test_feature
|
139
138
|
- test_refactor
|