prick 0.36.0 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49ed6762f3557cc979f89bb1aaee3d5aa1d8d11a5ba9c7880a8b692d917dc733
4
- data.tar.gz: 16436521e2f9a51ed6c2076ba2a54f968735868a711d170253691a69a4b34fb4
3
+ metadata.gz: aa15e8c866ef97ee0ba04de08ca05ea38b5cf47d6cb156e09be24d3e10a0c8d5
4
+ data.tar.gz: 550a8f65c73c1148fa8f9359dbfb7299d0ae2ca4c8acfc3aea7c82f7254c399f
5
5
  SHA512:
6
- metadata.gz: eedba5e0757b8f19c94d4bf898ea156b93090cd2466e333860d7a4da9ce91d75fbc4acab596bbc06b0a8f260909c9770715299c55040c017d45b7f679d5528f0
7
- data.tar.gz: 7d98f2a0a8e6ed8230bc44b3d16d1c46f4baa85956bdbcd893325e2d062d8a6d46c4277cf85af8c5e833fb20bbf8324a75d8788d05418cd87185976c6c16a76a
6
+ metadata.gz: 0b6ccea7c28cb6068597899dc8f740629fc7e3d26d7457a06c7c0e76abca1987cf63e422f2be482300c8b44474e0cda941510c1e97653ec4af064c57bb79eea4
7
+ data.tar.gz: 2e2685d9b25938dc291204eaa7735a167cbd7014219678dddb86ed6e02aa90c960de3aaf8e79fbe64becfff198d435c5ad05aa1657856ce1e1ea5bacee1de9d2
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!
@@ -408,6 +425,7 @@ begin
408
425
  owner = args.expect(0..1) || username
409
426
  Prick::SubCommand.drop_owner(owner)
410
427
  when :database!
428
+ clean_pg_meta_cache
411
429
  database = args.expect(0..1) || database
412
430
  Prick::SubCommand.drop_database(database)
413
431
  when :data!
@@ -416,6 +434,7 @@ begin
416
434
  Prick::SubCommand.drop_data(database)
417
435
  when :schema!
418
436
  require_db
437
+ clean_pg_meta_cache
419
438
  schemas = args.to_a
420
439
  Prick::SubCommand.drop_schema(database, schemas)
421
440
  else
@@ -430,6 +449,7 @@ begin
430
449
 
431
450
  when :migrate!
432
451
  require_db
452
+ # clean_pg_meta_cache # FIXME ?
433
453
  args.expect(0)
434
454
  Prick::SubCommand.migrate(database, username, file: cmd.file)
435
455
 
@@ -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/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.37.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.37.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-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: semantic