Class: SafeDb::View
Overview
View provides a bird’s eye view of the domain’s content and links well with the goto, show and tell commands.
$ xxx view
$ xxx goto 5 # shortcut for xxx open <<envelope_name>> <<key_name>>
$ xxx show
$ xxx tell
$ xxx tell url
View maps out and numbers each envelope/key combination. Goto with the number effectively shortcuts the open pinpointer. Show prints out the dictionary at the opened path but masks any secrets. Tell without a parameter echoes the secret. Tell with parameter echoes the value of the parameter key (eg url).
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
Attributes inherited from UseCase
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 Method Details
#execute ⇒ Object
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/usecase/view.rb', line 24 def execute return unless ops_key_exists? master_db = KeyApi.read_master_db() open_envelope = "(none)" if master_db[ ENV_PATH ].nil? open_envelope = master_db[ ENV_PATH ] unless master_db[ ENV_PATH ].nil? open_key_path = "(none)" if master_db[ KEY_PATH ].nil? open_key_path = master_db[ KEY_PATH ] unless master_db[ KEY_PATH ].nil? puts "" puts "--- Book Birthday ~> #{KeyApi.to_db_create_date(master_db)}\n" puts "--- The Book Name ~> #{KeyApi.to_db_domain_name(master_db)}\n" puts "--- The Book (Id) ~> #{KeyApi.to_db_domain_id(master_db)}\n" puts "---\n" puts "--- Chapter ~> #{open_envelope}\n" puts "--- + Verse ~> #{open_key_path}\n" puts "---\n" goto_location = 1 envelope_dictionaries = KeyApi.to_matching_dictionary( master_db, ENVELOPE_KEY_PREFIX ) envelope_dictionaries.each_pair do | envelope_name, crumb_dictionary | is_opened_chapter = envelope_name.eql?( open_envelope ) envelope_content = KeyDb.from_json( KeyApi.content_unlock( crumb_dictionary ) ) envelope_content.each_key do | envelope_key | is_opened_verse = envelope_key.eql?( open_key_path ) is_open = is_opened_chapter && is_opened_verse openend = is_open ? " (( open location ))" : "" fixdint = format( "%02d", goto_location ) goindex = is_open ? "" : "[#{fixdint}] " puts "--- --- --------------------------------------" if is_open puts "--- #{goindex}#{envelope_name} ~> #{envelope_key}#{openend}\n" puts "--- --- --------------------------------------" if is_open goto_location += 1 end end puts "" return end |