prick 0.36.0 → 0.38.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49ed6762f3557cc979f89bb1aaee3d5aa1d8d11a5ba9c7880a8b692d917dc733
4
- data.tar.gz: 16436521e2f9a51ed6c2076ba2a54f968735868a711d170253691a69a4b34fb4
3
+ metadata.gz: e44c6bb60e5ae3fe9a90935d641c116ccac1ff93790385880085dbe65cbca19c
4
+ data.tar.gz: bc04dc4f8f7c145c36f46fdeacb7ebb0fd751c4446f4adf1ecc0f2449098b6a5
5
5
  SHA512:
6
- metadata.gz: eedba5e0757b8f19c94d4bf898ea156b93090cd2466e333860d7a4da9ce91d75fbc4acab596bbc06b0a8f260909c9770715299c55040c017d45b7f679d5528f0
7
- data.tar.gz: 7d98f2a0a8e6ed8230bc44b3d16d1c46f4baa85956bdbcd893325e2d062d8a6d46c4277cf85af8c5e833fb20bbf8324a75d8788d05418cd87185976c6c16a76a
6
+ metadata.gz: 3a210f76e1d1ad412185a9bc52229ecb48119e3e5542d216e26750116cd6e807bce7d6435a293987dfa897ba5ded23c39f26a287259d8ebc55ec5154610a720c
7
+ data.tar.gz: e59379e97b66b72be5a6d43288ce8665f6dd3400f99e5ed5ec39308b2fe849592b143819f36e6c3f5ce6ca2edb9e1db5775e697cf171ead49832a71ab4877954
data/exe/prick CHANGED
@@ -157,6 +157,9 @@ SPEC = %(
157
157
  used by 'drop data' to reset data to the point in time of the snapshot.
158
158
  Only one snapshot can be created at a time
159
159
 
160
+ reset!
161
+ Restore database to the last snapshot. TODO
162
+
160
163
  version!
161
164
  Print project version
162
165
 
@@ -229,6 +232,10 @@ def require_db(database = Prick.state&.database, exist: true)
229
232
  end
230
233
  end
231
234
 
235
+ def clean_pg_meta_cache
236
+ FileUtils.rm_f(PG_META_STATE_PATH)
237
+ end
238
+
232
239
  def parse_database_args(state, args)
233
240
  arg, environment = args.expect(0..2)
234
241
  if arg
@@ -308,6 +315,7 @@ begin
308
315
  puts "#{Prick.state.name}-#{Prick.state.version}"
309
316
 
310
317
  when :setup!
318
+ clean_pg_meta_cache
311
319
  state.project_loaded? or Prick.error "No #{project_file} found"
312
320
  username, database, environment = parse_database_args(state, args)
313
321
  require_db(database, exist: false)
@@ -315,6 +323,7 @@ begin
315
323
 
316
324
  # FIXME Ensure that we never drop the current user
317
325
  when :teardown!
326
+ clean_pg_meta_cache
318
327
  if args.empty?
319
328
  Prick::SubCommand.teardown(database, remove_state_file: true)
320
329
  else
@@ -331,11 +340,13 @@ begin
331
340
  end
332
341
 
333
342
  when :set!
343
+ clean_pg_meta_cache
334
344
  variable, *args = args.expect(1..3)
335
345
  require_db(database) if variable == "duration"
336
346
  Prick::SubCommand.set(variable, *args) or error "Illegal variable name '#{variable}'"
337
347
 
338
348
  when :clean!
349
+ clean_pg_meta_cache
339
350
  database = args.expect(0..1) || database
340
351
  require_db(database)
341
352
  Prick::SubCommand.clean(database)
@@ -344,10 +355,12 @@ begin
344
355
  create_command = opts.create! # Because we need easy access to subcommand options
345
356
  case create_command.subcommand
346
357
  when :database!
358
+ clean_pg_meta_cache
347
359
  database, username, environment = parse_database_args(state, args)
348
360
  require_db(database, exist: false)
349
361
  Prick::SubCommand.create_database(database, username, environment)
350
362
  when :migration!
363
+ # clean_pg_meta_cache # FIXME ?
351
364
  require_db
352
365
  arg = args.expect(1)
353
366
  version = PrickVersion.try(arg) or Prick.error "Illegal version: #{arg}"
@@ -363,6 +376,7 @@ begin
363
376
 
364
377
  when :build!
365
378
  require_db
379
+ clean_pg_meta_cache
366
380
  dump = cmd.dump? ? cmd.dump("batches")&.to_sym || :batches : nil
367
381
  # exclude = cmd.exclude? ? cmd.exclude.split(",") : []
368
382
  Prick::SubCommand.build(
@@ -371,6 +385,7 @@ begin
371
385
 
372
386
  when :make!
373
387
  require_db
388
+ clean_pg_meta_cache
374
389
  dump = cmd.dump? ? cmd.dump("batches")&.to_sym || :batches : nil
375
390
  Prick::SubCommand.make(
376
391
  database, username, args.expect(0..1),
@@ -378,6 +393,7 @@ begin
378
393
 
379
394
  when :run!
380
395
  require_db
396
+ clean_pg_meta_cache
381
397
  dump = cmd.dump? ? cmd.dump("batches")&.to_sym || :batches : nil
382
398
  Prick::SubCommand.run(
383
399
  database, username, args.expect(1),
@@ -385,6 +401,7 @@ begin
385
401
 
386
402
  when :bash!
387
403
  args.expect(0)
404
+ clean_pg_meta_cache
388
405
  Prick::SubCommand.bash(main: cmd.main?)
389
406
 
390
407
  when :fox!
@@ -396,6 +413,11 @@ begin
396
413
  args.expect(0)
397
414
  Prick::SubCommand.snapshot(database, username)
398
415
 
416
+ when :reset!
417
+ require_db
418
+ args.expect(0)
419
+ Prick::SubCommand.drop_data(database)
420
+
399
421
  when :drop!
400
422
  case cmd.subcommand
401
423
  when :users!
@@ -408,6 +430,7 @@ begin
408
430
  owner = args.expect(0..1) || username
409
431
  Prick::SubCommand.drop_owner(owner)
410
432
  when :database!
433
+ clean_pg_meta_cache
411
434
  database = args.expect(0..1) || database
412
435
  Prick::SubCommand.drop_database(database)
413
436
  when :data!
@@ -416,6 +439,7 @@ begin
416
439
  Prick::SubCommand.drop_data(database)
417
440
  when :schema!
418
441
  require_db
442
+ clean_pg_meta_cache
419
443
  schemas = args.to_a
420
444
  Prick::SubCommand.drop_schema(database, schemas)
421
445
  else
@@ -430,6 +454,7 @@ begin
430
454
 
431
455
  when :migrate!
432
456
  require_db
457
+ # clean_pg_meta_cache # FIXME ?
433
458
  args.expect(0)
434
459
  Prick::SubCommand.migrate(database, username, file: cmd.file)
435
460
 
@@ -15,8 +15,6 @@ module Prick
15
15
  def schema() @schema ||= parent&.schema || "public" end
16
16
  def schema=(s) @schema = s end
17
17
 
18
- attr_reader :source
19
-
20
18
  def source
21
19
  @source ||= read_source
22
20
  end
@@ -98,6 +98,7 @@ module Prick
98
98
  # value is returned
99
99
  def parse_file_entry(unit, dir, entry)
100
100
  entry = entry.sub(/\/$/, "")
101
+ # puts "#parse_file_entry(#{unit.path.inspect}, #{dir.inspect}, #{entry.inspect})"
101
102
  if entry =~ /^(\S+?)(\?)?(?:\s+(.+))?\s*$/
102
103
  command = $1
103
104
  optional = !$2.nil?
@@ -141,7 +142,7 @@ module Prick
141
142
  (path, args = parse_file_entry(unit, dir, entry)) or return nil
142
143
  if File.directory? path
143
144
  parse_directory(unit, path)
144
- elsif File.executable? path
145
+ elsif File.executable?(path)
145
146
  ExecNode.new(unit, phase, path, args)
146
147
  elsif File.file? path
147
148
  case path
@@ -166,10 +167,13 @@ module Prick
166
167
  #
167
168
  # Note that "." is ignored in the search path
168
169
  def find_executable(filename) # ChatGPT
169
- Prick.state.executable_search_path.split(File::PATH_SEPARATOR).each do |directory|
170
- next if directory == "."
171
- path = File.join(directory, filename)
172
- return path if File.file?(path) && File.executable?(path)
170
+ # puts "#find_executable(#{filename.inspect})"
171
+ if !Prick.state.environments.key?(filename) # Environment names are reserved
172
+ Prick.state.executable_search_path.split(File::PATH_SEPARATOR).each do |directory|
173
+ next if directory == "."
174
+ path = File.join(directory, filename)
175
+ return path if File.file?(path) && File.executable?(path)
176
+ end
173
177
  end
174
178
  nil
175
179
  end
@@ -40,6 +40,8 @@ module Prick
40
40
  PRICK_ENVIRONMENT_FILE = "prick.environment.yml"
41
41
  PRICK_ENVIRONMENT_PATH = PRICK_ENVIRONMENT_FILE
42
42
 
43
+ # TODO: Move to var/cache
44
+
43
45
  # State file
44
46
  PRICK_STATE_FILE = ".prick.state.yml"
45
47
  PRICK_STATE_PATH = PRICK_STATE_FILE
@@ -48,6 +50,10 @@ module Prick
48
50
  FOX_STATE_FILE = ".fox-state.yml"
49
51
  FOX_STATE_PATH = FOX_STATE_FILE
50
52
 
53
+ # PgMeta snapshot. Is deleted at the start of each build
54
+ PG_META_STATE_FILE = ".pg_meta-state.yml"
55
+ PG_META_STATE_PATH = PG_META_STATE_FILE
56
+
51
57
  # Reflections file
52
58
  REFLECTIONS_FILE = "reflections.yml"
53
59
  REFLECTIONS_PATH = File.join(SCHEMA_DIR, REFLECTIONS_FILE)
data/lib/prick/state.rb CHANGED
@@ -239,7 +239,7 @@ module Prick
239
239
  # It is an error if the project file exists.
240
240
  def save_project(overwrite: false)
241
241
  overwrite || !File.exists?(project_file) or Prick.error "Won't overwrite '#{project_file}'"
242
- hash = { name: name, title: title, version: version.to_s, prick: prick_version.to_s }
242
+ hash = { name: name, title: title, version: version.to_s, prick: Prick::VERSION }
243
243
  save_yaml(project_file, hash)
244
244
  end
245
245
 
@@ -264,10 +264,11 @@ module Prick
264
264
  @build_id = insert_record(
265
265
  "prick.builds",
266
266
  name: name,
267
- version: version.to_s, prick: prick_version,
267
+ version: version.to_s, prick: Prick::VERSION,
268
268
  branch: branch, rev: rev(kind: :short), clean: clean?,
269
269
  environment: environment)
270
270
  end
271
+ # version: version.to_s, prick: prick_version,
271
272
  end
272
273
 
273
274
  def save_build_end(success, duration)
@@ -278,7 +279,7 @@ module Prick
278
279
  insert_record(
279
280
  "prick.builds",
280
281
  name: name,
281
- version: version.to_s, prick: prick_version,
282
+ version: version.to_s, prick: Prick::VERSION,
282
283
  branch: branch, rev: rev(kind: :short), clean: clean?,
283
284
  environment: environment,
284
285
  success: success, duration: duration, prick_duration: dt)
data/lib/prick/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prick
4
- VERSION = "0.36.0"
4
+ VERSION = "0.38.0"
5
5
  end
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.36.0
4
+ version: 0.38.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: 2024-05-06 00:00:00.000000000 Z
11
+ date: 2024-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semantic