Class: SafeDb::Goto

Inherits:
UseCase show all
Defined in:
lib/usecase/goto.rb

Overview

Goto is a shortcut (or alias even) for the open command that takes an integer index that effectively specifies which <envelope> and <key> to open.

Use view to list the valid integer indices for each envelope and key combination.

View maps out and numbers each envelope/key combination. Goto with the number effectively shortcuts the open pin pointer command. Show prints the dictionary at the opened path masking any secrets.

Once goto is enacted all path CRUD commands come into play as if you had opened the path. These include put, copy, paste, show, tell and delete.

Constant Summary

Constants inherited from UseCase

UseCase::APP_DIR_NAME, UseCase::COMMANDMENT, UseCase::ENV_VAR_KEY_NAME, UseCase::ENV_VAR_PREFIX_A, UseCase::ENV_VAR_PREFIX_B, UseCase::FILE_CONTENT_KEY, UseCase::FILE_KEY_PREFIX, UseCase::FILE_NAME_KEY

Instance Attribute Summary collapse

Attributes inherited from UseCase

#from_script

Instance Method Summary collapse

Methods inherited from UseCase

#check_post_conditions, #check_pre_conditions, #cleanup, #config_directory, #config_file, #flow_of_events, #get_master_database, #initialize, #post_validation, #pre_validation

Constructor Details

This class inherits a constructor from SafeDb::UseCase

Instance Attribute Details

#index=(value) ⇒ Object (writeonly)

The index (number) starting with 1 of the envelope and key-path combination that should be opened.



21
22
23
# File 'lib/usecase/goto.rb', line 21

def index=(value)
  @index = value
end

Instance Method Details

#executeObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/usecase/goto.rb', line 23

def execute

  return unless ops_key_exists?
  master_db = KeyApi.read_master_db()

  goto_location = 0
  envelope_dictionaries = KeyApi.to_matching_dictionary( master_db, ENVELOPE_KEY_PREFIX )
  envelope_dictionaries.each_pair do | envelope_name, crumb_dictionary |

    envelope_content = KeyDb.from_json( KeyApi.content_unlock( crumb_dictionary ) )
    envelope_content.each_key do | envelope_key |

      goto_location += 1
      next unless @index.to_i == goto_location

      open_uc = Open.new
      open_uc.env_path = envelope_name
      open_uc.key_path = envelope_key
      open_uc.flow_of_events

      return

    end


  end


end