safedb 0.3.1011 → 0.4.1002

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +56 -19
  3. data/README.md +15 -15
  4. data/Rakefile +7 -0
  5. data/bin/safe +2 -2
  6. data/lib/{interprete.rb → cli.rb} +168 -121
  7. data/lib/controller/admin/README.md +47 -0
  8. data/lib/controller/admin/access.rb +47 -0
  9. data/lib/controller/admin/checkin.rb +83 -0
  10. data/lib/controller/admin/checkout.rb +57 -0
  11. data/lib/controller/admin/diff.rb +75 -0
  12. data/lib/{usecase → controller/admin}/export.rb +15 -14
  13. data/lib/controller/admin/goto.rb +52 -0
  14. data/lib/controller/admin/import.rb +54 -0
  15. data/lib/controller/admin/init.rb +113 -0
  16. data/lib/controller/admin/login.rb +88 -0
  17. data/lib/{usecase → controller/admin}/logout.rb +0 -0
  18. data/lib/controller/admin/open.rb +39 -0
  19. data/lib/{usecase → controller/admin}/token.rb +2 -2
  20. data/lib/controller/admin/tree.md +54 -0
  21. data/lib/{usecase → controller/admin}/use.rb +0 -0
  22. data/lib/controller/admin/view.rb +61 -0
  23. data/lib/{usecase → controller/api}/docker/README.md +0 -0
  24. data/lib/{usecase → controller/api}/docker/docker.rb +1 -1
  25. data/lib/{usecase → controller/api}/jenkins/README.md +0 -0
  26. data/lib/{usecase → controller/api}/jenkins/jenkins.rb +1 -1
  27. data/lib/{usecase → controller/api}/terraform/README.md +1 -1
  28. data/lib/{usecase → controller/api}/terraform/terraform.rb +1 -1
  29. data/lib/{usecase → controller/api}/vpn/README.md +1 -1
  30. data/lib/{usecase → controller/api}/vpn/vpn.ini +0 -0
  31. data/lib/{usecase → controller/api}/vpn/vpn.rb +0 -0
  32. data/lib/{usecase → controller}/config/README.md +0 -0
  33. data/lib/{usecase → controller}/edit/README.md +0 -0
  34. data/lib/controller/edit/editverse.rb +48 -0
  35. data/lib/controller/edit/put.rb +35 -0
  36. data/lib/controller/edit/remove.rb +29 -0
  37. data/lib/{usecase/update/README.md → controller/edit/rename.md} +0 -0
  38. data/lib/{usecase → controller}/files/README.md +1 -1
  39. data/lib/controller/files/read.rb +36 -0
  40. data/lib/{usecase/files/eject.rb → controller/files/write.rb} +15 -20
  41. data/lib/{usecase → controller}/id.rb +0 -0
  42. data/lib/controller/query/print.rb +26 -0
  43. data/lib/controller/query/queryverse.rb +39 -0
  44. data/lib/controller/query/show.rb +50 -0
  45. data/lib/{session/require.gem.rb → controller/requirer.rb} +13 -9
  46. data/lib/{usecase → controller}/set.rb +4 -4
  47. data/lib/controller/usecase.rb +244 -0
  48. data/lib/{usecase → controller}/verse.rb +0 -0
  49. data/lib/{usecase → controller}/visit/README.md +0 -0
  50. data/lib/{usecase → controller}/visit/visit.rb +0 -0
  51. data/lib/factbase/facts.safedb.net.ini +7 -7
  52. data/lib/{keytools/key.docs.rb → model/README.md} +102 -66
  53. data/lib/model/book.rb +484 -0
  54. data/lib/model/branch.rb +48 -0
  55. data/lib/model/checkin.feature +33 -0
  56. data/lib/{configs/README.md → model/configs.md} +4 -4
  57. data/lib/model/content.rb +214 -0
  58. data/lib/model/indices.rb +132 -0
  59. data/lib/model/safe_tree.rb +51 -0
  60. data/lib/model/state.inspect.rb +221 -0
  61. data/lib/model/state.migrate.rb +334 -0
  62. data/lib/model/text_chunk.rb +68 -0
  63. data/lib/{extension → utils/extend}/array.rb +0 -0
  64. data/lib/{extension → utils/extend}/dir.rb +0 -0
  65. data/lib/{extension → utils/extend}/file.rb +0 -0
  66. data/lib/utils/extend/hash.rb +76 -0
  67. data/lib/{extension → utils/extend}/string.rb +6 -6
  68. data/lib/{session/fact.finder.rb → utils/facts/fact.rb} +0 -0
  69. data/lib/utils/identity/identifier.rb +356 -0
  70. data/lib/{keytools/key.ident.rb → utils/identity/machine.id.rb} +67 -4
  71. data/lib/utils/inspect/inspector.rb +81 -0
  72. data/lib/{keytools/kdf.bcrypt.rb → utils/kdfs/bcrypt.rb} +0 -0
  73. data/lib/{keytools → utils/kdfs}/kdf.api.rb +16 -16
  74. data/lib/{keytools/key.local.rb → utils/kdfs/kdfs.rb} +40 -40
  75. data/lib/{keytools/kdf.pbkdf2.rb → utils/kdfs/pbkdf2.rb} +0 -0
  76. data/lib/{keytools/kdf.scrypt.rb → utils/kdfs/scrypt.rb} +0 -0
  77. data/lib/{keytools → utils}/key.error.rb +2 -2
  78. data/lib/{keytools → utils}/key.pass.rb +2 -2
  79. data/lib/{keytools → utils/keys}/key.64.rb +0 -0
  80. data/lib/{keytools → utils/keys}/key.rb +6 -2
  81. data/lib/{keytools/key.iv.rb → utils/keys/random.iv.rb} +0 -0
  82. data/lib/{logging/gem.logging.rb → utils/logs/logger.rb} +6 -5
  83. data/lib/{keytools/key.pair.rb → utils/store/datamap.rb} +48 -30
  84. data/lib/{keytools/key.db.rb → utils/store/datastore.rb} +38 -104
  85. data/lib/utils/store/merge-boys-school.json +40 -0
  86. data/lib/utils/store/merge-girls-school.json +48 -0
  87. data/lib/utils/store/merge-merged-data.json +56 -0
  88. data/lib/utils/store/struct.rb +75 -0
  89. data/lib/utils/store/test-commands.sh +24 -0
  90. data/lib/{keytools/key.now.rb → utils/time/timestamp.rb} +32 -21
  91. data/lib/version.rb +1 -1
  92. metadata +86 -73
  93. data/lib/extension/hash.rb +0 -33
  94. data/lib/keytools/key.algo.rb +0 -109
  95. data/lib/keytools/key.api.rb +0 -1326
  96. data/lib/keytools/key.id.rb +0 -322
  97. data/lib/modules/cryptology/amalgam.rb +0 -70
  98. data/lib/modules/cryptology/engineer.rb +0 -99
  99. data/lib/modules/mappers/dictionary.rb +0 -288
  100. data/lib/session/time.stamp.rb +0 -340
  101. data/lib/session/user.home.rb +0 -49
  102. data/lib/usecase/cmd.rb +0 -471
  103. data/lib/usecase/edit/delete.rb +0 -46
  104. data/lib/usecase/files/file_me.rb +0 -78
  105. data/lib/usecase/files/read.rb +0 -169
  106. data/lib/usecase/files/write.rb +0 -89
  107. data/lib/usecase/goto.rb +0 -57
  108. data/lib/usecase/import.rb +0 -157
  109. data/lib/usecase/init.rb +0 -61
  110. data/lib/usecase/login.rb +0 -72
  111. data/lib/usecase/open.rb +0 -71
  112. data/lib/usecase/print.rb +0 -40
  113. data/lib/usecase/put.rb +0 -81
  114. data/lib/usecase/show.rb +0 -138
  115. data/lib/usecase/update/rename.rb +0 -180
  116. data/lib/usecase/view.rb +0 -71
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 202262aed7ae6b3cffbba137d118838cf8370d7ef54244215833378a1944c56c
4
- data.tar.gz: 990e817eab3133c4a42e6bb904874e060a204900319b7d87015e6d0449553c1c
3
+ metadata.gz: 3bcafea21f4204ecebc6712dd926e839aeb8c078904487528b44de4b1f87b4d8
4
+ data.tar.gz: 256015d30eb46362a1d3923d6a7cf0c1d88942b67c4f5cd8e7dce6b6b5fb40b4
5
5
  SHA512:
6
- metadata.gz: 1c2d25554329ceb38a8ed6dde23036100c8e54f9022d5a782f0ef66bee1aa05d207150282a5ea3766f1061f79d2871eb47b954090896452064912ef083ebc68f
7
- data.tar.gz: c553057dcbb670b980a8ed7e2a784c0445a04314f53d86bd1bd9f8326997a2bf0dda5a1b2f375df3a5bb0b71c3e92a74509b24f5e10318634572241baa706be4
6
+ metadata.gz: d013b6386bfc912ede2b8ad1736309c48cbbbb36d3e23731c092f4e041df47a3d012aa9a5ea5ecebb841d8f0066f040da2b3fb1c1e61adfff424997bc429f2ca
7
+ data.tar.gz: 42a6f28ecad6fc9fcbd759b4abdcfea468ebfe491cd75775698055b52946042009123edf6c1b5cc8bd56cd78fc8f78bd33ee42861cf3b973de44c67a7cc39beb
data/CONTRIBUTING.md CHANGED
@@ -42,20 +42,68 @@ reek lib
42
42
  ```
43
43
 
44
44
 
45
- ## Releasing Software
45
+ ## Automated Software Release
46
46
 
47
- Those with priveleges to release to safedb.net will have a private key to push (or pull) in git repository changes.
47
+ safedb is automatically released by Jenkins using a GitOps style pipeline defined in the Jenkinsfile and Dockerfile. The release to rubygems.org depends on
48
48
 
49
- To release the software to the rubygems.org platform, commonly via a **continuous integration pipeline** based on Jenkins 2.0, one needs
49
+ - a pull request to the [safe github master branch](https://github.com/devops4me/safedb.net.git)
50
+ - an error-free gem build
51
+ - an error-free documentation image build to www.safedb.net
52
+ - immaculate BDD test runs with **Cucumber and Aruba** in Linux environments incl Ubuntu, Raspbian and RHEL.
53
+ - an automated version number bump using the gem-release gem
54
+ - quality numbers passed by the Reek code quality analyzer
55
+ - available rubygems.org credentials in ~/.gem/credentials
50
56
 
51
- - **either** the email address / password combination
52
- - **or** a credentials file containing a hex API key
57
+ ## release safedb to RubyGems.org
53
58
 
54
- Release actors are also responsible for bumping the gem version via semantic versioning principles.
59
+ Once only use **`gem push`** at the repository root to create a **rubygems API key** and slurp it up from the **`~/.gem/credentials`** with **`safe file rubygems.org.credentials ~/.gem/credentials`**
60
+ Now when releasing we eject the file back into **`~/.gem/credentials`**, secure it ( with **`sudo chmod 0600 credentials`** ) and then issue the below command from the **gem-release** gem.
61
+
62
+ ### `gem bump patch --tag --push --release --file=$PWD/lib/version.rb`
63
+
64
+ The gem bump (and release) command bumps up the patch (or major or minor) version, tags the repository, pushes the changes and releases to rubygems.org
65
+
66
+
67
+
68
+ ## safedb development environment commands
69
+
70
+ ### `rake install`
71
+ ### `cucumber`
72
+ ### `git checkout -b feature.commit-branch`
73
+ ### `git add; git commit;`
74
+ ### `git cherry -v origin`
75
+ ### `git cherry -v origin feature.commit-branch`
76
+ ### `git push -u origin feature.commit-branch`
77
+ ### `git pull origin master`
78
+ ### `git pull origin feature.commit-branch`
79
+
80
+ ## common git feature merge commands
81
+
82
+ ### `git checkout master`
83
+ ### `git pull origin master`
84
+ ### `git merge feature.commit-branch`
85
+ ### `git push -u origin master`
86
+
87
+
88
+ ## Branch Naming Convention
55
89
 
56
- ### git push to github.com/devops4me/safedb.net
90
+ Branch names begin with either
57
91
 
58
- Write out the SSH config and private key files.
92
+ - feature. (or)
93
+ - bug. (or)
94
+ - refactor.
95
+
96
+ Branch names are then typically a **verb-noun concatenation** like
97
+
98
+ - feature.safe-inport-export
99
+ - refactor.book-id-create-algorithm
100
+ - refactor.validate-book-names
101
+
102
+ ## how to git push to safedb.net
103
+
104
+ Those with priveleges to release to safedb.net will have a private key to push pull requests into the repository.
105
+
106
+ This is how to setup the **ssh config** and **pem private key**.
59
107
 
60
108
  ```
61
109
  safe login safe.ecosystem
@@ -71,15 +119,4 @@ git clone git@safedb.code:devops4me/safedb.net.git mirror.safedb.code
71
119
 
72
120
  If a config file already exists then safe will back it up with a timestamp prefix before clobbering the file. Now bump up the major, minor or patch versions, then commit.
73
121
 
74
- ### development installs | rake install
75
-
76
- Use rake install to locally test local software changes.
77
-
78
- ### bump | tag | release to RubyGems.org
79
-
80
- Once only use **`gem push`** at the repository root to create a **rubygems API key** and slurp it up from the **`~/.gem/credentials`** with **`safe file rubygems.org.credentials ~/.gem/credentials`**
81
- Now when releasing we eject the file back into **`~/.gem/credentials`**, secure it ( with **`sudo chmod 0600 credentials`** ) and then issue the below command from the **gem-release** gem.
82
-
83
- ### `gem bump patch --tag --push --release --file=$PWD/lib/version.rb`
84
122
 
85
- This command bumps up the patch (or major or minor) version, tags the repository, pushes the changes and releases to rubygems.org
data/README.md CHANGED
@@ -104,7 +104,7 @@ safe | Install and Configure
104
104
 
105
105
  $ sudo apt-get install ruby-full # for OpenSSL we need full ruby
106
106
  $ sudo gem install safedb # install the safe ruby gem
107
- $ export SAFE_TTY_TOKEN=`safe token` # setup a shell session variable
107
+ $ export SAFE_TTY_TOKEN=`safe token` # setup a shell variable
108
108
  $ safe init joe@abc ~/safedb.creds # initialize a safe book in folder
109
109
  $ safe login joe@abc # login with the created password
110
110
 
@@ -143,7 +143,7 @@ Advanced users should avoid adding the export command to <tt>~/.bash_profile</tt
143
143
 
144
144
  When the shell closes the shell token will disappear which is good. You can clear it immediately with these commands.
145
145
 
146
- $ unset SAFE_TTY_TOKEN # Delete the shell session token
146
+ $ unset SAFE_TTY_TOKEN # Delete the shell token
147
147
  $ env | grep SAFE_TTY_TOKEN # Check SAFE_TTY_TOKEN is deleted
148
148
  $ env -i bash # Delete every env var created by shell
149
149
 
@@ -578,7 +578,7 @@ safe | moving computer
578
578
  We travel between laptops, desktops, virtual machines and even docker containers. Always run init the first time you use a domain on a different computer.
579
579
 
580
580
  $ gem install safe
581
- $ export SAFE_TTY_TOKEN=`safe token` # setup a shell session variable
581
+ $ export SAFE_TTY_TOKEN=`safe token` # setup a shell variable
582
582
  $ safe init joe@abc /home/joe/credentials # initialize a secrets domain
583
583
  $ safe login joe@abc # login to the new domain
584
584
 
@@ -647,7 +647,7 @@ You can require safe (as an SDK) and interact with it directly from any other Ru
647
647
  $ gem install safe
648
648
  $ irb
649
649
  $ > require "safe"
650
- $ > SafeDb::Interprete.version()
650
+ $ > SafeDb::CLI.version()
651
651
 
652
652
  The above should return the **installed version** of SafeDb.
653
653
 
@@ -752,17 +752,17 @@ This method (theoretially) allows a version 3.428.24952 to restore an export of
752
752
 
753
753
  ## Safe's Concurrency Methodology
754
754
 
755
- A safe repository (book) can be changed by one session but read concurrently by multiple sessions.
755
+ A safe repository (book) can be changed by one branch but read concurrently by multiple branchs.
756
756
 
757
757
  Directory Links are NOT PORTABLE to use to point to the active workspace especially if we the safe root folder is on a USB key.
758
758
  A GOOD engough concurrency technique is a lock file in the BOOK's root folder that is named `safe.concurrency.lockfile.<<book.id>>`
759
759
 
760
- The contents of the file will hold the relative directory name (session ID based) that has the lock and the session ID that had it before that (if not first).
760
+ The contents of the file will hold the relative directory name (branch ID based) that has the lock and the branch ID that had it before that (if not first).
761
761
 
762
- The <machine.id>.<bootup.id> is used to when the first read/write login session occurs. Subsequent logins for a read/write session will then have 2 choices in this shell.
762
+ The <machine.id>.<bootup.id> is used to when the first read/write login branch occurs. Subsequent logins for a read/write branch will then have 2 choices in this shell.
763
763
 
764
- - safe login ali.baba --steal # take over the primary read/write session
765
- - safe login ali.baba --branch # leave primary session but open one that will not change the price of sugar
764
+ - safe login ali.baba --steal # take over the primary read/write branch
765
+ - safe login ali.baba --branch # leave primary branch but open one that will not change the price of sugar
766
766
  - safe login ali.baba --branch=master
767
767
  - safe login ali.baba --branch=experimental
768
768
  - safe login ali.baba -b experimental
@@ -775,7 +775,7 @@ A third choice arises if we visit the shell holding the directory pointer and lo
775
775
 
776
776
  Logout NEVER TOUCHES the lock file (it could have moved on multiple times so only login can act on it).
777
777
 
778
- However logout DELETES the cipher.file intra-sessionary ciphertext that can be unlocked by session key to retrieve the content key. This action renders it impossible to read or write any data from logged in book.
778
+ However logout DELETES the cipher.file branch ciphertext that can be unlocked by branch key to retrieve the content key. This action renders it impossible to read or write any data from logged in book.
779
779
 
780
780
  A subsequent login can again re-instate this privilege.
781
781
 
@@ -790,22 +790,22 @@ The first repo holds the live link.
790
790
 
791
791
  Subsequent logins must perform two checks
792
792
 
793
- - IS MY DIRECTORY (session) noted as the latest in the lock file (possible if you've logged out of the same shell)
794
- - (if other directory) - Does the intra-sessionary key within that directory's cipher file have a value
793
+ - IS MY DIRECTORY (branch) noted as the latest in the lock file (possible if you've logged out of the same shell)
794
+ - (if other directory) - Does the branch key within that directory's cipher file have a value
795
795
 
796
796
  The popup asking the user to STEAL or go READONLY is triggered if the answers above are NO then YES.
797
797
 
798
798
  ### Safe steal | HowTo
799
799
 
800
- If intra key has no value then stealing is not necessary so the existence of the --steal flag does not change the price of sugar.
800
+ If branch key has no value then stealing is not necessary so the existence of the --steal flag does not change the price of sugar.
801
801
 
802
802
  The Stealing flow of events is to
803
803
 
804
- - copy the directory into a new one for this session named `<<book.id>>.<<timestamp>>.<<session.key>>`
804
+ - copy the directory into a new one for this branch named `<<book.id>>.<<timestamp>>.<<branch.key>>`
805
805
  - validate the directory for data consistency (nice to have functionality)
806
806
  - collect the password and if invalid stop now
807
807
  - grab the lock file and write it to point it to our directory (we are it)
808
- - create our own intra-sessionary key and write it in within our folder
808
+ - create our own branch key and write it in within our folder
809
809
 
810
810
  ### Safe branch | HowTo
811
811
 
data/Rakefile CHANGED
@@ -14,3 +14,10 @@ end
14
14
 
15
15
  task :default => :test
16
16
 
17
+ require 'yard'
18
+ # This configuration allows us to run "rake yard"
19
+ # to build documentation.
20
+ YARD::Rake::YardocTask.new do |t|
21
+ t.files = ['lib/**/*.rb'] # optional
22
+ t.stats_options = ['--list-undoc']
23
+ end
data/bin/safe CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'openssl'
4
- require 'interprete'
4
+ require 'cli'
5
5
 
6
- Interprete.start(ARGV)
6
+ CLI.start(ARGV)
@@ -1,14 +1,13 @@
1
1
  require "thor"
2
2
  require "fileutils"
3
+ require "strscan"
3
4
 
4
- require "session/time.stamp"
5
- require "logging/gem.logging"
6
- require "session/require.gem"
7
-
5
+ require "utils/logs/logger"
6
+ require "controller/requirer"
8
7
 
9
8
  # Include the logger mixins so that every class can enjoy "import free"
10
9
  # logging through pointers to the (extended) log behaviour.
11
- include OpenLogger
10
+ include LogImpl
12
11
 
13
12
 
14
13
  # This standard out sync command flushes text destined for STDOUT immediately,
@@ -20,7 +19,7 @@ $stdout.sync = true
20
19
  # that this code is executing from. Only use this tool if your library is
21
20
  # relatively small but highly interconnected. In these instances it raises
22
21
  # productivity and reduces pesky "not found" exceptions.
23
- OpenSession::RecursivelyRequire.now( __FILE__ )
22
+ SafeDb::Require.gems( __FILE__ )
24
23
 
25
24
 
26
25
  # This command line processor extends the Thor gem CLI tools in order to
@@ -32,7 +31,7 @@ OpenSession::RecursivelyRequire.now( __FILE__ )
32
31
  # - ensure that the parameter values are in range
33
32
  # - delegate processing to the registered handlers
34
33
 
35
- class Interprete < Thor
34
+ class CLI < Thor
36
35
 
37
36
 
38
37
  log.info(x) { "request to interact with a safe book has been received." }
@@ -69,7 +68,7 @@ class Interprete < Thor
69
68
  # - either <tt>safe --version</tt>
70
69
  # - or <tt>safe version</tt>
71
70
  def version
72
- log.info(x) { "[usecase] ~> print the version of this safedb.net personal database." }
71
+ log.info(x) { "print the version of this safedb.net personal database." }
73
72
 
74
73
  puts ""
75
74
  puts "safedb gem version => v#{SafeDb::VERSION}"
@@ -82,25 +81,23 @@ class Interprete < Thor
82
81
 
83
82
 
84
83
 
85
- # Description of the init configuration call.
86
- desc "init <book_name> <storage_dir>", "initialize the safe book on this device"
84
+ # Description of the book initialize call.
85
+ desc "init <book_name> <storage_dir>", "initialize a new safe credentials book"
87
86
 
88
87
  # Use <tt>password</tt> if confident that either the command history is
89
88
  # inaccessible or the call originates from non-interactive software.
90
89
  option :password, :aliases => '-p'
91
90
 
92
- # Initialize the credentials manager, collect the human password and
93
- # manufacture the strong asymmetric public / private keypair.
91
+ # Initialize a safe credentials book with this name and collect the human sourced
92
+ # pasword to be put through key derivation functions.
94
93
  #
95
- # @param domain_name [String] the domain the software operates under
96
- # @param base_path [String] the path to the base operating directory
97
- def init( domain_name, base_path = nil )
98
- log.info(x) { "initialize the safe book on this device." }
94
+ # @param book_name [String] the name of the credentials book to be created
95
+ def init( book_name )
96
+ log.info(x) { "initialize a new safe credentials book called [#{book_name}]." }
99
97
  init_uc = SafeDb::Init.new
100
98
  init_uc.password = options[ :password ] if options[ :password ]
101
- init_uc.domain_name = domain_name
102
- init_uc.base_path = File.expand_path( base_path ) unless base_path.nil?
103
- init_uc.flow_of_events
99
+ init_uc.book_name = book_name
100
+ init_uc.flow()
104
101
  end
105
102
 
106
103
 
@@ -112,14 +109,14 @@ class Interprete < Thor
112
109
  # inaccessible or the call originates from non-interactive software.
113
110
  option :password, :aliases => '-p'
114
111
 
115
- # Login in order to securely interact with your data.
116
- # @param domain_name [String] the domain the software operates under
117
- def login( domain_name = nil )
118
- log.info(x) { "[usecase] ~> login to the book before interacting with it." }
112
+ # Login in order to securely interact with your safe credentials.
113
+ # @param book_name [String] the name of the credentials book to login to
114
+ def login( book_name = nil )
115
+ log.info(x) { "login to the safe credentials book called [#{book_name}]." }
119
116
  login_uc = SafeDb::Login.new
120
- login_uc.domain_name = domain_name unless domain_name.nil?
117
+ login_uc.book_name = book_name unless book_name.nil?
121
118
  login_uc.password = options[ :password ] if options[ :password ]
122
- login_uc.flow_of_events
119
+ login_uc.flow()
123
120
  end
124
121
 
125
122
 
@@ -132,10 +129,10 @@ class Interprete < Thor
132
129
  #
133
130
  # @param key_name [String] the key whose value is to be printed
134
131
  def print key_name
135
- log.info(x) { "[usecase] ~> print the key value at the opened chapter and verse." }
132
+ log.info(x) { "print the key value at the opened chapter and verse." }
136
133
  print_uc = SafeDb::Print.new
137
134
  print_uc.key_name = key_name
138
- print_uc.flow_of_events
135
+ print_uc.flow()
139
136
  end
140
137
 
141
138
 
@@ -145,21 +142,21 @@ class Interprete < Thor
145
142
 
146
143
  # Print the name of the verse at the opened chapter and verse location.
147
144
  def verse
148
- log.info(x) { "[usecase] ~> print the verse name at the opened chapter and verse." }
145
+ log.info(x) { "print the verse name at the opened chapter and verse." }
149
146
  verse_uc = SafeDb::Verse.new
150
- verse_uc.flow_of_events
147
+ verse_uc.flow()
151
148
  end
152
149
 
153
150
 
154
151
 
155
152
  # Description of the safe token use case.
156
- desc "token", "generate and print out an encrypted (shell bound) session token"
153
+ desc "token", "generate and print out an encrypted (shell bound) shell token"
157
154
 
158
- # The<b>token</b> use cases prints out an encrypted session token tied
155
+ # The<b>token</b> use cases prints out an encrypted shell token tied
159
156
  # to the workstation and shell environment.
160
157
  def token
161
- log.info(x) { "[usecase] ~> generate and print out an encrypted (shell bound) session token" }
162
- SafeDb::Token.new.flow_of_events
158
+ log.info(x) { "generate and print out an encrypted (shell bound) shell token" }
159
+ SafeDb::Token.new.flow()
163
160
  end
164
161
 
165
162
 
@@ -191,11 +188,67 @@ class Interprete < Thor
191
188
  # @param verse [String]
192
189
  # the verse of the logged in book and specified chapter to open
193
190
  def open chapter, verse
194
- log.info(x) { "[usecase] ~> open a chapter and verse to read from or write to." }
191
+ log.info(x) { "open a chapter and verse to read from or write to." }
195
192
  open_uc = SafeDb::Open.new
196
- open_uc.env_path = chapter
197
- open_uc.key_path = verse
198
- open_uc.flow_of_events
193
+ open_uc.chapter = chapter
194
+ open_uc.verse = verse
195
+ open_uc.flow()
196
+ end
197
+
198
+
199
+
200
+ # Description of the diff use case command from the point of view
201
+ # of either a checkout from master to branch, a checkin from branch
202
+ # to master or a diff listing prophesying about both.
203
+ desc "diff", "master and branch diff with --checkin (-i), --checkout (-o) or both."
204
+
205
+ # A checkin is basically a copy-overwrite operation which does not finesse
206
+ # like the merging checkout does. The diff report illustrates that the master
207
+ # will essentially reflect the working branch's current state.
208
+ method_option :checkin, :type => :boolean, :aliases => "-i"
209
+
210
+ # A checkout is effectively an incoming merge of the master's data
211
+ # structure into the working branch. With checkouts nothing ever gets
212
+ # deleted.
213
+ method_option :checkout, :type => :boolean, :aliases => "-o"
214
+
215
+ # The <b>diff use case</b> spells out the key differences between the safe book
216
+ # on the master line the one on the current working branch.
217
+ #
218
+ # By default when conflicts occur, priority is given to the current working branch.
219
+ # No parameters are required to perform a diff.
220
+ def diff
221
+ log.info(x) { "prophesy list of checkout and/or checkin actions. CLI options are #{options.to_s()}" }
222
+ diff_uc = SafeDb::Diff.new()
223
+ diff_uc.checkin = true if options[ :checkin ]
224
+ diff_uc.checkout = true if options[ :checkout ]
225
+ diff_uc.flow()
226
+ end
227
+
228
+
229
+
230
+ # Description of the checkin use case command.
231
+ desc "checkin", "commit (save) the branch changes by putting them into master."
232
+
233
+ # The <b>checkin use case</b> commits any changes made to the safe book into
234
+ # master. This is straightforward if the master's state has not been forwarded
235
+ # by a ckeckin from another (shell) branch.
236
+ def checkin
237
+ log.info(x) { "commit (save) any changes made to this branch into the master." }
238
+ SafeDb::CheckIn.new.flow()
239
+ end
240
+
241
+
242
+
243
+ # Description of the checkout use case command.
244
+ desc "checkout", "refresh (update) the working branch with changes from the master."
245
+
246
+ # The <b>checkout use case</b> commits any changes made to the safe book into
247
+ # master. This is straightforward if the master's state has not been forwarded
248
+ # by a ckeckin from another (shell) branch.
249
+ def checkout
250
+ log.info(x) { "refresh (update) the working branch with changes from the master." }
251
+ SafeDb::CheckOut.new.flow()
199
252
  end
200
253
 
201
254
 
@@ -207,117 +260,111 @@ class Interprete < Thor
207
260
  # The --print flag demands that the exported text goes to stdout otherwise it
208
261
  # will be placed in an aptly named file in the present working directory.
209
262
  def export
210
- log.info(x) { "[usecase] ~> export book chapter content or dictionary at verse in JSON format." }
211
- SafeDb::Export.new.flow_of_events
263
+ log.info(x) { "export book chapter content or dictionary at verse in JSON format." }
264
+ SafeDb::Export.new.flow()
212
265
  end
213
266
 
214
267
 
215
268
 
216
- # Description of the put secret command.
217
- desc "put <key> <value>", "put key/value pair into dictionary at open chapter and verse"
269
+ # Description of the import use case command.
270
+ desc "import", "imports the contents of the parameter json file into this book."
218
271
 
219
- # Put a secret with an id like login/username and a value like joebloggs into the
220
- # context (eg work/laptop) that was opened with the open command.
221
- #
222
- # @param secret_id [String] the id of the secret to put into the opened context
223
- # @param secret_value [String] the value of the secret to put into the opened context
224
- def put secret_id, secret_value
225
- log.info(x) { "[usecase] ~> put key/value pair into dictionary at open chapter and verse." }
226
- put_uc = SafeDb::Put.new
227
- put_uc.secret_id = secret_id
228
- put_uc.secret_value = secret_value
229
- put_uc.flow_of_events
272
+ # The <b>import use case</b> takes a filepath parameter in order to pull in
273
+ # a <em>json</em> formatted data structure.
274
+ # @param import_filepath [String] the path to the JSON file that we will import
275
+ def import import_filepath
276
+ log.info(x) { "importing into current book from file #{import_filepath}." }
277
+ import_uc = SafeDb::Import.new
278
+ import_uc.import_filepath = import_filepath
279
+ import_uc.flow()
230
280
  end
231
281
 
232
282
 
233
283
 
234
- # Description of the file command.
235
- desc "file <file_key> <file_url>", "ingest a file into the safe from the filesystem (or S3, ssh, Google Drive)"
284
+ # Description of the put secret command.
285
+ desc "put <key> <value>", "put key/value pair into dictionary at open chapter and verse"
236
286
 
237
- # The <b>file use case</b> pulls a read in from either an accessible readsystem
238
- # or from a remote http, https, git, S3, GoogleDrive and/or ssh source.
287
+ # Put a secret with an id like login/username and a value like joebloggs into the
288
+ # context (eg work/laptop) that was opened with the open command.
239
289
  #
240
- # @param file_key [String] keyname representing the file that is being read in
241
- # @param file_url [String] url of file to ingest and assimilate into the safe
242
- def file file_key, file_url
243
- log.info(x) { "[usecase] ~> file read against key [[ #{file_key} ]]" }
244
- log.info(x) { "[usecase] ~> file read from url [[ #{file_url} ]]" }
245
- file_uc = SafeDb::FileMe.new
246
- file_uc.file_key = file_key
247
- file_uc.file_url = file_url
248
- file_uc.flow_of_events
290
+ # @param credential_id [String] the id of the secret to put into the opened context
291
+ # @param credential_value [String] the value of the secret to put into the opened context
292
+ def put credential_id, credential_value
293
+ log.info(x) { "put key/value pair into dictionary at open chapter and verse." }
294
+ put_uc = SafeDb::Put.new
295
+ put_uc.credential_id = credential_id
296
+ put_uc.credential_value = credential_value
297
+ put_uc.flow()
249
298
  end
250
299
 
251
300
 
252
301
 
253
- # Description of the eject command.
254
- desc "eject <file_key>", "write out ingested file at chapter/verse with specified file key"
302
+ # Description of the set configuration directives command.
303
+ desc "set <directive_name> <directive_value>", "set book-scoped configuration directive"
255
304
 
256
- # The <b>eject use case</b> writes out a file that was previously ingested
257
- # and coccooned inside the safe typically with the file command.
305
+ # The <b>set <em>use case</em></b> is the generic tool for setting book scoped
306
+ # configuration directives. These directives can only be read, written, updated
307
+ # or removed during a logged in branch.
258
308
  #
259
- # @param file_key [String] the key that the file was ingested against
260
- def eject file_key
261
- log.info(x) { "[usecase] ~> eject file at chapter/verse against specified key." }
262
- eject_uc = SafeDb::Eject.new
263
- eject_uc.file_key = file_key
264
- eject_uc.to_dir = options[:to_dir] if options[:to_dir]
265
- eject_uc.flow_of_events
309
+ # @param directive_name [String] the name of the book-scoped configuration directive
310
+ # @param directive_value [String] the value of the book-scoped configuration directive
311
+ def set directive_name, directive_value
312
+ log.info(x) { "set the configuration directive value for #{directive_name}" }
313
+ set_uc = SafeDb::Set.new
314
+ set_uc.directive_name = directive_name
315
+ set_uc.directive_value = directive_value
316
+ set_uc.flow()
266
317
  end
267
318
 
268
319
 
269
320
 
270
- # Description of the delete command.
271
- desc "delete <entity_id>", "delete a line (key/value pair), or a verse, chapter and even a book"
321
+ # Description of the remove command.
322
+ desc "remove <line_id>", "remove a line (key/value pair), or a verse, chapter and even a book"
272
323
 
273
- # The <b>delete use case</b> can delete a single line (key/value pair), or
324
+ # The <b>remove use case</b> can remove a single line (key/value pair), or
274
325
  # a verse, chapter and even a book
275
326
  #
276
- # @param entity_id [String] the ID of the entity to delete (line, verse, chapter or book)
277
- def delete entity_id
278
- log.info(x) { "[usecase] ~> delete a safe entity with a key id [#{entity_id}]." }
279
- delete_uc = SafeDb::DeleteMe.new
280
- delete_uc.entity_id = entity_id
281
- delete_uc.flow_of_events
327
+ # @param line_id [String] the ID of the entity to remove (line, verse, chapter or book)
328
+ def remove line_id
329
+ log.info(x) { "remove a safe entity with a key id [#{line_id}]." }
330
+ remove_uc = SafeDb::Remove.new()
331
+ remove_uc.line_id = line_id
332
+ remove_uc.flow()
282
333
  end
283
334
 
284
335
 
285
336
 
286
337
  # Description of the read command.
287
- desc "read <file_url>", "read (reread) file either locally or via http, git or ssh"
338
+ desc "read <file_url>", "read file into the open chapter and verse for safe keeping."
288
339
 
289
- # The <b>read use case</b> pulls a read in from either an accessible readsystem
290
- # or from a remote http, https, git, S3, GoogleDrive and/or ssh source.
291
- #
292
- # This use case expects a @file_url parameter. The actions it takes are to
293
- #
294
- # - register @in.url to mirror @file_url
295
- # - register @out.url to mirror @file_url
296
- # - check the location of @file_url
297
- # - if no file exists it humbly finishes up
340
+ # The <b>read use case</b> pulls a file in from either an accessible filesystem.
298
341
  #
342
+ # @param file_key [String] keyname representing the file that is being read in
299
343
  # @param file_url [String] url of file to ingest and assimilate into the safe
300
- def read file_url
301
- log.info(x) { "[usecase] ~> read (reread) file from optional url [[ #{file_url} ]]" }
344
+ def read file_key, file_url
345
+ log.info(x) { "read file into key #{file_key} from url #{file_url}" }
302
346
  read_uc = SafeDb::Read.new
347
+ read_uc.file_key = file_key
303
348
  read_uc.file_url = file_url
304
- read_uc.flow_of_events
349
+ read_uc.flow()
305
350
  end
306
351
 
307
352
 
308
353
 
309
354
  # Description of the write command.
310
- desc "write <file_url>", "write out file at chapter/verse to (optional) file url"
355
+ desc "write <file_key>", "write out file to current folder or use --to_dir=</path/to/dir."
311
356
 
312
357
  # The <b>write use case</b> writes out a file that was previously ingested
313
358
  # and coccooned inside the safe.
314
359
  #
315
- # @param file_url [String] optional file url marking where to write the file
316
- def write( file_url = nil )
317
- log.info(x) { "[usecase] ~> write out file at chapter/verse to (optional) file url." }
360
+ # @param file_key [String] the key name of the file to write out onto the filesystem
361
+ def write( file_key )
362
+ log.info(x) { "write out the file against key #{file_key}" }
363
+ log.info(x) { "output folder optionally set to #{options[:to_dir]}" } if options[:to_dir]
318
364
  write_uc = SafeDb::Write.new
319
- write_uc.file_url = file_url if file_url
320
- write_uc.flow_of_events
365
+ write_uc.file_key = file_key
366
+ write_uc.to_dir = options[:to_dir] if options[:to_dir]
367
+ write_uc.flow()
321
368
  end
322
369
 
323
370
 
@@ -328,8 +375,8 @@ class Interprete < Thor
328
375
  # Show the secrets at the opened path. These secrets
329
376
  # are simply written out to the shell console.
330
377
  def show
331
- log.info(x) { "[usecase] ~> show dictionary at the opened chapter and verse." }
332
- SafeDb::Show.new.flow_of_events
378
+ log.info(x) { "show dictionary at the opened chapter and verse." }
379
+ SafeDb::Show.new.flow()
333
380
  end
334
381
 
335
382
 
@@ -340,9 +387,9 @@ class Interprete < Thor
340
387
  # Display a bird's eye view of the domain's database including
341
388
  # its envelopes, their keys and imported objects such as files.
342
389
  def view
343
- log.info(x) { "[usecase] ~> print list of chapter and verse combos to console." }
390
+ log.info(x) { "print list of chapter and verse combos to console." }
344
391
  view_uc = SafeDb::View.new
345
- view_uc.flow_of_events
392
+ view_uc.flow()
346
393
  end
347
394
 
348
395
 
@@ -356,10 +403,10 @@ class Interprete < Thor
356
403
  # @param index [Number]
357
404
  # the integer index chosen from the list procured by the view command.
358
405
  def goto index
359
- log.info(x) { "[usecase] ~> opens the chapter and verse at index [#{index}]." }
406
+ log.info(x) { "opens the chapter and verse at index [#{index}]." }
360
407
  goto_uc = SafeDb::Goto.new
361
408
  goto_uc.index = index
362
- goto_uc.flow_of_events
409
+ goto_uc.flow()
363
410
 
364
411
  end
365
412
 
@@ -385,10 +432,10 @@ class Interprete < Thor
385
432
  # the terraform command to run which is currently limited to plan, apply and destroy.
386
433
  # This parameter is optional and if nothing is given then "apply" is assumed.
387
434
  def terraform( command = nil )
388
- log.info(x) { "[usecase] ~> will export IAM credentials then invoke $ terraform #{command}" }
435
+ log.info(x) { "will export IAM credentials then invoke $ terraform #{command}" }
389
436
  terraform_uc = SafeDb::Terraform.new
390
437
  terraform_uc.command = command if command
391
- terraform_uc.flow_of_events
438
+ terraform_uc.flow()
392
439
  end
393
440
 
394
441
 
@@ -422,14 +469,14 @@ class Interprete < Thor
422
469
  #
423
470
  def jenkins( command, service, url )
424
471
 
425
- log.info(x) { "[usecase] ~> request to #{command} #{service} credentials to Jenkins at #{url}" }
472
+ log.info(x) { "request to #{command} #{service} credentials to Jenkins at #{url}" }
426
473
  jenkins_uc = SafeDb::Jenkins.new
427
474
 
428
475
  jenkins_uc.command = command if command
429
476
  jenkins_uc.service = service if service
430
477
  jenkins_uc.url = url if url
431
478
 
432
- jenkins_uc.flow_of_events
479
+ jenkins_uc.flow()
433
480
 
434
481
  end
435
482
 
@@ -448,10 +495,10 @@ class Interprete < Thor
448
495
  # login or logout
449
496
  def docker( command = "login" )
450
497
 
451
- log.info(x) { "[usecase] ~> request to #{command} into or out of a docker repository." }
498
+ log.info(x) { "request to #{command} into or out of a docker repository." }
452
499
  docker_uc = SafeDb::Docker.new
453
500
  docker_uc.command = command
454
- docker_uc.flow_of_events
501
+ docker_uc.flow()
455
502
 
456
503
  end
457
504
 
@@ -461,16 +508,16 @@ class Interprete < Thor
461
508
  desc "vpn <command>", "runs vpn command typically safe vpn up or safe vpn down"
462
509
 
463
510
  # This VPN use case connects to the VPN whose specifics are recorded within the vpn.ini
464
- # factfile living in the same directory as the vpn.rb usecase class.
511
+ # factfile living in the same directory as the vpn.rb controlling class.
465
512
  #
466
513
  # @param command [String]
467
514
  # the vpn command to run which is currently limited to up or down
468
515
  # This parameter is optional and if nothing is given then "up" is assumed.
469
516
  def vpn( command = nil )
470
- log.info(x) { "[usecase] ~> VPN connection command #{command} has been issued." }
517
+ log.info(x) { "VPN connection command #{command} has been issued." }
471
518
  vpn_uc = SafeDb::Vpn.new
472
519
  vpn_uc.command = command if command
473
- vpn_uc.flow_of_events
520
+ vpn_uc.flow()
474
521
  end
475
522
 
476
523
 
@@ -480,9 +527,9 @@ class Interprete < Thor
480
527
 
481
528
  # Put out the multiple formats of the current timestamp.
482
529
  def id
483
- log.info(x) { "[usecase] ~> prints out the current timestamp identifiers." }
530
+ log.info(x) { "prints out the current timestamp identifiers." }
484
531
  id_uc = SafeDb::Id.new
485
- id_uc.flow_of_events
532
+ id_uc.flow()
486
533
  end
487
534
 
488
535