tdp 1.0.0 → 1.1.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 +4 -4
- data/bin/tdp +1 -0
- data/lib/tdp.rb +67 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96b14653bafc10f1e10e657b36f10a6eb7fa45b8
|
4
|
+
data.tar.gz: ad48ba0992c7d63812b587f2457bb057b0beb53a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccf342a74157a9c1f4f0f7a902426e9bf82846b5c17372c03eb345a9023dd11038bcad63801533da4f4f4c9b23976c60f163f35bce0ceb4a999232104b03031e
|
7
|
+
data.tar.gz: 57f51d3e7b19032e2c6140ba95f733134728cb3e85cebb15f0afab409d2f83e726d06ccaa585921096a152d0dfb6444e0b8062ea57419aee414db13e48e52620
|
data/bin/tdp
CHANGED
data/lib/tdp.rb
CHANGED
@@ -64,6 +64,7 @@ module TDP
|
|
64
64
|
|
65
65
|
##
|
66
66
|
# patches :: an array of problematic patches (Patch objects)
|
67
|
+
#
|
67
68
|
def initialize(patches)
|
68
69
|
super('Patches with same name and different content: ' +
|
69
70
|
patches.map(&:full_filename).join(' / ')
|
@@ -72,6 +73,25 @@ module TDP
|
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
76
|
+
##
|
77
|
+
# Raised when there are multiple patches with different names and
|
78
|
+
# the same content signature.
|
79
|
+
#
|
80
|
+
class DuplicateError < RuntimeError
|
81
|
+
# Contradicting patch names
|
82
|
+
attr_reader :patch_names
|
83
|
+
|
84
|
+
##
|
85
|
+
# patch_names :: an array of names of problematic patches
|
86
|
+
#
|
87
|
+
def initialize(patch_names)
|
88
|
+
super('Patches with same content signature and different names: ' +
|
89
|
+
patch_names.join(' / ')
|
90
|
+
)
|
91
|
+
@patch_names = patch_names.freeze
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
75
95
|
##
|
76
96
|
# A single patch.
|
77
97
|
#
|
@@ -230,6 +250,19 @@ module TDP
|
|
230
250
|
result
|
231
251
|
end
|
232
252
|
|
253
|
+
##
|
254
|
+
# Fetches the information about applied patches and
|
255
|
+
# returns it as { signature => name } hash.
|
256
|
+
#
|
257
|
+
def applied_patches_inverse
|
258
|
+
result = {}
|
259
|
+
applied_patches.each do |name, sig|
|
260
|
+
raise DuplicateError, [result[sig], name] if result.key?(sig)
|
261
|
+
result[sig] = name
|
262
|
+
end
|
263
|
+
result
|
264
|
+
end
|
265
|
+
|
233
266
|
##
|
234
267
|
# Looks up a signature of a patch by its name.
|
235
268
|
#
|
@@ -270,6 +303,13 @@ module TDP
|
|
270
303
|
def erase
|
271
304
|
@db[:tdp_patch].delete
|
272
305
|
end
|
306
|
+
|
307
|
+
##
|
308
|
+
# Renames a patch.
|
309
|
+
#
|
310
|
+
def rename(old_name, new_name)
|
311
|
+
@db[:tdp_patch].where(name: old_name).update(name: new_name)
|
312
|
+
end
|
273
313
|
end
|
274
314
|
|
275
315
|
##
|
@@ -321,14 +361,30 @@ module TDP
|
|
321
361
|
# ones of the patches applied to the database.
|
322
362
|
#
|
323
363
|
def plan
|
364
|
+
ref = @dao.applied_patches
|
324
365
|
@patches.select do |patch|
|
325
|
-
signature =
|
366
|
+
signature = ref[patch.name]
|
326
367
|
next false if signature == patch.signature
|
327
368
|
next true if signature.nil? || patch.volatile?
|
328
369
|
raise MismatchError, patch
|
329
370
|
end
|
330
371
|
end
|
331
372
|
|
373
|
+
##
|
374
|
+
# Produces an { old_name => new_name } hash for mass-renaming.
|
375
|
+
#
|
376
|
+
def plan_rename
|
377
|
+
ref = @dao.applied_patches_inverse
|
378
|
+
m = {}
|
379
|
+
@patches.each do |patch|
|
380
|
+
old_name = ref[patch.signature]
|
381
|
+
raise NotAppliedError, patch if old_name.nil?
|
382
|
+
raise DuplicateError, [patch.name, m[old_name]] if m.key?(old_name)
|
383
|
+
m[old_name] = patch.name
|
384
|
+
end
|
385
|
+
m.select { |old_name, new_name| old_name != new_name }
|
386
|
+
end
|
387
|
+
|
332
388
|
##
|
333
389
|
# Applies all changes that need to be applied.
|
334
390
|
#
|
@@ -382,6 +438,16 @@ module TDP
|
|
382
438
|
@dao.register(patch)
|
383
439
|
end
|
384
440
|
end
|
441
|
+
|
442
|
+
##
|
443
|
+
# Amends the data about applied patches after they were renamed
|
444
|
+
# (without content changes) in the configuration.
|
445
|
+
#
|
446
|
+
def rename
|
447
|
+
plan_rename.each do |old_name, new_name|
|
448
|
+
@dao.rename(old_name, new_name)
|
449
|
+
end
|
450
|
+
end
|
385
451
|
end
|
386
452
|
|
387
453
|
##
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Appel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|