ki-repo 0.1.1 → 0.1.2

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.
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- # Copyright 2012 Mikko Apo
3
+ # Copyright 2012-2013 Mikko Apo
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@ module Ki
20
20
  class UserPrefFile < KiJSONHashFile
21
21
  attr_chain :uses, -> { Array.new }, :accessor => CachedData
22
22
  attr_chain :prefixes, -> { Array.new }, :accessor => CachedData
23
+ attr_chain :requires, -> { Array.new }, :accessor => CachedData
23
24
 
24
25
  def initialize
25
26
  super("ki-user-pref.json")
@@ -31,42 +32,6 @@ module Ki
31
32
  class UserPrefCommand
32
33
  attr_chain :shell_command
33
34
 
34
- def help
35
- <<EOF
36
- #{summary}
37
- Syntax: #{shell_command} prefix|use parameters...
38
-
39
- ### Examples for command prefixes:
40
- #{shell_command} prefix
41
- - shows command prefixes, when a "ki command" is executed ki looks for the command with all prefix combinations
42
- #{shell_command} prefix version package
43
- - sets two command prefixes, looks for "command", "version-command" and "package-command"
44
- #{shell_command} prefix + foo
45
- - adds one command prefix to existing ones, looks for "command", "version-command", "package-command", "foo-command"
46
- #{shell_command} prefix - package foo
47
- - removes two command prefixes from list
48
- #{shell_command} prefix -c
49
- - clears command prefix list
50
-
51
- ### Examples for automatic script loading:
52
- #{shell_command} use
53
- - shows list of automatically loading scripts. when ki starts up, it looks for all defined versions and loads all files tagged with ki-cmd
54
- #{shell_command} use ki/http ki/ftp/123:ki-extra
55
- - scripts are loaded from two different version. ki/http uses latest available version and files tagged with "ki-cmd", ki/ftp uses specific version and files tagged with "ki-extra"
56
- #{shell_command} use + ki/scp
57
- - adds one more script package version
58
- #{shell_command} use - ki/scp ki/ftp/123:ki-extra
59
- - removes two configurations
60
- #{shell_command} use -c
61
- - clear use list
62
-
63
- EOF
64
- end
65
-
66
- def summary
67
- "Sets user preferences"
68
- end
69
-
70
35
  def execute(ctx, args)
71
36
  user_pref = ctx.user_pref
72
37
  pref = args.delete_at(0)
@@ -76,6 +41,9 @@ EOF
76
41
  elsif pref == "use"
77
42
  arr = user_pref.uses
78
43
  str = "Use"
44
+ elsif pref == "require"
45
+ arr = user_pref.requires
46
+ str = "Require"
79
47
  elsif pref.nil?
80
48
  puts "User preferences:"
81
49
  user_pref.cached_data.each_pair do |key, values|
@@ -116,6 +84,48 @@ EOF
116
84
  end
117
85
  end
118
86
  end
87
+
88
+ def summary
89
+ "Sets user preferences"
90
+ end
91
+
92
+ def help
93
+ <<EOF
94
+ #{summary}
95
+ Syntax: #{shell_command} prefix|use parameters...
96
+
97
+ ### Examples for command prefixes:
98
+ #{shell_command} prefix
99
+ - shows command prefixes, when a "ki command" is executed ki looks for the command with all prefix combinations
100
+ #{shell_command} prefix version package
101
+ - sets two command prefixes, looks for "command", "version-command" and "package-command"
102
+ #{shell_command} prefix + foo
103
+ - adds one command prefix to existing ones, looks for "command", "version-command", "package-command", "foo-command"
104
+ #{shell_command} prefix - package foo
105
+ - removes two command prefixes from list
106
+ #{shell_command} prefix -c
107
+ - clears command prefix list
108
+
109
+ ### Examples for default script loading:
110
+ #{shell_command} use
111
+ - shows list of automatically loading scripts. when ki starts up, it looks for all defined versions and loads all files tagged with "ki"
112
+ #{shell_command} use ki/http ki/ftp/123:ki-extra
113
+ - scripts are loaded from two different version. ki/http uses latest available version and files tagged with "ki", ki/ftp uses specific version and files tagged with "ki-extra"
114
+ #{shell_command} use + ki/scp
115
+ - adds one more script package version
116
+ #{shell_command} use - ki/scp ki/ftp/123:ki-extra
117
+ - removes two configurations
118
+ #{shell_command} use -c
119
+ - clear use list
120
+
121
+ ### Examples for default Ruby file requiring:
122
+ #{shell_command} require
123
+ #{shell_command} require hooves/default
124
+ #{shell_command} require + hooves/default
125
+ #{shell_command} require - hooves/default
126
+ #{shell_command} require -c
127
+ EOF
128
+ end
119
129
  end
120
130
 
121
131
  KiCommand.register_cmd("pref", UserPrefCommand)
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- # Copyright 2012 Mikko Apo
3
+ # Copyright 2012-2013 Mikko Apo
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -37,34 +37,6 @@ module Ki
37
37
  metadata_file.save
38
38
  end
39
39
 
40
- def help
41
- <<EOF
42
- "#{shell_command}" can be used to generate version metadata files. Version metadata files
43
- contain information about files (size, permission bits, hash checksums), version origins
44
- and dependencies.
45
-
46
- After version metadata file is ready, it can be imported to repository using version-import.
47
-
48
- ### Usage
49
-
50
- #{shell_command} <parameters> file_pattern1*.* file_pattern2*.*
51
-
52
- ### Examples
53
-
54
- #{shell_command} test.sh
55
- #{shell_command} readme* -t doc
56
- #{shell_command} -d my/component/1,name=comp,path=doc,internal -O "mv doc/test.sh helloworld.sh"
57
- ki version-import
58
-
59
- ### Parameters
60
- #{opts}
61
- EOF
62
- end
63
-
64
- def summary
65
- "Create version metadata file"
66
- end
67
-
68
40
  def opts
69
41
  OptionParser.new do |opts|
70
42
  opts.banner = ""
@@ -104,6 +76,34 @@ EOF
104
76
  end
105
77
  end
106
78
  end
79
+
80
+ def summary
81
+ "Create version metadata file"
82
+ end
83
+
84
+ def help
85
+ <<EOF
86
+ "#{shell_command}" can be used to generate version metadata files. Version metadata files
87
+ contain information about files (size, permission bits, hash checksums), version origins
88
+ and dependencies.
89
+
90
+ After version metadata file is ready, it can be imported to repository using version-import.
91
+
92
+ ### Usage
93
+
94
+ #{shell_command} <parameters> file_pattern1*.* file_pattern2*.*
95
+
96
+ ### Examples
97
+
98
+ #{shell_command} test.sh
99
+ #{shell_command} readme* -t doc
100
+ #{shell_command} -d my/component/1,name=comp,path=doc,internal -O "mv doc/test.sh helloworld.sh"
101
+ ki version-import
102
+
103
+ ### Parameters
104
+ #{opts}
105
+ EOF
106
+ end
107
107
  end
108
108
 
109
109
  # Tests version from repository or metadata file
@@ -132,24 +132,6 @@ EOF
132
132
  end
133
133
  end
134
134
 
135
- def help
136
- <<EOF
137
- "#{shell_command}" tests versions, their files and their dependencies. Can also test version that has not been imported yet.
138
-
139
- ### Examples
140
-
141
- #{shell_command} -r my/product other/product
142
- #{shell_command} -f ki-version.json -i file-directory
143
-
144
- ### Parameters
145
- #{opts}
146
- EOF
147
- end
148
-
149
- def summary
150
- "Tests versions and their dependencies"
151
- end
152
-
153
135
  def opts
154
136
  OptionParser.new do |opts|
155
137
  opts.banner = ""
@@ -168,42 +150,38 @@ EOF
168
150
  end
169
151
  end
170
152
  end
171
- end
172
-
173
- # Imports version and its files to repository
174
- # @see VersionImporter
175
- class ImportVersion
176
- attr_chain :input_dir, -> { Dir.pwd }
177
- attr_chain :file, -> { File.join(input_dir, "ki-version.json") }
178
- attr_chain :importer, -> {}
179
- attr_chain :shell_command, :require
180
153
 
181
- def execute(ctx, args)
182
- @importer = VersionImporter.new
183
- opts.parse(args)
184
- @importer.ki_home(ctx.ki_home).import(file, input_dir)
154
+ def summary
155
+ "Tests versions and their dependencies"
185
156
  end
186
157
 
187
158
  def help
188
159
  <<EOF
189
- "#{shell_command}" imports version and its files to repository.
190
-
191
- Version name can be defined either during "version-build",
192
- or generated automatically for component at import (with -c my/component) or defined to be a specific version (-v).
193
- Can also move files (-m), test dependencies before import (-t).
160
+ "#{shell_command}" tests versions, their files and their dependencies. Can also test version that has not been imported yet.
194
161
 
195
162
  ### Examples
196
163
 
197
- #{shell_command} -m -t -c my/product
164
+ #{shell_command} -r my/product other/product
198
165
  #{shell_command} -f ki-version.json -i file-directory
199
166
 
200
167
  ### Parameters
201
168
  #{opts}
202
169
  EOF
203
170
  end
171
+ end
204
172
 
205
- def summary
206
- "Imports version metadata and files to repository"
173
+ # Imports version and its files to repository
174
+ # @see VersionImporter
175
+ class ImportVersion
176
+ attr_chain :input_dir, -> { Dir.pwd }
177
+ attr_chain :file, -> { File.join(input_dir, "ki-version.json") }
178
+ attr_chain :importer, -> {}
179
+ attr_chain :shell_command, :require
180
+
181
+ def execute(ctx, args)
182
+ @importer = VersionImporter.new
183
+ opts.parse(args)
184
+ @importer.ki_home(ctx.ki_home).import(file, input_dir)
207
185
  end
208
186
 
209
187
  def opts
@@ -232,42 +210,42 @@ EOF
232
210
  end
233
211
  end
234
212
  end
235
- end
236
213
 
237
- # Exports version from repository to target directory
238
- # @see VersionExporter
239
- class ExportVersion
240
- attr_chain :out, -> { Dir.pwd }
241
- attr_chain :shell_command, :require
242
-
243
- def execute(ctx, args)
244
- @exporter = VersionExporter.new
245
- file_patterns = opts.parse(args)
246
- version = file_patterns.delete_at(0)
247
- @exporter.find_files.files(file_patterns)
248
- @exporter.ki_home(ctx.ki_home).export(version, out)
214
+ def summary
215
+ "Imports version metadata and files to repository"
249
216
  end
250
217
 
251
218
  def help
252
219
  <<EOF
253
- "#{shell_command}" exports version and its dependencies to target directory.
254
-
255
- ### Usage
220
+ "#{shell_command}" imports version and its files to repository.
256
221
 
257
- #{shell_command} <parameters> <file_export_pattern*.*>
222
+ Version name can be defined either during "version-build",
223
+ or generated automatically for component at import (with -c my/component) or defined to be a specific version (-v).
224
+ Can also move files (-m), test dependencies before import (-t).
258
225
 
259
226
  ### Examples
260
227
 
261
- #{shell_command} -o export-dir --tags -c bin my/product
262
- #{shell_command} -o scripts -c -t my/admin-tools '*.sh'
228
+ #{shell_command} -m -t -c my/product
229
+ #{shell_command} -f ki-version.json -i file-directory
263
230
 
264
231
  ### Parameters
265
232
  #{opts}
266
233
  EOF
267
234
  end
235
+ end
268
236
 
269
- def summary
270
- "Export version to a directory"
237
+ # Exports version from repository to target directory
238
+ # @see VersionExporter
239
+ class ExportVersion
240
+ attr_chain :out, -> { Dir.pwd }
241
+ attr_chain :shell_command, :require
242
+
243
+ def execute(ctx, args)
244
+ @exporter = VersionExporter.new
245
+ file_patterns = opts.parse(args)
246
+ version = file_patterns.delete_at(0)
247
+ @exporter.find_files.files(file_patterns)
248
+ @exporter.ki_home(ctx.ki_home).export(version, out)
271
249
  end
272
250
 
273
251
  def opts
@@ -287,6 +265,28 @@ EOF
287
265
  end
288
266
  end
289
267
  end
268
+
269
+ def summary
270
+ "Export version to a directory"
271
+ end
272
+
273
+ def help
274
+ <<EOF
275
+ "#{shell_command}" exports version and its dependencies to target directory.
276
+
277
+ ### Usage
278
+
279
+ #{shell_command} <parameters> <file_export_pattern*.*>
280
+
281
+ ### Examples
282
+
283
+ #{shell_command} -o export-dir --tags -c bin my/product
284
+ #{shell_command} -o scripts -c -t my/admin-tools '*.sh'
285
+
286
+ ### Parameters
287
+ #{opts}
288
+ EOF
289
+ end
290
290
  end
291
291
 
292
292
  # Sets status for version
@@ -314,6 +314,10 @@ EOF
314
314
  end
315
315
  end
316
316
 
317
+ def summary
318
+ "Add status values to version"
319
+ end
320
+
317
321
  def help
318
322
  <<EOF
319
323
  "#{shell_command}" sets status values to versions and sets status value order to component.
@@ -328,10 +332,6 @@ Status value order is used to determine which statuses match version queries:
328
332
  #{shell_command} order my/component maturity alpha,beta,gamma
329
333
  EOF
330
334
  end
331
-
332
- def summary
333
- "Add status values to version"
334
- end
335
335
  end
336
336
 
337
337
  # Shows information about a version
@@ -389,22 +389,7 @@ EOF
389
389
  end
390
390
 
391
391
  def map_to_csl(map)
392
- map.sort.map { |k, v| "#{k}=#{Array.wrap(v).join(",")}" }.join(", ")
393
- end
394
-
395
- def help
396
- <<EOF
397
- "#{shell_command}" prints information about version or versions and their dependencies
398
-
399
- ### Examples
400
-
401
- #{shell_command} -r -d my/component/23 my/product/127
402
- #{shell_command} -f ki-version.json -i binary-dir
403
- EOF
404
- end
405
-
406
- def summary
407
- "Prints information about version or versions"
392
+ map.sort.map { |k, v| "#{k}=#{Array(v).join(",")}" }.join(", ")
408
393
  end
409
394
 
410
395
  def opts
@@ -428,6 +413,24 @@ EOF
428
413
  end
429
414
  end
430
415
  end
416
+
417
+ def summary
418
+ "Prints information about version or versions"
419
+ end
420
+
421
+ def help
422
+ <<EOF
423
+ "#{shell_command}" prints information about version or versions and their dependencies
424
+
425
+ ### Examples
426
+
427
+ #{shell_command} -r -d my/component/23 my/product/127
428
+ #{shell_command} -f ki-version.json -i binary-dir
429
+
430
+ ### Parameters
431
+ #{opts}
432
+ EOF
433
+ end
431
434
  end
432
435
 
433
436
  # Sets status for version
@@ -453,6 +456,10 @@ EOF
453
456
  end
454
457
  end
455
458
 
459
+ def summary
460
+ "Searches for versions and components"
461
+ end
462
+
456
463
  def help
457
464
  <<EOF
458
465
  "#{shell_command}" searches for versions and components.
@@ -463,10 +470,6 @@ EOF
463
470
  #{shell_command} my/*
464
471
  EOF
465
472
  end
466
-
467
- def summary
468
- "Searches for versions and components"
469
- end
470
473
  end
471
474
 
472
475
  KiCommand.register_cmd("version-build", BuildVersionMetadataFile)