prick 0.5.0 → 0.6.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: 67c64dcd2eb2d716544b81a7b17f15c8b42af6b863821f411596fac4b6868edd
4
- data.tar.gz: 178c2bd8cd8617fb4a10d6e1f76f15a601bb1341a2c64456a5c83ecc9eeff629
3
+ metadata.gz: d1acbb39706f5c58e4ef47230fa18cea7fb16d3c15c3fdc500624b859b4328bc
4
+ data.tar.gz: 9853c05b7f3717d0c12e68595f0dd945d95d84f372b7d438efe222ba2388e62a
5
5
  SHA512:
6
- metadata.gz: 31fd38814ff54a3b535cabe371f1578abfcd025e749e9a9b1d18cdd454f7c74e5797b9166c4429f1bbda5ece50432bc0ace27d07a97e25591d1bae9648bb4b63
7
- data.tar.gz: 8c9bf98db283cb79a11edd4016339c74c84fc02517b9872b476e776ecf21e91ecde490e87689a8ae1a041ecd25836f92d5d145ac6e2452824480a8a9db5c65c5
6
+ metadata.gz: f3ad4787717d1f9c3a1eb6d727dbfd9b5a22b0a13c22951d25a757ead4bae71831ba35d26dc2dbec5b68d826c3469c44eded315dade0de4f6819e6c4193a7389
7
+ data.tar.gz: a630950080794df280914d7980095827010ae717ea14262a4dc4a95b25af2fbbb50a4116d52fb912461a1a03aa9be910ad6a115857ba5fbe70cb20b1d977aa87
data/exe/prick CHANGED
@@ -4,206 +4,163 @@ require 'prick.rb'
4
4
  require 'prick/program.rb'
5
5
 
6
6
  require 'shellopts'
7
- require 'indented_io'
8
7
 
9
8
  require 'tempfile'
10
9
 
11
10
  include ShellOpts
12
11
  include Prick
13
12
 
14
- PROGRAM = File.basename($0)
15
-
16
13
  SPEC = %(
17
- n,name=NAME
18
- C,directory=DIR
19
- h,help
20
- v,verbose
21
- q,quiet
22
- version
23
-
24
- init! u,user=USER
25
-
26
- info!
27
- list!
28
- list.releases! m,migrations c,cancelled
29
- list.migrations!
30
- list.upgrades! a,all
31
- list.cache!
32
-
33
- build! d,database=DATABASE C,nocache
34
- make! d,database=DATABASE C,nocache
35
- make.clean! a,all
36
- load! d,database=DATABASE
37
- save!
38
- drop! a,all
39
-
40
- diff! m,mark t,tables T,notables
41
- migrate!
42
-
43
- prepare! prepare.release! prepare.migration! prepare.schema! prepare.diff!
44
- include! include.feature!
45
- check!
46
-
47
- create! create.release! create.prerelease! create.feature!
48
- cancel! cancel.release!
49
-
50
- generate! generate.migration! generate.schema!
51
- upgrade!
52
- backup!
53
- restore!
54
- )
55
-
56
- USAGE = "Usage: #{PROGRAM} -h -v -n NAME -C DIR COMMAND" # FIXME: Why doesn't shellopts include PROGRAM?
57
-
58
- HELP = %(
59
- NAME
60
- prick - Database version management
61
-
62
- USAGE
63
- prick -v -n NAME -C DIR -h <command>
64
-
65
- OPTIONS
66
- -n, --name=NAME
14
+ -n,name=NAME
67
15
  Name of project. Defauls to the environment variable `PRICK_PROJECT` if
68
16
  set and else the name of the current directory
69
17
 
70
- -C, --directory=DIR
71
- Change to directory DIR before anything else
18
+ -C,directory=DIR
19
+ Change to directory DIR before doing anything else
72
20
 
73
- -h, --help
21
+ -h,help COMMAND...
74
22
  Print this page
75
23
 
76
- -v, --verbose
77
- Be verbose
78
-
79
- --version
80
- Print prick version
24
+ +v,verbose
25
+ Be verbose. Repeated --verbose options increase the verbosity level
81
26
 
82
- COMMANDS
83
- INITIALIZATION
84
- init --user=USER [DIR]
85
- Initialize a project in the given directory. DIR defaults to the
86
- current directory. The USER is the postgres user, it defaults to
87
- the project name
27
+ -q,quiet
28
+ Be quiet
88
29
 
89
- INFO COMMANDS
90
- info
30
+ --version
31
+ Print prick version
91
32
 
92
- list releases --migrations --cancelled
93
- list migrations
94
- list upgrades --all
95
- List releases/migrations/upgrades
33
+ init! -u,user=USER [DIR]
34
+ Initialize a project in the given directory. DIR defaults to the current
35
+ directory. The USER is the postgres user, it defaults to the project name
96
36
 
97
- BUILDING
98
- build -d DATABASE -C --nocache [TAG]
99
- Build the current database from the content in the schemas/ directory.
100
- With a tag the version is built into the associated versioned database.
101
- The result is saved to cache unless the -C option is given. The -d option
102
- overrides the default database
37
+ info!
38
+ Print project information
103
39
 
104
- make -d DATABASE -C --nocache [TAG]
105
- Loads the current database from cache if present and build it
106
- otherwise. With a tag, the version is built into the associated
107
- versioned database. The -C option ignores the cache and the -d option
108
- overrides the default database
40
+ list.releases! -m,migrations -c,cancelled
41
+ List releases. Include migration releases if the --migration option is
42
+ present and also include cancelled releases if the --cancelled option is
43
+ present
109
44
 
110
- make clean -a
111
- Drop versioned databases and remove cached and other temporary files.
112
- Also drop the project database if the -a option is given
113
-
114
- load -d DATABASE VERSION|FILE
115
- Load the cached version or the file into the associated versioned
116
- database. It is an error if the version hasn't been cached. The
117
- --database argument overrides the database
45
+ list.migrations!
46
+ List migrations
118
47
 
119
- save VERSION [FILE]
120
- Save the versioned database associated with version to the cache or the
121
- given file
48
+ list.upgrades! [FROM [TO]]
49
+ List available upgrades
122
50
 
123
- drop --all [DATABASE]
124
- Drop the given database or all versioned databases. The --all option also drops the project
125
- database
126
-
51
+ list.cache!
52
+ List cache files
53
+
54
+ build! -d,database=DATABASE -C,no-cache [TAG]
55
+ Build the current database from the content in the schemas/ directory.
56
+ With a tag the version is built into the associated versioned database
57
+ and the result is saved to cache unless the -C option is given. The -d
58
+ option overrides the default database
59
+
60
+ make! -d,database=DATABASE -C,no-cache [TAG]
61
+ Build the current database from the content in the schemas/ directory.
62
+ With a tag the associated versioned database is loaded from cache if
63
+ present. The -C option ignores the cache and the -d option overrides
64
+ the default database
65
+
66
+ make.clean! -a,all
67
+ Drop versioned databases and remove cached and other temporary files.
68
+ Also drop the project database if the -a option is given
69
+
70
+ load! -d,database=DATABASE VERSION|FILE
71
+ Load the cached version or the file into the associated versioned
72
+ database. It is an error if the version hasn't been cached. The --database
73
+ argument overrides the database
74
+
75
+ save! VERSION [FILE]
76
+ Save the versioned database associated with version to the cache or the
77
+ given file
78
+
79
+ drop! -a,all [DATABASE]
80
+ Drop the given database or all versioned databases. The --all option also
81
+ drops the project database
82
+
83
+ diff! -m,mark -t,tables -T,notables
127
84
  diff [FROM-DATABASE|FROM-VERSION [TO-DATABASE|TO-VERSION]]
128
- Create a schema diff between the given databases or versions. Default
129
- to-version is the current schema and default from-version is the base
130
- version of this branch/tag
85
+ Create a schema diff between the given databases or versions. Default
86
+ to-version is the current schema and default from-version is the base
87
+ version of this branch/tag
131
88
 
132
- migrate
133
- Not yet implemented
89
+ migrate!
90
+ Not yet implemented
134
91
 
135
- PREPARING RELEASES
136
- prepare release [FORK]
137
- Populate the current migration directory with migration files
92
+ prepare!
93
+ Prepare a release. Just a shorthand for 'prick prepare release'
138
94
 
139
- prepare feature NAME
140
- Create and populate a feature as a subdirectory of the current
141
- directory. Also prepares the current release directory
95
+ prepare.release! [FORK]
96
+ Populate the current migration directory with migration files
142
97
 
143
- prepare migration FROM
144
- Create and populate a migration directory
98
+ prepare.feature! NAME
99
+ Create and populate a feature as a subdirectory of the current directory.
100
+ Also prepares the current release directory
145
101
 
146
- prepare schema NAME
147
- Create and populate a new schema directory. Existing files and
148
- directories are kept
102
+ prepare.migration! [FROM]
103
+ Create and populate a migration directory
149
104
 
150
- prepare diff [VERSION]
105
+ prepare.schema! NAME
106
+ Create and populate a new schema directory. Existing files and
107
+ directories are kept
108
+
109
+ prepare.diff! [VERSION]
110
+ Not yet implemented
151
111
 
152
- include feature FEATURE
153
- Include the given feature in the current pre-release
112
+ include.feature! FEATURE
113
+ Include the given feature in the current pre-release
154
114
 
155
- check
156
- Check that the current migration applied to the base version yields the
157
- same result as loading the current schema
115
+ check!
116
+ Check that the current migration applied to the base version yields the
117
+ same result as loading the current schema
158
118
 
159
- CREATING RELEASES
160
- create release [RELEASE]
161
- Prepare a release and create release directory and migration file
162
- before tagging and branching to a release branch. The RELEASE argument
163
- can be left out if the current branch is a prerelease branch
119
+ create.release! [RELEASE]
120
+ Prepare a release and create release directory and migration file before
121
+ tagging and branching to a release branch. The RELEASE argument can be
122
+ left out if the current branch is a prerelease branch
164
123
 
165
- create prerelease RELEASE
166
- Prepare a release and create release directory and migration file
167
- before branching to a prerelease branch
168
-
169
- create feature NAME
170
- Prepare a feature before branching to a feature branch
124
+ create.prerelease! RELEASE
125
+ Prepare a release and create release directory and migration file before
126
+ branching to a prerelease branch
171
127
 
172
- cancel release RELEASE
173
- Cancel a release. Since tags are immutable, the release is cancelled by
174
- added a special cancel-tag to the release that makes prick ignore it
128
+ create.feature! NAME
129
+ Prepare a feature before branching to a feature branch
175
130
 
176
- DEPLOYING RELEASES
177
- generate migration
178
- generate schema
179
- Create a PostgreSQL script to migrate or create the database
131
+ cancel!
132
+ Cancel a release. Just a shorthand for 'prick cancel release'
133
+
134
+ cancel.release!
135
+ Cancel a release. Since tags are immutable, the release is cancelled by
136
+ added a special cancel-tag to the release that makes prick ignore it
180
137
 
181
- upgrade
182
- Migrate the database to match the current schema
138
+ generate.migration!
139
+ Create a script to migrate the database
183
140
 
184
- backup [FILE]
185
- Saves a backup of the database to the given file or to the var/spool
186
- directory
141
+ generate.schema!
142
+ Create a script to create the database
187
143
 
188
- restore [FILE]
189
- Restore the database from the given backup file or from the latest
190
- backup in the var/spool directory
144
+ upgrade!
145
+ Migrate the database to match the current schema
146
+
147
+ backup! [FILE]
148
+ Saves a backup of the database to the given file or to the var/spool
149
+ directory
150
+
151
+ restore! [FILE]
152
+ Restore the database from the given backup file or from the latest backup
153
+ in the var/spool directory
191
154
  )
192
155
 
193
156
 
194
- opts, args = ShellOpts.as_struct(SPEC, ARGV)
157
+
158
+ opts, args = ShellOpts.process(SPEC, ARGV)
195
159
 
196
160
  # Handle --help
197
- if opts.help?
198
- begin
199
- file = Tempfile.new("prick")
200
- file.puts HELP.split("\n").map { |l| l.sub(/^ /, "") }
201
- file.flush
202
- system "less #{file.path}"
203
- ensure
204
- file.close
205
- end
206
- exit
161
+ if opts.help?
162
+ ShellOpts.help
163
+ exit
207
164
  end
208
165
 
209
166
  # Handle --version
@@ -214,7 +171,7 @@ end
214
171
 
215
172
  begin
216
173
  # Honor -C option
217
- if opts.directory
174
+ if opts.directory?
218
175
  if File.exist?(opts.directory)
219
176
  begin
220
177
  Dir.chdir(opts.directory)
@@ -232,8 +189,8 @@ begin
232
189
  # Handle init command
233
190
  if opts.subcommand == :init
234
191
  directory = args.expect(0..1)
235
- name = opts.name || directory || File.basename(Dir.getwd)
236
- user = opts.init.user || name
192
+ name = opts.name || (directory && File.basename(directory)) || File.basename(Dir.getwd)
193
+ user = opts.init!.user || name
237
194
  program.init(name, user, directory || ".")
238
195
  exit 0
239
196
  end
@@ -247,40 +204,59 @@ begin
247
204
  # TODO: Check for dirty detached head
248
205
 
249
206
  # Expect a sub-command
250
- opts.subcommand? or raise Prick::Error, "Subcomand expected"
207
+ opts.subcommand or raise Prick::Error, "Subcomand expected"
251
208
 
252
209
  case opts.subcommand
253
210
  when :info
254
211
  args.expect(0)
255
212
  program.info
256
213
 
214
+ when :list
215
+ command = opts.list!
216
+ case command.subcommand
217
+ when :releases;
218
+ obj = command.releases!
219
+ program.list_releases(migrations: obj.migrations?, cancelled: obj.cancelled?)
220
+ when :migrations; program.list_migrations
221
+ when :upgrades; program.list_upgrades(*args.expect(0..2).compact)
222
+ when :cache;
223
+ args.expect(0)
224
+ program.list_cache
225
+ when NilClass; raise Prick::Error, "list requires a releases|migrations|upgrades sub-command"
226
+ else
227
+ raise Prick::Internal, "Subcommand #{opts.subcommand}.#{command.subcommand} is not matched"
228
+ end
229
+
257
230
  when :build
258
231
  version = args.expect(0..1)
259
- program.build(opts.build.database, version, opts.build.nocache)
232
+ program.build(opts.build!.database, version, opts.build!.no_cache?)
260
233
 
261
234
  when :make
262
- command = opts.make
235
+ command = opts.make!
263
236
  case command.subcommand
264
237
  when :clean
265
238
  args.expect(0)
266
- program.make_clean(command.clean.all)
239
+ program.make_clean(command.clean!.all?)
267
240
  else
268
241
  version = args.expect(0..1)
269
- program.make(opts.make.database, version, opts.make.nocache)
242
+ program.make(opts.make!.database, version, opts.make!.no_cache?)
270
243
  end
271
244
 
272
245
  when :load
273
246
  version_or_file = args.expect(1)
274
- program.load(opts.load.database, version_or_file)
247
+ program.load(opts.load!.database, version_or_file)
275
248
 
276
249
  when :save
277
250
  version, file = args.expect(1..2)
278
251
  program.save(version, file)
279
252
 
253
+ when :drop
254
+ program.drop(args.expect(0..1), opts.drop!.all)
255
+
280
256
  when :diff
281
- mark = opts.diff.mark
282
- tables = opts.diff.tables
283
- no_tables = opts.diff.notables
257
+ mark = opts.diff!.mark
258
+ tables = opts.diff!.tables
259
+ no_tables = opts.diff!.notables
284
260
  tables.nil? && no_tables.nil? || tables ^ no_tables or
285
261
  raise Error, "--tables and --no-tables options are exclusive"
286
262
  select = tables ? :tables : (no_tables ? :no_tables : :all)
@@ -290,31 +266,12 @@ begin
290
266
  when :migrate
291
267
  raise NotYet
292
268
 
293
- when :drop
294
- program.drop(args.expect(0..1), opts.drop.all)
295
-
296
- when :list
297
- command = opts.list
298
- case command.subcommand
299
- when :releases;
300
- obj = command.releases
301
- program.list_releases(migrations: obj.migrations?, cancelled: obj.cancelled?)
302
- when :migrations; program.list_migrations
303
- when :upgrades; program.list_upgrades(*args.expect(0..2).compact)
304
- when :cache;
305
- args.expect(0)
306
- program.list_cache
307
- when NilClass; raise Prick::Error, "list requires a releases|migrations|upgrades sub-command"
308
- else
309
- raise Prick::Internal, "Subcommand #{opts.subcommand}.#{command.subcommand} is not matched"
310
- end
311
-
312
269
  when :prepare
313
- cmd = opts.prepare.subcommand || :release
270
+ cmd = opts.prepare!.subcommand || :release
314
271
  case cmd
315
272
  when :release; program.prepare_release(args.expect(0..1))
316
- when :feature; raise NotYet
317
- when :migration; program.prepare_migration(args.expect(1))
273
+ when :feature; program.prepare_feature(args.expect(1))
274
+ when :migration; program.prepare_migration(args.expect(0..1))
318
275
  when :schema; program.prepare_schema(args.expect(1))
319
276
  when :diff; program.prepare_diff(args.expect(0..1))
320
277
  else
@@ -322,7 +279,7 @@ begin
322
279
  end
323
280
 
324
281
  when :include
325
- cmd = opts.include.subcommand || :feature
282
+ cmd = opts.include!.subcommand || :feature
326
283
  case cmd
327
284
  when :feature; program.include_feature(args.expect(1))
328
285
  else
@@ -334,7 +291,7 @@ begin
334
291
  program.check
335
292
 
336
293
  when :create
337
- cmd = opts.create.subcommand || :release
294
+ cmd = opts.create!.subcommand || :release
338
295
  case cmd
339
296
  when :release; program.create_release(args.expect(0..1))
340
297
  when :prerelease; program.create_prerelease(args.expect(0..1))
@@ -344,20 +301,20 @@ begin
344
301
  end
345
302
 
346
303
  when :cancel
347
- cmd = opts.cancel.subcommand
304
+ cmd = opts.cancel!.subcommand
348
305
  case cmd
349
306
  when :release; program.cancel_release(args.expect(1))
350
- when nil; raise Prick::Error, "'cancel' subcommand require a release argument"
307
+ when nil; raise Prick::Error, "'cancel' subcommand requires a release argument"
351
308
  else
352
309
  raise Prick::Internal, "Subcommand #{opts.subcommand}.#{cmd} is not matched"
353
310
  end
354
311
 
355
312
  when :generate
356
- cmd = opts.generate.subcommand
313
+ cmd = opts.generate!.subcommand
357
314
  case cmd
358
315
  when :schema; program.generate_schema
359
316
  when :migration; program.generate_migration
360
- when nil; raise Prick::Error, "'genrate' subcommand require a 'schema' or 'migration' argument"
317
+ when nil; raise Prick::Error, "'generate' subcommand requires a 'schema' or 'migration' argument"
361
318
  else
362
319
  raise Prick::Internal, "Subcommand #{opts.subcommand}.#{cmd} is not matched"
363
320
  end
@@ -381,3 +338,56 @@ rescue Prick::Error => ex
381
338
  ShellOpts.error(ex.message)
382
339
  end
383
340
 
341
+ __END__
342
+
343
+ # Awaits support for sections in ShellOpts
344
+ HELP = %(
345
+ OPTIONS
346
+ -n, --name=NAME
347
+ -C, --directory=DIR
348
+ -h, --help
349
+ -v, --verbose
350
+ --version
351
+
352
+ COMMANDS
353
+ INITIALIZATION
354
+ init --user=USER [DIR]
355
+
356
+ INFO COMMANDS
357
+ info
358
+ list releases --migrations --cancelled
359
+ list migrations
360
+ list upgrades --all
361
+
362
+ BUILDING
363
+ build -d DATABASE -C --nocache [TAG]
364
+ make -d DATABASE -C --nocache [TAG]
365
+ make clean -a
366
+ load -d DATABASE VERSION|FILE
367
+ save VERSION [FILE]
368
+ drop --all [DATABASE]
369
+ diff [FROM-DATABASE|FROM-VERSION [TO-DATABASE|TO-VERSION]]
370
+ migrate
371
+
372
+ PREPARING RELEASES
373
+ prepare release [FORK]
374
+ prepare feature NAME
375
+ prepare migration FROM
376
+ prepare schema NAME
377
+ prepare diff [VERSION]
378
+ include feature FEATURE
379
+ check
380
+
381
+ CREATING RELEASES
382
+ create release [RELEASE]
383
+ create prerelease RELEASE
384
+ create feature NAME
385
+ cancel release RELEASE
386
+
387
+ DEPLOYING RELEASES
388
+ generate migration
389
+ generate schema
390
+ upgrade
391
+ backup [FILE]
392
+ restore [FILE]
393
+ )
data/lib/prick.rb CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ $LOAD_PATH.unshift("/home/clr/prj/shellopts/lib")
3
+
2
4
  # 'semantic' is required here instead of in prick/version.rb to avoid having Gem depend on it
3
5
  require "semantic"
4
6
 
@@ -25,7 +27,5 @@ require "prick/version.rb"
25
27
  require "ext/fileutils.rb"
26
28
  require "ext/shortest_path.rb"
27
29
 
28
- require "indented_io"
29
-
30
30
  module Prick
31
31
  end
data/lib/prick/program.rb CHANGED
@@ -25,7 +25,7 @@ module Prick
25
25
  def init(name, user, directory)
26
26
  !Project.exist?(directory) or raise Error, "Directory #{directory} is already initialized"
27
27
  Project.create(name, user, directory)
28
- if name != File.basename(directory)
28
+ if name != directory
29
29
  mesg "Initialized project #{name} in #{directory}"
30
30
  else
31
31
  mesg "Initialized project #{name}"
@@ -46,12 +46,23 @@ module Prick
46
46
  puts " Schema version : #{sv}" + (sv != bv ? " (mismatch)" : "")
47
47
  end
48
48
 
49
+ def list_releases(migrations: false, cancelled: false)
50
+ raise NotYet
51
+ end
52
+
53
+ def list_migrations
54
+ raise NotYet
55
+ end
56
+
57
+ def list_upgrades(from = nil, to = nil)
58
+ raise NotYet
59
+ end
60
+
49
61
  def list_cache
50
62
  project.cache.list.each { |l| puts l }
51
63
  end
52
64
 
53
65
  def build(database, version, nocache)
54
- check_owned(database) if database
55
66
  into_mesg = database && "into #{database}"
56
67
  version_mesg = version ? "v#{version}" : "current schema"
57
68
  version &&= Version.new(version)
@@ -63,7 +74,6 @@ module Prick
63
74
  end
64
75
 
65
76
  def make(database, version, nocache)
66
- check_owned(database) if database
67
77
  version &&= Version.new(version)
68
78
  version.nil? || Git.tag?(version) or raise Error, "Can't find tag v#{version}"
69
79
  if !nocache && version && project.cache.exist?(version)
@@ -74,7 +84,7 @@ module Prick
74
84
  end
75
85
 
76
86
  def make_clean(all)
77
- project.cache.clean.each { |file| puts "Removed cache file #{File.basename(file)}" }
87
+ project.cache.clean.each { |file| mesg "Removed cache file #{File.basename(file)}" }
78
88
  drop(nil, all)
79
89
  end
80
90
 
@@ -135,8 +145,24 @@ module Prick
135
145
  end
136
146
  end
137
147
 
148
+ def migrate
149
+ raise NotYet
150
+ end
151
+
138
152
  def prepare_release(fork)
139
153
  project.prepare_release(fork)
154
+ enda
155
+
156
+ def prepare_feature(name)
157
+ raise NotYet
158
+ end
159
+
160
+ def prepare_migration(from = nil)
161
+ raise NotYet
162
+ end
163
+
164
+ def prepare_schema(name)
165
+ raise NotYet
140
166
  end
141
167
 
142
168
  def prepare_diff(version = nil)
@@ -153,6 +179,20 @@ module Prick
153
179
  end
154
180
  end
155
181
 
182
+ def include(name)
183
+ raise NotYet
184
+ end
185
+
186
+ def check
187
+ version ||=
188
+ if project.prerelease? || project.migration?
189
+ project.branch.base_version
190
+ else
191
+ project.branch.version
192
+ end
193
+ project.check_migration(version)
194
+ end
195
+
156
196
  def create_release(version = nil)
157
197
  if project.prerelease_branch?
158
198
  raise NotYet
@@ -164,6 +204,18 @@ module Prick
164
204
  mesg "Created release v#{project.head.version}"
165
205
  end
166
206
 
207
+ def create_prerelease(version = nil)
208
+ raise NotYet
209
+ end
210
+
211
+ def create_feature(name)
212
+ raise NotYet
213
+ end
214
+
215
+ def cancel(version)
216
+ raise NotYet
217
+ end
218
+
167
219
  def generate_schema
168
220
  project.generate_schema
169
221
  end
@@ -172,6 +224,10 @@ module Prick
172
224
  project.generate_migration
173
225
  end
174
226
 
227
+ def upgrade
228
+ raise NotYet
229
+ end
230
+
175
231
  # TODO: Create a Backup class and a Project#backup_store object
176
232
  def backup(file = nil)
177
233
  file = file || File.join(SPOOL_DIR, "#{project.name}-#{Time.now.utc.strftime("%Y%m%d-%H%M%S")}.sql.gz")
data/lib/prick/project.rb CHANGED
@@ -98,8 +98,6 @@ module Prick
98
98
  Project.new(state.name, state.user, branch)
99
99
  end
100
100
 
101
- # def checkout(branch_or_tag) end
102
-
103
101
  def build(database = self.database, version: nil)
104
102
  database.clean
105
103
  if version
@@ -118,17 +116,6 @@ module Prick
118
116
  self
119
117
  end
120
118
 
121
- # def make(database = self.database, version: nil)
122
- # database.clean
123
- # if cache.exist?(version)
124
- # load(database, version: version)
125
- # else
126
- # build(database, version: version)
127
- # cache.save(database, version) if version
128
- # end
129
- # self
130
- # end
131
-
132
119
  def load(database = self.database, version: nil, file: nil)
133
120
  version.nil? ^ file.nil? or raise Internal, "Need exactly one of :file and :version to be defined"
134
121
  database.clean
data/lib/prick/rdbms.rb CHANGED
@@ -9,14 +9,15 @@ module Prick
9
9
 
10
10
  ### EXECUTE SQL
11
11
 
12
- # Execute the SQL statement and return stdout as an array of tuples. FIXME:
13
- # SQL can't contain '"'
12
+ # Execute the SQL statement and return stdout as an array of tuples
14
13
  def self.exec_sql(db, sql, user: ENV['USER'])
15
14
  stdout = Command.command %(
16
15
  {
17
16
  echo "set role #{user};"
18
17
  echo "set search_path to public;"
19
- echo "#{sql}"
18
+ cat <<'EOF'
19
+ #{sql}
20
+ EOF
20
21
  } | psql --csv --tuples-only --quiet -v ON_ERROR_STOP=1 -d #{db}
21
22
  )
22
23
  CSV.new(stdout.join("\n")).read
data/lib/prick/version.rb CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # Required by gem
6
6
  module Prick
7
- VERSION = "0.5.0"
7
+ VERSION = "0.6.0"
8
8
  end
9
9
 
10
10
  # Project related code starts here
data/prick.gemspec CHANGED
@@ -1,4 +1,6 @@
1
1
 
2
+ #$LOAD_PATH.unshift("/home/clr/prj/shellopts/lib")
3
+
2
4
  #lib = File.expand_path("../lib", __FILE__)
3
5
  #$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
6
  #require "prick/version"
@@ -29,7 +31,7 @@ Gem::Specification.new do |spec|
29
31
  spec.require_paths = ["lib"]
30
32
 
31
33
  # spec.add_dependency "pg"
32
- spec.add_dependency "shellopts", "2.0.0.pre.11"
34
+ spec.add_dependency "shellopts", "2.0.0.pre.14"
33
35
  spec.add_dependency "semantic"
34
36
  spec.add_dependency "indented_io"
35
37
  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.5.0
4
+ version: 0.6.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-01-27 00:00:00.000000000 Z
11
+ date: 2021-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shellopts
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0.pre.11
19
+ version: 2.0.0.pre.14
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.0.pre.11
26
+ version: 2.0.0.pre.14
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: semantic
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
158
  requirements: []
159
- rubygems_version: 3.1.2
159
+ rubygems_version: 3.1.4
160
160
  signing_key:
161
161
  specification_version: 4
162
162
  summary: A release control and management system for postgresql