Class: Canopus::Workspace::Trust
- Inherits:
-
Object
- Object
- Canopus::Workspace::Trust
- Defined in:
- lib/canopus/workspace/trust.rb,
sig/trust.rbs
Instance Method Summary collapse
-
#initialize(root, state_path: nil) ⇒ Trust
constructor
A new instance of Trust.
- #status ⇒ :trusted, :untrusted
- #trust! ⇒ Boolean
- #trusted? ⇒ Boolean
- #untrust! ⇒ Boolean
Constructor Details
#initialize(root, state_path: nil) ⇒ Trust
Returns a new instance of Trust.
10 11 12 13 14 15 |
# File 'lib/canopus/workspace/trust.rb', line 10 def initialize(root, state_path: nil) @root = File.realpath(root) @state_path = state_path || File.join(ENV["XDG_STATE_HOME"] || File.("~/.local/state"), "canopus", "trust.json") @key = Digest::SHA256.hexdigest(@root) @states = load_states end |
Instance Method Details
#status ⇒ :trusted, :untrusted
18 |
# File 'lib/canopus/workspace/trust.rb', line 18 def status = trusted? ? :trusted : :untrusted |
#trust! ⇒ Boolean
20 21 22 |
# File 'lib/canopus/workspace/trust.rb', line 20 def trust! update(true) end |
#trusted? ⇒ Boolean
17 |
# File 'lib/canopus/workspace/trust.rb', line 17 def trusted? = @states[@key] == true |
#untrust! ⇒ Boolean
24 25 26 |
# File 'lib/canopus/workspace/trust.rb', line 24 def untrust! update(false) end |