safedb 0.5.1002 → 0.5.1003
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cli.rb +36 -1
- data/lib/controller/admin/{access.rb → auth.rb} +3 -2
- data/lib/controller/admin/commit.rb +1 -1
- data/lib/controller/admin/export.rb +1 -1
- data/lib/controller/admin/import.rb +1 -1
- data/lib/controller/admin/init.rb +2 -2
- data/lib/controller/admin/login.rb +1 -1
- data/lib/controller/edit/generate.rb +76 -0
- data/lib/controller/edit/remove.rb +3 -0
- data/lib/controller/edit/rename.rb +57 -0
- data/lib/controller/files/write.rb +1 -1
- data/lib/controller/id.rb +2 -2
- data/lib/controller/requirer.rb +1 -8
- data/lib/model/state.inspect.rb +3 -0
- data/lib/model/state.migrate.rb +5 -5
- data/lib/model/text_chunk.rb +1 -1
- data/lib/utils/time/timestamp.rb +15 -20
- data/lib/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fc97d7955c363f290d97994018b73806d1d465fdc8628bc299069bc0b4c2a43c
|
|
4
|
+
data.tar.gz: a0885f01b7fd396cf0860df2ba1383fb58222e62ebd298febf5c2aaa898ab071
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 989bd998cc21841345b12f8bb2d3a74191203ce11d9895cd54e000fc597804988fe80cf76d0874a2d3c60e8e3a1d1bc1addf36f1db7a8c8edaef815b4c78091a
|
|
7
|
+
data.tar.gz: 35856adea81b13c0940c2ef8ce122fdfa19ebbdfad734a8eb6dad08f3e430c7b803c68afd54a68a88abb0b8ec91a74b2c58797c631233b8f1729ca484b54eb21
|
data/lib/cli.rb
CHANGED
|
@@ -72,7 +72,7 @@ class CLI < Thor
|
|
|
72
72
|
|
|
73
73
|
puts ""
|
|
74
74
|
puts "safedb gem version => v#{SafeDb::VERSION}"
|
|
75
|
-
puts "time and date now => #{SafeDb::
|
|
75
|
+
puts "time and date now => #{SafeDb::TimeStamp.human_readable()}"
|
|
76
76
|
puts "safedb @github.com => https://github.com/devops4me/safedb.net"
|
|
77
77
|
puts "safe @rubygems.org => https://rubygems.org/gems/safedb"
|
|
78
78
|
puts ""
|
|
@@ -325,6 +325,25 @@ class CLI < Thor
|
|
|
325
325
|
|
|
326
326
|
|
|
327
327
|
|
|
328
|
+
# Description of the generate command.
|
|
329
|
+
desc "generate <line>", "generate a string password that conforms to configured properties"
|
|
330
|
+
|
|
331
|
+
# The <b>generate use case</b> generates a random string credential that abides by
|
|
332
|
+
# the laws set out by configured and/or default parameter properties. These properties
|
|
333
|
+
# include the character superset to which all credential characters belong, the median
|
|
334
|
+
# length of the credential and the (give or take) span denoting the shortest and
|
|
335
|
+
# longest possible credentials.
|
|
336
|
+
#
|
|
337
|
+
# @param line [String] name of line the credential is stored against. Defaults to @password
|
|
338
|
+
def generate( line = "@password" )
|
|
339
|
+
log.info(x) { "generate a string credential and store it against line [#{line}]." }
|
|
340
|
+
generate_uc = SafeDb::Generate.new()
|
|
341
|
+
generate_uc.line = line
|
|
342
|
+
generate_uc.flow()
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
328
347
|
# Description of the remove command.
|
|
329
348
|
desc "remove <line_id>", "remove a line (key/value pair), or a verse, chapter and even a book"
|
|
330
349
|
|
|
@@ -341,6 +360,22 @@ class CLI < Thor
|
|
|
341
360
|
|
|
342
361
|
|
|
343
362
|
|
|
363
|
+
# Description of the rename command.
|
|
364
|
+
desc "rename <now_name> <new_name>", "rename an existing chapter, verse or line"
|
|
365
|
+
|
|
366
|
+
# The <b>rename use case</b> can rename an existing chapter, verse or line.
|
|
367
|
+
# @param now_name [String] the existing name of the chapter, verse or line
|
|
368
|
+
# @param new_name [String] the new name the chapter, verse or line goes by
|
|
369
|
+
def rename now_name, new_name
|
|
370
|
+
log.info(x) { "rename the existing chapter, verse or line from [ #{now_name} ] to [ #{new_name} ]." }
|
|
371
|
+
rename_uc = SafeDb::Rename.new()
|
|
372
|
+
rename_uc.now_name = now_name
|
|
373
|
+
rename_uc.new_name = new_name
|
|
374
|
+
rename_uc.flow()
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
344
379
|
# Description of the read command.
|
|
345
380
|
desc "read <file_url>", "read file into the open chapter and verse for safe keeping."
|
|
346
381
|
|
|
@@ -4,8 +4,10 @@ module SafeDb
|
|
|
4
4
|
|
|
5
5
|
# Parent to use cases like Init and Login that perform early
|
|
6
6
|
# initialize workflows.
|
|
7
|
-
class
|
|
7
|
+
class Auth < Controller
|
|
8
8
|
|
|
9
|
+
# This authorization use case should always have a book name
|
|
10
|
+
# provided and sometimes may have a password parameter.
|
|
9
11
|
attr_writer :password, :book_name
|
|
10
12
|
|
|
11
13
|
|
|
@@ -29,7 +31,6 @@ module SafeDb
|
|
|
29
31
|
|
|
30
32
|
end
|
|
31
33
|
|
|
32
|
-
|
|
33
34
|
def contains_all_master_book_indices( data_map )
|
|
34
35
|
return false unless data_map.contains?( Indices::CONTENT_RANDOM_IV )
|
|
35
36
|
return false unless data_map.contains?( Indices::CONTENT_IDENTIFIER )
|
|
@@ -23,7 +23,7 @@ module SafeDb
|
|
|
23
23
|
puts " Open Verse := #{@book.get_open_verse_name()}\n" if @book.has_open_verse_name?()
|
|
24
24
|
puts ""
|
|
25
25
|
|
|
26
|
-
export_filename = "safedb.#{
|
|
26
|
+
export_filename = "safedb.#{TimeStamp.yyjjj_hhmm_ss_nanosec()}.#{@book.book_id()}.json"
|
|
27
27
|
export_filepath = File.join( Dir.pwd, export_filename )
|
|
28
28
|
|
|
29
29
|
exported_struct = {}
|
|
@@ -26,7 +26,7 @@ module SafeDb
|
|
|
26
26
|
puts " Book Name := #{@book.book_name()}\n"
|
|
27
27
|
puts " Book Id := #{@book.book_id()}\n"
|
|
28
28
|
puts " Import from := #{@import_filepath}\n"
|
|
29
|
-
puts " Import time := #{
|
|
29
|
+
puts " Import time := #{TimeStamp.readable()}\n"
|
|
30
30
|
puts ""
|
|
31
31
|
|
|
32
32
|
new_verse_count = 0
|
|
@@ -28,7 +28,7 @@ module SafeDb
|
|
|
28
28
|
# - the book name ( maybe from SAFE_BOOK_NAME ) follows convention
|
|
29
29
|
# - the shell must have a SAFE_TTY_TOKEN environment variable
|
|
30
30
|
#
|
|
31
|
-
class Init <
|
|
31
|
+
class Init < Auth
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
def execute
|
|
@@ -71,7 +71,7 @@ module SafeDb
|
|
|
71
71
|
def virginal_book()
|
|
72
72
|
|
|
73
73
|
initial_db = DataStore.new()
|
|
74
|
-
initial_db.store( Indices::SAFE_BOOK_INITIALIZE_TIME,
|
|
74
|
+
initial_db.store( Indices::SAFE_BOOK_INITIALIZE_TIME, TimeStamp.readable() )
|
|
75
75
|
initial_db.store( Indices::SAFE_BOOK_NAME, @book_name )
|
|
76
76
|
initial_db.store( Indices::SAFE_BOOK_INIT_VERSION, Indices::SAFE_VERSION_STRING )
|
|
77
77
|
initial_db.store( Indices::SAFE_BOOK_CHAPTER_KEYS, {} )
|
|
@@ -23,7 +23,7 @@ module SafeDb
|
|
|
23
23
|
# - a file in the present directory (with a pre-agreed name)
|
|
24
24
|
# - a URL from a parameter or pre-agreed
|
|
25
25
|
# - the shell's secure password reader
|
|
26
|
-
class Login <
|
|
26
|
+
class Login < Auth
|
|
27
27
|
|
|
28
28
|
# If the clip switch is present it signifies that the password should
|
|
29
29
|
# be read in from the clipboard. Any text selection puts text into the
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
|
|
3
|
+
module SafeDb
|
|
4
|
+
|
|
5
|
+
# The <b>generate use case</b> generates a random string credential that abides by
|
|
6
|
+
# the laws set out by configured and/or default parameter properties. These properties
|
|
7
|
+
# include the character superset to which all credential characters belong, the median
|
|
8
|
+
# length of the credential and the (give or take) span denoting the shortest and
|
|
9
|
+
# longest possible credentials.
|
|
10
|
+
#
|
|
11
|
+
# If the parameter line already exists in the verse, it is backed up by appending
|
|
12
|
+
# it with a timestamp to prevent overwriting (and losing) the old value forever. This
|
|
13
|
+
# no clobber behaviour can be switched off by passing the --overwrite flag.
|
|
14
|
+
class Generate < EditVerse
|
|
15
|
+
|
|
16
|
+
# This is the name of the key the generated randomized string will be
|
|
17
|
+
# stored against within the current opened chapter and verse.
|
|
18
|
+
attr_writer :line
|
|
19
|
+
|
|
20
|
+
# A default median length of 14 characters with a give or take
|
|
21
|
+
# span of two means that the resulting password length could be
|
|
22
|
+
# one of either 12, 13, 14, 15 or 16 characters.
|
|
23
|
+
MEDIAN_LENGTH = 14
|
|
24
|
+
|
|
25
|
+
# If a median length of 15 is required with give or take set
|
|
26
|
+
# at 3 - the resulting password length could be anything from
|
|
27
|
+
# a minimum of 12 (15 - 3) to a maximum of 18 (15 + 3).
|
|
28
|
+
GIVE_OR_TAKE_SIZE = 2
|
|
29
|
+
|
|
30
|
+
# The length range typifies the set of possible credential lengths
|
|
31
|
+
# that can be produced by this class. The lower bound is the median
|
|
32
|
+
# length less give or take, the upper bound is the median length
|
|
33
|
+
# plus the give or take size.
|
|
34
|
+
LENGTH_RANGE = (MEDIAN_LENGTH - GIVE_OR_TAKE_SIZE) .. ( MEDIAN_LENGTH + GIVE_OR_TAKE_SIZE)
|
|
35
|
+
|
|
36
|
+
# The super strong non alpha-numeric character set has a large
|
|
37
|
+
# set of characters configured for the most secure credentials
|
|
38
|
+
# protecting security concious application states.
|
|
39
|
+
STRONG_CHARACTERS = "?@=$~%/+^.,][\{\}\<\>\&\(\)_\-"
|
|
40
|
+
|
|
41
|
+
# The widely accepted non alpha-numeric character set contains
|
|
42
|
+
# these characters
|
|
43
|
+
#
|
|
44
|
+
# - an @ sign
|
|
45
|
+
# - a percent sign
|
|
46
|
+
# - plus sign
|
|
47
|
+
# - a period
|
|
48
|
+
# - a comma
|
|
49
|
+
# - an (open) square bracket
|
|
50
|
+
# - a (close) square bracket
|
|
51
|
+
# - an underscore
|
|
52
|
+
# - a hyphen
|
|
53
|
+
WIDELY_ACCEPTED_CHARS = "@%+.,][_\-"
|
|
54
|
+
|
|
55
|
+
# This is the command used to generate the credentials stream.
|
|
56
|
+
GENERATE_CMD = "head /dev/urandom | tr -dc A-Za-z0-9#{WIDELY_ACCEPTED_CHARS} | head -c 258"
|
|
57
|
+
|
|
58
|
+
# The <b>generate use case</b> generates random strings that abide by a configured
|
|
59
|
+
# median length, span size, and a configured superset of characters that the generated
|
|
60
|
+
# credentials characters will be a subset of.
|
|
61
|
+
def edit_verse()
|
|
62
|
+
|
|
63
|
+
credential_length = Random.new().rand( LENGTH_RANGE )
|
|
64
|
+
credential_stream = %x[ #{GENERATE_CMD} ]
|
|
65
|
+
credential_string = credential_stream.chomp()[ 0 .. ( credential_length - 1 ) ]
|
|
66
|
+
|
|
67
|
+
@verse.store( "#{@line}-#{TimeStamp.yyjjj_hhmm_sst()}", @verse[ @line ] ) if @verse.has_key?( @line )
|
|
68
|
+
@verse.store( @line, credential_string )
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
end
|
|
@@ -17,6 +17,9 @@ module SafeDb
|
|
|
17
17
|
# wants to delete only one line (key/value pair).
|
|
18
18
|
def edit_verse()
|
|
19
19
|
|
|
20
|
+
# @todo refactor to recognise file values using isMap rather than the string prefix
|
|
21
|
+
# @todo refactor the Rename, Show, Read and Write use cases as well as this one.
|
|
22
|
+
|
|
20
23
|
@verse.delete( @line_id )
|
|
21
24
|
@verse.delete( "#{Indices::INGESTED_FILE_LINE_NAME_KEY}#{@line_id}" )
|
|
22
25
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
|
|
3
|
+
module SafeDb
|
|
4
|
+
|
|
5
|
+
# The <b>rename use case</b> when applied at the verse level changes the
|
|
6
|
+
# stated <em>line keyname</em>.
|
|
7
|
+
#
|
|
8
|
+
class Rename < EditVerse
|
|
9
|
+
|
|
10
|
+
# The id of the current chapter, verse or line entity to be renamed is
|
|
11
|
+
# the now_name and its new name is the new_name.
|
|
12
|
+
attr_writer :now_name, :new_name
|
|
13
|
+
|
|
14
|
+
# Find the line key named now_name and replace it with the provided
|
|
15
|
+
# new_name. The validation for keynames applies, both must be provided and
|
|
16
|
+
# the now_name must exist. This use case also renames file keys.
|
|
17
|
+
def edit_verse()
|
|
18
|
+
|
|
19
|
+
# @todo refactor to recognise file values using isMap rather than the string prefix
|
|
20
|
+
# @todo refactor the Remove, Show, Read and Write use cases as well as this one.
|
|
21
|
+
|
|
22
|
+
exit(100) unless has_line?()
|
|
23
|
+
|
|
24
|
+
current_value = @verse[ @now_name ]
|
|
25
|
+
|
|
26
|
+
# @todo instead of store and delete use the hash key rename method
|
|
27
|
+
@verse.store( @new_name, current_value ) unless is_file?()
|
|
28
|
+
@verse.store( "#{Indices::INGESTED_FILE_LINE_NAME_KEY}#{@new_name}", current_value ) if is_file?()
|
|
29
|
+
|
|
30
|
+
@verse.delete( "#{Indices::INGESTED_FILE_LINE_NAME_KEY}#{@now_name}" )
|
|
31
|
+
@verse.delete( @now_name )
|
|
32
|
+
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def is_file?()
|
|
40
|
+
return @verse.has_key?( "#{Indices::INGESTED_FILE_LINE_NAME_KEY}#{@now_name}" )
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def has_line?()
|
|
44
|
+
|
|
45
|
+
return true if( @verse.has_key?( @now_name ) || @verse.has_key?( "#{Indices::INGESTED_FILE_LINE_NAME_KEY}#{@now_name}" ) )
|
|
46
|
+
@book.print_book_mark()
|
|
47
|
+
puts ""
|
|
48
|
+
puts "Line [ #{@now_name} ] is not in this chapter/verse."
|
|
49
|
+
puts ""
|
|
50
|
+
return false
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
end
|
|
@@ -32,7 +32,7 @@ module SafeDb
|
|
|
32
32
|
destination_dir = @to_dir unless @to_dir.nil?
|
|
33
33
|
|
|
34
34
|
file_full_path = File.join( destination_dir, simple_filename )
|
|
35
|
-
backup_filename =
|
|
35
|
+
backup_filename = TimeStamp.yyjjj_hhmm_sst() + "-" + simple_filename
|
|
36
36
|
backup_file_path = File.join( destination_dir, backup_filename )
|
|
37
37
|
will_clobber = File.file?( file_full_path )
|
|
38
38
|
|
data/lib/controller/id.rb
CHANGED
data/lib/controller/requirer.rb
CHANGED
|
@@ -87,16 +87,11 @@ module SafeDb
|
|
|
87
87
|
|
|
88
88
|
require_relative "../version"
|
|
89
89
|
require_relative "../controller/controller"
|
|
90
|
-
require_relative "../controller/admin/
|
|
90
|
+
require_relative "../controller/admin/auth"
|
|
91
91
|
require_relative "../controller/edit/editverse"
|
|
92
92
|
require_relative "../controller/query/queryverse"
|
|
93
93
|
|
|
94
94
|
gem_basepath = File.expand_path "..", gem_filepath
|
|
95
|
-
|
|
96
|
-
log.debug(x) { "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" }
|
|
97
|
-
log.debug(x) { "@@@@ Require Gems In or Under [#{gem_basepath}]" }
|
|
98
|
-
log.debug(x) { "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" }
|
|
99
|
-
|
|
100
95
|
Dir["#{gem_basepath}/**/*.rb"].each do |gem_path|
|
|
101
96
|
|
|
102
97
|
log.debug(x) { "@@@@ => #{gem_path}" }
|
|
@@ -104,8 +99,6 @@ module SafeDb
|
|
|
104
99
|
|
|
105
100
|
end
|
|
106
101
|
|
|
107
|
-
log.debug(x) { "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" }
|
|
108
|
-
|
|
109
102
|
end
|
|
110
103
|
|
|
111
104
|
end
|
data/lib/model/state.inspect.rb
CHANGED
|
@@ -137,6 +137,7 @@ module SafeDb
|
|
|
137
137
|
private
|
|
138
138
|
|
|
139
139
|
|
|
140
|
+
|
|
140
141
|
def self.data_differences( this_data, that_data )
|
|
141
142
|
|
|
142
143
|
this_data.each_pair do | chapter_name, master_verse_data |
|
|
@@ -171,6 +172,7 @@ module SafeDb
|
|
|
171
172
|
|
|
172
173
|
end
|
|
173
174
|
|
|
175
|
+
|
|
174
176
|
def self.drop_differences( this_data, that_data )
|
|
175
177
|
|
|
176
178
|
this_data.each_pair do | chapter_name, master_verse_data |
|
|
@@ -200,6 +202,7 @@ module SafeDb
|
|
|
200
202
|
|
|
201
203
|
end
|
|
202
204
|
|
|
205
|
+
|
|
203
206
|
def self.print_chapter_2b_added( fq_chap_name )
|
|
204
207
|
puts " + Chapter 2b added -> #{fq_chap_name}"
|
|
205
208
|
end
|
data/lib/model/state.migrate.rb
CHANGED
|
@@ -243,7 +243,7 @@ module SafeDb
|
|
|
243
243
|
|
|
244
244
|
keypairs = DataMap.new( Indices::MASTER_INDICES_FILEPATH )
|
|
245
245
|
keypairs.use( book_identifier )
|
|
246
|
-
keypairs.set( Indices::SAFE_BOOK_INITIALIZE_TIME,
|
|
246
|
+
keypairs.set( Indices::SAFE_BOOK_INITIALIZE_TIME, TimeStamp.readable() )
|
|
247
247
|
keypairs.set( Indices::COMMIT_IDENTIFIER, Identifier.get_random_identifier( 16 ) )
|
|
248
248
|
end
|
|
249
249
|
|
|
@@ -314,14 +314,14 @@ module SafeDb
|
|
|
314
314
|
branch_exists = File.exists? FileTree.branch_indices_filepath( branch_id )
|
|
315
315
|
branch_keys = DataMap.new( FileTree.branch_indices_filepath( branch_id ) )
|
|
316
316
|
branch_keys.use( Indices::BRANCH_DATA )
|
|
317
|
-
branch_keys.set( Indices::BRANCH_INITIAL_LOGIN_TIME,
|
|
318
|
-
branch_keys.set( Indices::BRANCH_LAST_ACCESSED_TIME,
|
|
317
|
+
branch_keys.set( Indices::BRANCH_INITIAL_LOGIN_TIME, TimeStamp.readable() ) unless branch_exists
|
|
318
|
+
branch_keys.set( Indices::BRANCH_LAST_ACCESSED_TIME, TimeStamp.readable() )
|
|
319
319
|
branch_keys.set( Indices::CURRENT_BRANCH_BOOK_ID, book_id )
|
|
320
320
|
|
|
321
321
|
logged_in = branch_keys.has_section?( book_id )
|
|
322
322
|
branch_keys.use( book_id )
|
|
323
|
-
branch_keys.set( Indices::BOOK_BRANCH_LOGIN_TIME,
|
|
324
|
-
branch_keys.set( Indices::BOOK_LAST_ACCESSED_TIME,
|
|
323
|
+
branch_keys.set( Indices::BOOK_BRANCH_LOGIN_TIME, TimeStamp.readable() ) unless logged_in
|
|
324
|
+
branch_keys.set( Indices::BOOK_LAST_ACCESSED_TIME, TimeStamp.readable() )
|
|
325
325
|
|
|
326
326
|
return branch_keys
|
|
327
327
|
|
data/lib/model/text_chunk.rb
CHANGED
|
@@ -20,7 +20,7 @@ module SafeDb
|
|
|
20
20
|
#{Indices::SAFE_URL_NAME} ciphertext block
|
|
21
21
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
22
22
|
Safe Book Id := #{book_id}
|
|
23
|
-
Time Created := #{
|
|
23
|
+
Time Created := #{TimeStamp.readable()}
|
|
24
24
|
Safe Version := #{Indices::SAFE_VERSION_STRING}
|
|
25
25
|
Safe Website := #{Indices::SAFE_GEM_WEBSITE}
|
|
26
26
|
RubyGems.org := https://rubygems.org/gems/safedb
|
data/lib/utils/time/timestamp.rb
CHANGED
|
@@ -10,7 +10,7 @@ module SafeDb
|
|
|
10
10
|
# The central idea behind the pattern is to link every infrastructure
|
|
11
11
|
# object created during a branch with a reference accurate to the nearest
|
|
12
12
|
# centi-second denoting the moment the software runtime (branch) began.
|
|
13
|
-
class
|
|
13
|
+
class TimeStamp
|
|
14
14
|
include Singleton
|
|
15
15
|
|
|
16
16
|
attr_reader :time_now
|
|
@@ -19,7 +19,7 @@ module SafeDb
|
|
|
19
19
|
# @example 02 => in February
|
|
20
20
|
#
|
|
21
21
|
def self.mo
|
|
22
|
-
return
|
|
22
|
+
return TimeStamp.instance.time_now.strftime "%m"
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
|
|
@@ -27,7 +27,7 @@ module SafeDb
|
|
|
27
27
|
# @example feb => in February
|
|
28
28
|
#
|
|
29
29
|
def self.mmm
|
|
30
|
-
return
|
|
30
|
+
return TimeStamp.instance.time_now.strftime( "%b" ).downcase
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
|
|
@@ -36,7 +36,7 @@ module SafeDb
|
|
|
36
36
|
# @example tue => on Tuesday
|
|
37
37
|
#
|
|
38
38
|
def self.ddd
|
|
39
|
-
return
|
|
39
|
+
return TimeStamp.instance.time_now.strftime( "%a" ).downcase
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
|
|
@@ -45,7 +45,7 @@ module SafeDb
|
|
|
45
45
|
# @example 22 => between 22.00.00 and 22.59.59 inclusive
|
|
46
46
|
#
|
|
47
47
|
def self.hh
|
|
48
|
-
return
|
|
48
|
+
return TimeStamp.instance.time_now.strftime "%H"
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
|
|
@@ -53,7 +53,7 @@ module SafeDb
|
|
|
53
53
|
# Return two digit minute of hour from [00] to [59].
|
|
54
54
|
#
|
|
55
55
|
def self.mm
|
|
56
|
-
return
|
|
56
|
+
return TimeStamp.instance.time_now.strftime "%M"
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
|
|
@@ -61,7 +61,7 @@ module SafeDb
|
|
|
61
61
|
# Return two digit second of minute from [00] to [59].
|
|
62
62
|
#
|
|
63
63
|
def self.ss
|
|
64
|
-
return
|
|
64
|
+
return TimeStamp.instance.time_now.strftime "%S"
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
|
|
@@ -93,7 +93,7 @@ module SafeDb
|
|
|
93
93
|
#
|
|
94
94
|
#
|
|
95
95
|
def self.sst
|
|
96
|
-
millisec_string =
|
|
96
|
+
millisec_string = TimeStamp.instance.time_now.strftime "%L"
|
|
97
97
|
return "#{ss}#{millisec_string[0]}"
|
|
98
98
|
end
|
|
99
99
|
|
|
@@ -103,7 +103,7 @@ module SafeDb
|
|
|
103
103
|
# that we are currently in.
|
|
104
104
|
#
|
|
105
105
|
def self.yy
|
|
106
|
-
return
|
|
106
|
+
return TimeStamp.instance.time_now.strftime("%Y")[2..-1]
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
|
|
@@ -112,7 +112,7 @@ module SafeDb
|
|
|
112
112
|
# that we are currently in.
|
|
113
113
|
#
|
|
114
114
|
def self.yyyy
|
|
115
|
-
return
|
|
115
|
+
return TimeStamp.instance.time_now.strftime("%Y")
|
|
116
116
|
end
|
|
117
117
|
|
|
118
118
|
|
|
@@ -120,7 +120,7 @@ module SafeDb
|
|
|
120
120
|
# Return 3 digit julian day of year [001] to [366]. -- #
|
|
121
121
|
# ------------------------------------------------- -- #
|
|
122
122
|
def self.jjj
|
|
123
|
-
return
|
|
123
|
+
return TimeStamp.instance.time_now.strftime "%j"
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
|
|
@@ -257,11 +257,6 @@ module SafeDb
|
|
|
257
257
|
# hour, 2 digit minute, 2 digit second and 1 digit rounded
|
|
258
258
|
# down tenth of second.
|
|
259
259
|
#
|
|
260
|
-
# @example
|
|
261
|
-
# => 19003.1025
|
|
262
|
-
# => 10:25 am on January 3rd 2019
|
|
263
|
-
#
|
|
264
|
-
#
|
|
265
260
|
# Return the time of day to a TENTH of a second accuracy.
|
|
266
261
|
# [8] characters will always be returned with the 5th one
|
|
267
262
|
# being the (period) separator.
|
|
@@ -311,7 +306,7 @@ module SafeDb
|
|
|
311
306
|
# 23 characters are always returned with three (3) period
|
|
312
307
|
# separators at the 6th, 11th and 14th positions.
|
|
313
308
|
def self.yyjjj_hhmm_ss_nanosec
|
|
314
|
-
nanosec_str =
|
|
309
|
+
nanosec_str = TimeStamp.instance.time_now.strftime "%9N"
|
|
315
310
|
return "#{yyjjj}.#{hhmm}.#{ss}.#{nanosec_str}"
|
|
316
311
|
end
|
|
317
312
|
|
|
@@ -375,7 +370,7 @@ module SafeDb
|
|
|
375
370
|
|
|
376
371
|
# Return the Rubyfied time zone being used.
|
|
377
372
|
def self.zone
|
|
378
|
-
return
|
|
373
|
+
return TimeStamp.instance.time_now.zone
|
|
379
374
|
end
|
|
380
375
|
|
|
381
376
|
|
|
@@ -385,7 +380,7 @@ module SafeDb
|
|
|
385
380
|
def self.log_instance_time
|
|
386
381
|
|
|
387
382
|
log.debug(x) { "[stamp] -------------- => -------------------------------- #" }
|
|
388
|
-
log.debug(x) { "[stamp] eco time stamp => [#{
|
|
383
|
+
log.debug(x) { "[stamp] eco time stamp => [#{TimeStamp.instance.time_now.ctime}]" }
|
|
389
384
|
log.debug(x) { "[stamp] -------------- => -------------------------------- #" }
|
|
390
385
|
log.debug(x) { "[stamp] Univ Time Zone => #{zone}" }
|
|
391
386
|
log.debug(x) { "[stamp] Month Index is => #{mo}" }
|
|
@@ -413,7 +408,7 @@ module SafeDb
|
|
|
413
408
|
end
|
|
414
409
|
|
|
415
410
|
|
|
416
|
-
|
|
411
|
+
TimeStamp.log_instance_time
|
|
417
412
|
|
|
418
413
|
|
|
419
414
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: safedb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.1003
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Apollo Akora
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-04-
|
|
11
|
+
date: 2019-04-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bcrypt
|
|
@@ -129,7 +129,7 @@ files:
|
|
|
129
129
|
- bin/safe
|
|
130
130
|
- lib/cli.rb
|
|
131
131
|
- lib/controller/admin/README.md
|
|
132
|
-
- lib/controller/admin/
|
|
132
|
+
- lib/controller/admin/auth.rb
|
|
133
133
|
- lib/controller/admin/commit.rb
|
|
134
134
|
- lib/controller/admin/diff.rb
|
|
135
135
|
- lib/controller/admin/export.rb
|
|
@@ -156,9 +156,11 @@ files:
|
|
|
156
156
|
- lib/controller/controller.rb
|
|
157
157
|
- lib/controller/edit/README.md
|
|
158
158
|
- lib/controller/edit/editverse.rb
|
|
159
|
+
- lib/controller/edit/generate.rb
|
|
159
160
|
- lib/controller/edit/put.rb
|
|
160
161
|
- lib/controller/edit/remove.rb
|
|
161
162
|
- lib/controller/edit/rename.md
|
|
163
|
+
- lib/controller/edit/rename.rb
|
|
162
164
|
- lib/controller/files/README.md
|
|
163
165
|
- lib/controller/files/read.rb
|
|
164
166
|
- lib/controller/files/write.rb
|