git-cipher 0.3 → 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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/git-cipher +46 -1
  3. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fafc4d52d9e64f31c6224872f4357038dbde9902
4
- data.tar.gz: 95f89526e90879fd8cb111a5489f6d458a3d9609
3
+ metadata.gz: 4c0501f05ef3eb618fc318e776e838a0919727fb
4
+ data.tar.gz: 2af67cbad13cae60e002fb333c8e9e863cdcf7b1
5
5
  SHA512:
6
- metadata.gz: 433b3749ae3175d9c4927a83bdd321fbe72b5cc0cc8d462d77ba0bb37a2b9cfdc8ce0652f37e64309c0b6f78a000e4a92217e39b93332eba68d153d7c8dec9f4
7
- data.tar.gz: 2c8157fab0532f359d2acaf2ebed1eae6e9719467ec6c5e37e5f2b8344c7ff479c263d28146db0daae67df6093eb3f83bf7f50b5764647f9dd633b4939323254
6
+ metadata.gz: 05b0f6b6fcb1fabac7fb6250d84a90ee06a7382bf9f03830d9a769666075819d291b0bd0deb3706f71a3481797002e7f163f343111caa103a003516f7f05e98c
7
+ data.tar.gz: 1be1b9e1ae34640beab077d9f1a12fc7ed14a6c391ee94683ccf166f53fc02c3e8720c8f7a52a0b6096792e670a79f1b4419d5b97789ea4a6336aa2f9cf67e01
@@ -10,8 +10,12 @@ class Cipher
10
10
  EXTENSION = 'encrypted'
11
11
  DEFAULT_GPG_USER = 'greg@hurrell.net'
12
12
  EXECUTABLE_EXTENSIONS = %w[.js .sh]
13
+ STATUS = {
14
+ 'MISSING' => 0b01,
15
+ 'MODIFIED' => 0b10,
16
+ }
13
17
  VALID_OPTIONS = %w[force help]
14
- VALID_SUBCOMMANDS = %w[decrypt encrypt help log ls]
18
+ VALID_SUBCOMMANDS = %w[decrypt encrypt help log ls status]
15
19
 
16
20
  def run
17
21
  send @subcommand
@@ -286,6 +290,31 @@ private
286
290
  matching.each { |file| puts file }
287
291
  end
288
292
 
293
+ def status
294
+ exitstatus = 0
295
+ matching.each do |file|
296
+ pathname = Pathname.new(file)
297
+ basename = pathname.basename.to_s
298
+ outfile = pathname.dirname + basename.gsub(
299
+ /\A\.|\.#{EXTENSION}\z/, ''
300
+ )
301
+ if outfile.exist?
302
+ if FileUtils.uptodate?(outfile, [file])
303
+ # Plain-text is newer than ciphertext.
304
+ description = yellow('[MODIFIED]')
305
+ exitstatus |= STATUS['MODIFIED']
306
+ else
307
+ description = green('[OK]')
308
+ end
309
+ else
310
+ description = red('[MISSING]')
311
+ exitstatus |= STATUS['MISSING']
312
+ end
313
+ puts "#{file}: #{description}"
314
+ end
315
+ exit exitstatus
316
+ end
317
+
289
318
  def matching
290
319
  Dir.glob("**/*.#{EXTENSION}", File::FNM_DOTMATCH)
291
320
  end
@@ -419,6 +448,17 @@ private
419
448
  Lists the encrypted files in the current directory and
420
449
  its subdirectories.
421
450
  USAGE
451
+ when 'status'
452
+ puts strip_heredoc(<<-USAGE)
453
+ #{command_name} status
454
+
455
+ Shows the status of encrypted files in the current directory and
456
+ its subdirectories.
457
+
458
+ Exits with status #{STATUS['MISSING']} if any decrypted file is missing.
459
+ Exits with status #{STATUS['MODIFIED']} if any decrypted file is modified.
460
+ Exits with status #{STATUS['MISSING'] | STATUS['MODIFIED']} if both of the above apply.
461
+ USAGE
422
462
  else
423
463
  puts strip_heredoc(<<-USAGE)
424
464
  Available commands (invoke any with -h or --help for more info):
@@ -427,11 +467,16 @@ private
427
467
  #{command_name} encrypt
428
468
  #{command_name} log
429
469
  #{command_name} ls
470
+ #{command_name} status
430
471
  USAGE
431
472
  end
432
473
 
433
474
  exit
434
475
  end
476
+
477
+ def yellow(string)
478
+ colorize(string, 33)
479
+ end
435
480
  end
436
481
 
437
482
  Cipher.new.run
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-cipher
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '1.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Hurrell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-24 00:00:00.000000000 Z
11
+ date: 2019-01-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: "\n Provides a convenient workflow for working with encrypted files
14
14
  in a public\n Git repo. Delegates the underlying work of encryption/decryption
@@ -31,19 +31,19 @@ require_paths:
31
31
  - lib
32
32
  required_ruby_version: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - '>='
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
36
  version: '0'
37
37
  required_rubygems_version: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  requirements:
43
43
  - Git
44
44
  - GnuPG
45
45
  rubyforge_project:
46
- rubygems_version: 2.0.14.1
46
+ rubygems_version: 2.5.2.3
47
47
  signing_key:
48
48
  specification_version: 4
49
49
  summary: Manages encrypted content in a Git repo