milestoner 13.3.0 → 14.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "refinements/structs"
4
-
5
- module Milestoner
6
- module CLI
7
- module Parsers
8
- # Handles parsing of Command Line Interface (CLI) security options.
9
- class Security
10
- using Refinements::Structs
11
-
12
- def self.call(...) = new(...).call
13
-
14
- def initialize configuration = Container[:configuration],
15
- client: Parser::CLIENT,
16
- container: Container
17
- @configuration = configuration
18
- @client = client
19
- @container = container
20
- end
21
-
22
- def call arguments = []
23
- client.separator "\nSECURITY OPTIONS:\n"
24
- add_sign
25
- client.parse arguments
26
- configuration
27
- end
28
-
29
- private
30
-
31
- attr_reader :configuration, :client, :container
32
-
33
- def add_sign
34
- client.on(
35
- "--[no-]sign",
36
- %(Sign with GPG key. Default: #{configuration.sign}.)
37
- ) do |value|
38
- compute_sign value
39
- end
40
- end
41
-
42
- def compute_sign value
43
- truth_table = [true, false].repeated_permutation(2).to_a
44
-
45
- case truth_table.index [value, configuration.sign]
46
- when 0..1 then configuration.merge! sign: true
47
- when 2..3 then configuration.merge! sign: false
48
- else logger.error { "--sign must be a boolean. Check gem configuration." }
49
- end
50
- end
51
-
52
- def logger = container[__method__]
53
- end
54
- end
55
- end
56
- end