rake_git_crypt 0.1.0.pre.1 → 0.1.0.pre.2

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: f3511deca635ea9983d386eec2c6dc03cf61c45739ef9c7ae3fbaabebc5740b5
4
- data.tar.gz: 18bc1e62cd8df91a3926c897c5988b3812436447a1e0d0d74bde443ad5aec54f
3
+ metadata.gz: 4ebf5b5840f7126aa22776be5637cb20756c128c7f5da74d6b8d1cea6897a677
4
+ data.tar.gz: 4bd0e38ea31eb8d2ecd2f38ee7673c97709f6dfec58ef630b370bda870261889
5
5
  SHA512:
6
- metadata.gz: 3cfcdf0f6c212588359345cbe11a605dbf319f77eecf8e919c409857d605a0c11973b8ce6d16216d0ec46f1904c0088731deb7791ca54c715e065b9ba9f28e1e
7
- data.tar.gz: 30664d8b232bc92a29d4791df84eb3ccf3e81b15b07cfc65b21982851e584c96ba8f644a55260fb46cee44d733e14e0cd2c1adf40998af9d2f3f4ffd91214e4a
6
+ metadata.gz: ff6d4a8cfa9df6f20daed3e22ae1cad73d2a8b9a16cb065aa271e9d13e9fd8201d16e90a12d90c1933756fc9477c673282c7039e0c92c409764de814a4864b9f
7
+ data.tar.gz: 195901c1744a6399303b846ff9b769b743d57dbc36211bec7d16777265d5dcf5c23e80849d64cca0391c3d67c92af5b08f7ec9328a00fd1b7fa248e3dc82c2c9
data/Gemfile.lock CHANGED
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake_git_crypt (0.1.0.pre.1)
4
+ rake_git_crypt (0.1.0.pre.2)
5
5
  colored2 (~> 3.1)
6
6
  rake_factory (~> 0.23)
7
7
  ruby_git_crypt (= 0.1.0.pre.2)
8
+ ruby_gpg2 (~> 0.6)
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rake_factory'
4
+ require 'ruby_git_crypt'
5
+ require 'ruby_gpg2'
6
+
7
+ module RakeGitCrypt
8
+ module Tasks
9
+ class AddGPGUser < RakeFactory::Task
10
+ default_name :add_gpg_user
11
+ default_description 'Add GPG user to git-crypt.'
12
+
13
+ parameter :key_name
14
+
15
+ parameter :gpg_user_id
16
+ parameter :gpg_user_key_path
17
+
18
+ action do
19
+ validate
20
+
21
+ if gpg_user_id
22
+ log_adding_by_id
23
+ add_gpg_user(gpg_user_id)
24
+ log_done
25
+ end
26
+
27
+ if gpg_user_key_path
28
+ log_adding_by_key_path
29
+ result = import_key
30
+ key_fingerprint = lookup_key_fingerprint(result)
31
+ add_gpg_user(key_fingerprint)
32
+ log_done
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def validate
39
+ return if gpg_user_id || gpg_user_key_path
40
+
41
+ raise RakeFactory::RequiredParameterUnset,
42
+ 'One of gpg_user_id or gpg_user_key_path must be provided ' \
43
+ 'but neither was.'
44
+ end
45
+
46
+ def import_key
47
+ RubyGPG2.import(
48
+ key_file_paths: [gpg_user_key_path],
49
+ with_status: true
50
+ )
51
+ end
52
+
53
+ def lookup_key_fingerprint(result)
54
+ result.status.filter_by_type(:import_ok)
55
+ .first_line.key_fingerprint
56
+ end
57
+
58
+ def add_gpg_user(gpg_user_id)
59
+ RubyGitCrypt.add_gpg_user(
60
+ key_name: key_name,
61
+ gpg_user_id: gpg_user_id
62
+ )
63
+ end
64
+
65
+ def log_adding_by_id
66
+ $stdout.puts(
67
+ "Adding GPG user with ID: '#{gpg_user_id}' to git-crypt..."
68
+ )
69
+ end
70
+
71
+ def log_adding_by_key_path
72
+ puts(
73
+ "Adding GPG user with key at: '#{gpg_user_key_path}' to git-crypt..."
74
+ )
75
+ end
76
+
77
+ def log_done
78
+ $stdout.puts('Done.')
79
+ end
80
+ end
81
+ end
82
+ end
@@ -9,9 +9,13 @@ module RakeGitCrypt
9
9
  default_name :init
10
10
  default_description 'Initialise git-crypt.'
11
11
 
12
- action do |_task|
12
+ parameter :key_name
13
+
14
+ action do |task|
13
15
  puts('Initialising git-crypt...')
14
- RubyGitCrypt.init
16
+ RubyGitCrypt.init(
17
+ key_name: task.key_name
18
+ )
15
19
  end
16
20
  end
17
21
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'tasks/init'
4
+ require_relative 'tasks/add_gpg_user'
4
5
 
5
6
  module RakeGitCrypt
6
7
  module Tasks
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RakeGitCrypt
4
- VERSION = '0.1.0.pre.1'
4
+ VERSION = '0.1.0.pre.2'
5
5
  end
@@ -39,6 +39,7 @@ Gem::Specification.new do |spec|
39
39
  spec.add_dependency 'colored2', '~> 3.1'
40
40
  spec.add_dependency 'rake_factory', '~> 0.23'
41
41
  spec.add_dependency 'ruby_git_crypt', '0.1.0.pre.2'
42
+ spec.add_dependency 'ruby_gpg2', '~> 0.6'
42
43
 
43
44
  spec.add_development_dependency 'activesupport'
44
45
  spec.add_development_dependency 'bundler'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake_git_crypt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.1
4
+ version: 0.1.0.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - InfraBlocks Maintainers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-07 00:00:00.000000000 Z
11
+ date: 2023-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored2
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.1.0.pre.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: ruby_gpg2
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.6'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.6'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: activesupport
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -266,6 +280,7 @@ files:
266
280
  - lib/rake_git_crypt.rb
267
281
  - lib/rake_git_crypt/task_sets.rb
268
282
  - lib/rake_git_crypt/tasks.rb
283
+ - lib/rake_git_crypt/tasks/add_gpg_user.rb
269
284
  - lib/rake_git_crypt/tasks/init.rb
270
285
  - lib/rake_git_crypt/version.rb
271
286
  - rake_git_crypt.gemspec