Class: Secrets::App::Commands::Command
- Inherits:
-
Object
- Object
- Secrets::App::Commands::Command
show all
- Defined in:
- lib/secrets/app/commands/command.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(cli) ⇒ Command
Returns a new instance of Command.
36
37
38
|
# File 'lib/secrets/app/commands/command.rb', line 36
def initialize(cli)
self.cli = cli
end
|
Instance Attribute Details
#cli ⇒ Object
Returns the value of attribute cli.
34
35
36
|
# File 'lib/secrets/app/commands/command.rb', line 34
def cli
@cli
end
|
Class Method Details
.inherited(klass) ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/secrets/app/commands/command.rb', line 7
def self.inherited(klass)
klass.instance_eval do
@required_options = Set.new
class << self
def required_options(*args)
@required_options.merge(args) if args
@required_options
end
def short_name
name.split(/::/)[-1].underscore
end
def options_satisfied_by?(opts_hash)
proc = required_options.find { |option| option.is_a?(Proc) }
return true if proc && proc.call(opts_hash)
required_options.to_a.delete_if { |o| o.is_a?(Proc) }.all? { |o|
o.is_a?(Array) ? o.any? { |opt| opts_hash[opt] } : opts_hash[o]
}
end
end
Secrets::App::Commands.register klass
end
end
|
Instance Method Details
#key ⇒ Object
44
45
46
|
# File 'lib/secrets/app/commands/command.rb', line 44
def key
@key ||= opts[:private_key]
end
|
#opts ⇒ Object
40
41
42
|
# File 'lib/secrets/app/commands/command.rb', line 40
def opts
cli.opts
end
|