Class: SafeDb::TextChunk

Inherits:
Object
  • Object
show all
Defined in:
lib/model/text_chunk.rb

Overview

These textual chunks will hold information blocks that are printed into files or printed out for user consumption on standard out.

Class Method Summary collapse

Class Method Details

.crypt_header(book_id) ⇒ String

Construct the header for the ciphertext content files written out onto the filesystem including information such as the application version and human readable time.

Parameters:

  • book_id (String)

    the identifier of the book that is being queried and edited

Returns:

  • (String)

    a textual block that can be printed at the top of crypt files



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/model/text_chunk.rb', line 15

def self.crypt_header( book_id )

  <<-CRYPT_HEADER
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#{Indices::SAFE_URL_NAME} ciphertext block
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Safe Book Id := #{book_id}
Time Created := #{TimeStamp.readable()}
Safe Version := #{Indices::SAFE_PRE_VERSION_STRING}#{SafeDb::VERSION}
Safe Website := #{Indices::SAFE_GEM_WEBSITE}
RubyGems.org := https://rubygems.org/gems/safedb
CRYPT_HEADER

end

.not_logged_in_messageObject

Print a message stating that the book cannot be accessed until a successful login has occured.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/model/text_chunk.rb', line 34

def self.not_logged_in_message()

  <<-NOT_LOGGED_IN_MESSAGE

  Please login to access the credentials in this book.
  Suppose you initialized a book called websites.

#{Indices::COMMANDER} login websites
 #{Indices::COMMANDER} login websites --password=secret123
#{Indices::COMMANDER} login websites --clip

  A space before the command skips history logging.

NOT_LOGGED_IN_MESSAGE

end

.not_open_messageObject

Print a message stating that the book has not been opened at any chapter and verse location.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/model/text_chunk.rb', line 54

def self.not_open_message()

  <<-UNOPENED_MESSAGE

  Please open a chapter and verse to put, edit or query data.

 #{Indices::COMMANDER} open contacts monica

  then add monica's contact details

 #{Indices::COMMANDER} put email [email protected]
 #{Indices::COMMANDER} put phone +1-357-246-8901
 #{Indices::COMMANDER} put twitter @monica_x
 #{Indices::COMMANDER} put skype.id 6363430539
 #{Indices::COMMANDER} put birthday \"1st April 1978\"

  also hilary's

 #{Indices::COMMANDER} open contacts hilary
 #{Indices::COMMANDER} put email [email protected]

  then save the changes to your book and logout."

 #{Indices::COMMANDER} commit"
 #{Indices::COMMANDER} logout"

UNOPENED_MESSAGE

end