prick 0.26.0 → 0.27.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/TODO +3 -0
- data/exe/prick +1 -1
- data/lib/builder/builder.rb +1 -0
- data/lib/builder/parser.rb +46 -5
- data/lib/ext/expand_variables.rb +27 -0
- data/lib/prick/version.rb +1 -1
- data/lib/prick.rb +1 -0
- data/lib/share/init/spec/spec_helper.rb +1 -1
- 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: fe266587f9311853dc79a6eee9ff2732ba265fd50ce1fb69fb0ba1d8f2018f5a
|
4
|
+
data.tar.gz: f364180b63248c6b1cbc963cad889770538aabfbc5b0ec9d12aabe97e91fd1dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ab04d20f8169352ac7c6e181b053c3e5271e60c5109af444fd8abb37ad3ce5d101e37f2c2ee06c801b0b7a18662fad65384b6434e592abefd18a1c48b7ee442
|
7
|
+
data.tar.gz: f8108b5acec772b9ee63b7f8acc46aa9a1b54fea79766cd1c7ed449a8d069484d6ffd74296a6f90d2eac9dc368656d680bdf03e0ab9f140d336cac46ea104219
|
data/TODO
CHANGED
data/exe/prick
CHANGED
@@ -200,7 +200,7 @@ begin
|
|
200
200
|
database, username, args.expect(0..1), force: cmd.force?, timer: cmd.time?, dump: dump)
|
201
201
|
|
202
202
|
when :make!
|
203
|
-
dump = cmd.dump? ? cmd.dump("batches")
|
203
|
+
dump = cmd.dump? ? cmd.dump("batches")&.to_sym || :batches : nil
|
204
204
|
Prick::SubCommand.make(database, username, args.expect(0..1), timer: cmd.time?, dump: dump)
|
205
205
|
|
206
206
|
when :fox!
|
data/lib/builder/builder.rb
CHANGED
data/lib/builder/parser.rb
CHANGED
@@ -8,11 +8,12 @@ module Prick
|
|
8
8
|
|
9
9
|
attr_reader :conn
|
10
10
|
attr_reader :dir
|
11
|
-
attr_reader :unit
|
11
|
+
attr_reader :unit # The singular RootBuildNode object
|
12
12
|
# attr_reader :schemas
|
13
13
|
|
14
14
|
def initialize(conn)
|
15
15
|
@conn = conn
|
16
|
+
@unit = nil
|
16
17
|
end
|
17
18
|
|
18
19
|
def parse(dir)
|
@@ -24,7 +25,7 @@ module Prick
|
|
24
25
|
|
25
26
|
private
|
26
27
|
|
27
|
-
# First
|
28
|
+
# First built unit is a RootBuildNode, the rest are regular BuildNode objects
|
28
29
|
def make_build_unit(parent, path)
|
29
30
|
if @unit
|
30
31
|
BuildNode.new(parent, path)
|
@@ -76,11 +77,51 @@ module Prick
|
|
76
77
|
unit
|
77
78
|
end
|
78
79
|
|
80
|
+
# Expand $ENVIRONMENT variable. The function implements a hierarchy of
|
81
|
+
# environments:
|
82
|
+
#
|
83
|
+
# production
|
84
|
+
# online
|
85
|
+
# development
|
86
|
+
# online
|
87
|
+
# offline
|
88
|
+
# backend
|
89
|
+
# frontend
|
90
|
+
# test
|
91
|
+
#
|
92
|
+
# If an environment doesn't exist in #dir, then the higher level
|
93
|
+
# environments are tried in turn. Eg. if the current environment is
|
94
|
+
# 'test', the algorithm expands '$ENVIRONMENT' to 'test', 'offline', and
|
95
|
+
# 'development' until an existing file is found. If no file is found, the
|
96
|
+
# algorithm returns the unexpanded value
|
97
|
+
#
|
98
|
+
def expand_environment(dir, name)
|
99
|
+
env = Prick.state.environment.to_s
|
100
|
+
file = name
|
101
|
+
if !File.exist?("#{dir}/#{file}") && name =~ /^(.*?)\$ENVIRONMENT/
|
102
|
+
while true
|
103
|
+
file = expand_variables(name, ENVIRONMENT: env)
|
104
|
+
break if File.exist? "#{dir}/#{file}"
|
105
|
+
case env
|
106
|
+
when "production"; break
|
107
|
+
when "development"; break
|
108
|
+
when "online"; env = "development"
|
109
|
+
when "offline"; env = "development"
|
110
|
+
when "backend"; env = "offline"
|
111
|
+
when "frontend"; env = "offline"
|
112
|
+
when "test"; env = "offline"
|
113
|
+
else
|
114
|
+
raise Error, "Illegal env: '#{env}'"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
return file
|
119
|
+
end
|
120
|
+
|
79
121
|
def parse_file_entry(dir, entry)
|
80
|
-
name = entry
|
81
|
-
name.sub!(/\$ENVIRONMENT/, Prick.state.environment.to_s)
|
122
|
+
name = expand_environment(dir, entry)
|
82
123
|
name.sub!(/\/$/, "")
|
83
|
-
if name =~ /^(\S+)\s+(
|
124
|
+
if name =~ /^(\S+)\s+(.+)$/ # has arguments -> exe
|
84
125
|
file = $1
|
85
126
|
args = $2.split
|
86
127
|
else
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
# Expands variables in a template string. Variables are prefixed with a $ sign
|
3
|
+
# and consist of word characters (letters, digits, underscores). The name can
|
4
|
+
# be enclosed in curly braces to avoid unintended expansions. The $ sign can be
|
5
|
+
# escaped with a backslash (\), and backslashes can be escaped with another
|
6
|
+
# backslash. All occurrences of a variable in the string are replaced
|
7
|
+
#
|
8
|
+
# The str argument is the template string and the variables argument is a hash
|
9
|
+
# from variable name (Symbol) to variable value
|
10
|
+
#
|
11
|
+
# Note that the characters '\x00' and '\x01' are used internally and may not be
|
12
|
+
# present in the template string
|
13
|
+
#
|
14
|
+
def expand_variables(str, variables) # ChatGPT
|
15
|
+
# Replace escaped bashslashes and dollar signs
|
16
|
+
str = str.gsub('\\\\', "\x00").gsub('\\$', "\x01")
|
17
|
+
|
18
|
+
# Expand variables
|
19
|
+
str.gsub!(/\$(\w+)\b|\$\{(\w+)\}/) do |match| # Strange that '\b' is necessary
|
20
|
+
key = ($1 || $2).to_sym
|
21
|
+
variables[key] || match
|
22
|
+
end
|
23
|
+
|
24
|
+
# Restore escaped characters
|
25
|
+
str.gsub("\x00", '\\').gsub("\x01", '$')
|
26
|
+
end
|
27
|
+
|
data/lib/prick/version.rb
CHANGED
data/lib/prick.rb
CHANGED
@@ -40,7 +40,7 @@ require 'postspec_helper'
|
|
40
40
|
require 'prick_helper'
|
41
41
|
|
42
42
|
Postspec.configure do |config|
|
43
|
-
config.database =
|
43
|
+
config.database = Prick.state.database
|
44
44
|
# config.anchors = "..."
|
45
45
|
config.mode = :seed
|
46
46
|
config.reflections = Prick::REFLECTIONS_PATH if File.exist?(Prick::REFLECTIONS_PATH)
|
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.27.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: semantic
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- lib/builder/node.rb
|
174
174
|
- lib/builder/node_pool.rb
|
175
175
|
- lib/builder/parser.rb
|
176
|
+
- lib/ext/expand_variables.rb
|
176
177
|
- lib/local/command.rb
|
177
178
|
- lib/local/git.rb
|
178
179
|
- lib/local/timer.rb
|