safedb 0.5.1005 → 0.7.1001
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +1 -1
- data/genius-decision.txt +25 -0
- data/lib/cli.rb +155 -8
- data/lib/controller/{admin/auth.rb → abstract/authenticate.rb} +1 -2
- data/lib/controller/{controller.rb → abstract/controller.rb} +45 -24
- data/lib/controller/{edit/editverse.rb → abstract/edit_verse.rb} +0 -0
- data/lib/controller/{query/queryverse.rb → abstract/query_verse.rb} +0 -0
- data/lib/controller/{admin → access}/README.md +0 -0
- data/lib/controller/access/banner.txt +6 -0
- data/lib/controller/{admin → access}/init.rb +4 -4
- data/lib/controller/{admin → access}/login.rb +28 -23
- data/lib/controller/{admin → access}/logout.rb +0 -0
- data/lib/controller/{admin → access}/token.rb +0 -0
- data/lib/controller/{admin → access}/use.rb +0 -0
- data/lib/controller/api/docker/docker.rb +4 -22
- data/lib/controller/api/git/git.rb +104 -0
- data/lib/controller/api/terraform/README.md +23 -2
- data/lib/controller/api/terraform/terraform.rb +38 -7
- data/lib/controller/{admin → book}/commit.rb +2 -3
- data/lib/controller/{admin → book}/diff.rb +0 -0
- data/lib/controller/{admin → book}/export.rb +0 -0
- data/lib/controller/{admin → book}/import.rb +0 -0
- data/lib/controller/{admin → book}/refresh.rb +2 -2
- data/lib/controller/{admin → book}/view.rb +0 -0
- data/lib/{modules/storage/git.store.rb → controller/db/model_git_service.rb} +0 -0
- data/lib/controller/db/pull.rb +69 -0
- data/lib/controller/db/push.rb +352 -0
- data/lib/controller/db/remote.rb +108 -0
- data/lib/controller/edit/generate.rb +1 -1
- data/lib/controller/edit/keys.rb +72 -0
- data/lib/controller/edit/paste.rb +36 -0
- data/lib/controller/files/write.rb +11 -3
- data/lib/controller/misc/wipe.rb +23 -0
- data/lib/controller/navigate/at.rb +42 -0
- data/lib/controller/{admin → navigate}/goto.rb +0 -0
- data/lib/controller/{admin → navigate}/open.rb +0 -0
- data/lib/controller/query/copy.rb +32 -95
- data/lib/controller/query/tell.rb +36 -0
- data/lib/controller/requirer.rb +4 -4
- data/lib/controller/visit/README.md +34 -0
- data/lib/controller/visit/visit.rb +33 -0
- data/lib/manual/copy-paste.md +19 -2
- data/lib/{modules/README.md → manual/crypto-math.md} +0 -0
- data/lib/manual/push-pull.md +46 -0
- data/lib/manual/remote.md +62 -0
- data/lib/model/coordinates.rb +59 -0
- data/lib/model/{safe_tree.rb → file_tree.rb} +11 -6
- data/lib/model/indices.rb +113 -8
- data/lib/model/master.rb +40 -0
- data/lib/model/{state.migrate.rb → state_evolve.rb} +13 -5
- data/lib/model/{state.inspect.rb → state_query.rb} +5 -1
- data/lib/plugin/github.rb +53 -0
- data/lib/{modules/cryptology → utils/ciphers}/aes-256.rb +0 -0
- data/lib/{modules/cryptology → utils/ciphers}/blowfish.rb +0 -0
- data/lib/{modules/cryptology → utils/ciphers}/cipher.rb +0 -0
- data/lib/{modules/cryptology → utils/ciphers}/crypt.io.rb +0 -0
- data/lib/utils/keys/key.rb +44 -0
- data/lib/utils/keys/keypair.rb +52 -0
- data/lib/utils/logs/logger.rb +1 -1
- data/lib/utils/store/datastore.rb +1 -1
- data/lib/utils/store/github.rb +27 -0
- data/lib/utils/time/timestamp.rb +91 -0
- data/lib/version.rb +1 -1
- data/safedb.gemspec +2 -0
- metadata +75 -32
- data/lib/controller/verse.rb +0 -20
- data/lib/modules/storage/coldstore.rb +0 -186
- data/lib/utils/store/test-commands.sh +0 -24
data/lib/utils/time/timestamp.rb
CHANGED
@@ -107,6 +107,15 @@ module SafeDb
|
|
107
107
|
end
|
108
108
|
|
109
109
|
|
110
|
+
#
|
111
|
+
# Return the [one] digit year (eg 9 for 2019).
|
112
|
+
# that we are currently in.
|
113
|
+
#
|
114
|
+
def self.y
|
115
|
+
return TimeStamp.instance.time_now.strftime("%Y")[3..-1]
|
116
|
+
end
|
117
|
+
|
118
|
+
|
110
119
|
#
|
111
120
|
# Return the [four] digit year (eg 2019)
|
112
121
|
# that we are currently in.
|
@@ -214,6 +223,13 @@ module SafeDb
|
|
214
223
|
end
|
215
224
|
|
216
225
|
|
226
|
+
# Return 4 digit amalgam of year and julian day.
|
227
|
+
# eg [9003] for [January 3rd 2019]
|
228
|
+
def self.yjjj
|
229
|
+
return "#{y}#{jjj}"
|
230
|
+
end
|
231
|
+
|
232
|
+
|
217
233
|
# Return the 4 digit amalgam of the hour and minute
|
218
234
|
# using the 24 hour clock.
|
219
235
|
#
|
@@ -282,6 +298,81 @@ module SafeDb
|
|
282
298
|
end
|
283
299
|
|
284
300
|
|
301
|
+
# Return the time of day to a TENTH of a second accuracy
|
302
|
+
# via a string timestamp with zero separation.
|
303
|
+
#
|
304
|
+
# The timestampt returned is an amalgam of
|
305
|
+
#
|
306
|
+
# - a 2 digit year
|
307
|
+
# - a 3 digit julian day
|
308
|
+
# - a 2 digit hourn
|
309
|
+
# - a 2 digit minute
|
310
|
+
# - a 2 digit second and finally
|
311
|
+
# - a 1 digit (rounded down) tenth of a second
|
312
|
+
#
|
313
|
+
# The 3 digits of the second segment comprise of
|
314
|
+
#
|
315
|
+
# - second of minute => 2 digits | [00] to [59]
|
316
|
+
# - tenth of second => 1 digit from [0] to [9]
|
317
|
+
#
|
318
|
+
# @example
|
319
|
+
# => The time at the 562nd millisecond of the 49th
|
320
|
+
# second of the 23rd minute of the 17th hour of
|
321
|
+
# the day ( 17:23:49.562 )
|
322
|
+
#
|
323
|
+
# => 8 chars
|
324
|
+
# => 1723.495
|
325
|
+
#
|
326
|
+
def self.yyjjjhhmmsst
|
327
|
+
return "#{yyjjj}#{hhmm}#{sst}"
|
328
|
+
end
|
329
|
+
|
330
|
+
|
331
|
+
# Return the time of day to a TENTH of a second accuracy
|
332
|
+
# via a string timestamp with zero separation.
|
333
|
+
#
|
334
|
+
# The timestampt returned is an amalgam of
|
335
|
+
#
|
336
|
+
# - a 1 digit year
|
337
|
+
# - a 3 digit julian day
|
338
|
+
# - a 2 digit hourn
|
339
|
+
# - a 2 digit minute
|
340
|
+
# - a 2 digit second and finally
|
341
|
+
# - a 1 digit (rounded down) tenth of a second
|
342
|
+
#
|
343
|
+
# The 3 digits of the second segment comprise of
|
344
|
+
#
|
345
|
+
# - second of minute => 2 digits | [00] to [59]
|
346
|
+
# - tenth of second => 1 digit from [0] to [9]
|
347
|
+
#
|
348
|
+
# @example
|
349
|
+
# => The time at the 562nd millisecond of the 49th
|
350
|
+
# second of the 23rd minute of the 17th hour of
|
351
|
+
# the day ( 72349562 )
|
352
|
+
#
|
353
|
+
# => 8 chars
|
354
|
+
# => 1723.495
|
355
|
+
#
|
356
|
+
def self.yjjjhhmmsst
|
357
|
+
return "#{yjjj}#{hhmm}#{sst}"
|
358
|
+
end
|
359
|
+
|
360
|
+
|
361
|
+
# Return the time of day to a single minute accuracy
|
362
|
+
# via a string timestamp with zero separation.
|
363
|
+
#
|
364
|
+
# The timestampt returned is an amalgam of
|
365
|
+
#
|
366
|
+
# - a 2 digit year
|
367
|
+
# - a 3 digit julian day
|
368
|
+
# - a 2 digit hourn
|
369
|
+
# - a 2 digit minute
|
370
|
+
#
|
371
|
+
def self.yyjjjhhmm
|
372
|
+
return "#{yyjjj}#{hhmm}"
|
373
|
+
end
|
374
|
+
|
375
|
+
|
285
376
|
# Return a string timestampt that is a period separated
|
286
377
|
# amalgam of the 2 digit year, 3 digit julian day, 2 digit
|
287
378
|
# hour, 2 digit minute, 2 digit second and <b>9 digit</b>
|
data/lib/version.rb
CHANGED
data/safedb.gemspec
CHANGED
@@ -28,6 +28,8 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_dependency 'bcrypt', '~> 3.1'
|
29
29
|
spec.add_dependency 'thor', '~> 0.20'
|
30
30
|
spec.add_dependency 'inifile', '~> 3.0'
|
31
|
+
spec.add_dependency 'octokit', '~> 4.14'
|
32
|
+
spec.add_dependency 'net-ssh', '~> 5.2'
|
31
33
|
|
32
34
|
spec.add_development_dependency "bundler", "~> 0"
|
33
35
|
spec.add_development_dependency "cucumber", "~> 2.0"
|
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.
|
4
|
+
version: 0.7.1001
|
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-
|
11
|
+
date: 2019-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bcrypt
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: octokit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.14'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.14'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: net-ssh
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.2'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.2'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: bundler
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,24 +155,22 @@ files:
|
|
127
155
|
- README.md
|
128
156
|
- Rakefile
|
129
157
|
- bin/safe
|
158
|
+
- genius-decision.txt
|
130
159
|
- lib/cli.rb
|
131
|
-
- lib/controller/
|
132
|
-
- lib/controller/
|
133
|
-
- lib/controller/
|
134
|
-
- lib/controller/
|
135
|
-
- lib/controller/
|
136
|
-
- lib/controller/
|
137
|
-
- lib/controller/
|
138
|
-
- lib/controller/
|
139
|
-
- lib/controller/
|
140
|
-
- lib/controller/
|
141
|
-
- lib/controller/
|
142
|
-
- lib/controller/admin/refresh.rb
|
143
|
-
- lib/controller/admin/token.rb
|
144
|
-
- lib/controller/admin/use.rb
|
145
|
-
- lib/controller/admin/view.rb
|
160
|
+
- lib/controller/abstract/authenticate.rb
|
161
|
+
- lib/controller/abstract/controller.rb
|
162
|
+
- lib/controller/abstract/edit_verse.rb
|
163
|
+
- lib/controller/abstract/query_verse.rb
|
164
|
+
- lib/controller/access/README.md
|
165
|
+
- lib/controller/access/banner.txt
|
166
|
+
- lib/controller/access/init.rb
|
167
|
+
- lib/controller/access/login.rb
|
168
|
+
- lib/controller/access/logout.rb
|
169
|
+
- lib/controller/access/token.rb
|
170
|
+
- lib/controller/access/use.rb
|
146
171
|
- lib/controller/api/docker/README.md
|
147
172
|
- lib/controller/api/docker/docker.rb
|
173
|
+
- lib/controller/api/git/git.rb
|
148
174
|
- lib/controller/api/jenkins/README.md
|
149
175
|
- lib/controller/api/jenkins/jenkins.rb
|
150
176
|
- lib/controller/api/terraform/README.md
|
@@ -152,11 +178,21 @@ files:
|
|
152
178
|
- lib/controller/api/vpn/README.md
|
153
179
|
- lib/controller/api/vpn/vpn.ini
|
154
180
|
- lib/controller/api/vpn/vpn.rb
|
181
|
+
- lib/controller/book/commit.rb
|
182
|
+
- lib/controller/book/diff.rb
|
183
|
+
- lib/controller/book/export.rb
|
184
|
+
- lib/controller/book/import.rb
|
185
|
+
- lib/controller/book/refresh.rb
|
186
|
+
- lib/controller/book/view.rb
|
155
187
|
- lib/controller/config/README.md
|
156
|
-
- lib/controller/
|
188
|
+
- lib/controller/db/model_git_service.rb
|
189
|
+
- lib/controller/db/pull.rb
|
190
|
+
- lib/controller/db/push.rb
|
191
|
+
- lib/controller/db/remote.rb
|
157
192
|
- lib/controller/edit/README.md
|
158
|
-
- lib/controller/edit/editverse.rb
|
159
193
|
- lib/controller/edit/generate.rb
|
194
|
+
- lib/controller/edit/keys.rb
|
195
|
+
- lib/controller/edit/paste.rb
|
160
196
|
- lib/controller/edit/put.rb
|
161
197
|
- lib/controller/edit/remove.rb
|
162
198
|
- lib/controller/edit/rename.md
|
@@ -165,38 +201,44 @@ files:
|
|
165
201
|
- lib/controller/files/read.rb
|
166
202
|
- lib/controller/files/write.rb
|
167
203
|
- lib/controller/id.rb
|
204
|
+
- lib/controller/misc/wipe.rb
|
205
|
+
- lib/controller/navigate/at.rb
|
206
|
+
- lib/controller/navigate/goto.rb
|
207
|
+
- lib/controller/navigate/open.rb
|
168
208
|
- lib/controller/query/copy.rb
|
169
209
|
- lib/controller/query/print.rb
|
170
|
-
- lib/controller/query/queryverse.rb
|
171
210
|
- lib/controller/query/show.rb
|
211
|
+
- lib/controller/query/tell.rb
|
172
212
|
- lib/controller/requirer.rb
|
173
213
|
- lib/controller/set.rb
|
174
|
-
- lib/controller/verse.rb
|
175
214
|
- lib/controller/visit/README.md
|
176
215
|
- lib/controller/visit/visit.rb
|
177
216
|
- lib/factbase/facts.safedb.net.ini
|
178
217
|
- lib/manual/copy-paste.md
|
218
|
+
- lib/manual/crypto-math.md
|
179
219
|
- lib/manual/dir-structure.md
|
180
220
|
- lib/manual/drag-drop.md
|
181
221
|
- lib/manual/login-logout.md
|
222
|
+
- lib/manual/push-pull.md
|
223
|
+
- lib/manual/remote.md
|
182
224
|
- lib/model/README.md
|
183
225
|
- lib/model/book.rb
|
184
226
|
- lib/model/branch.rb
|
185
227
|
- lib/model/checkin.feature
|
186
228
|
- lib/model/configs.md
|
187
229
|
- lib/model/content.rb
|
230
|
+
- lib/model/coordinates.rb
|
231
|
+
- lib/model/file_tree.rb
|
188
232
|
- lib/model/indices.rb
|
189
|
-
- lib/model/
|
190
|
-
- lib/model/
|
191
|
-
- lib/model/
|
233
|
+
- lib/model/master.rb
|
234
|
+
- lib/model/state_evolve.rb
|
235
|
+
- lib/model/state_query.rb
|
192
236
|
- lib/model/text_chunk.rb
|
193
|
-
- lib/
|
194
|
-
- lib/
|
195
|
-
- lib/
|
196
|
-
- lib/
|
197
|
-
- lib/
|
198
|
-
- lib/modules/storage/coldstore.rb
|
199
|
-
- lib/modules/storage/git.store.rb
|
237
|
+
- lib/plugin/github.rb
|
238
|
+
- lib/utils/ciphers/aes-256.rb
|
239
|
+
- lib/utils/ciphers/blowfish.rb
|
240
|
+
- lib/utils/ciphers/cipher.rb
|
241
|
+
- lib/utils/ciphers/crypt.io.rb
|
200
242
|
- lib/utils/clipboard/clip.rb
|
201
243
|
- lib/utils/extend/array.rb
|
202
244
|
- lib/utils/extend/dir.rb
|
@@ -216,15 +258,16 @@ files:
|
|
216
258
|
- lib/utils/key.pass.rb
|
217
259
|
- lib/utils/keys/key.64.rb
|
218
260
|
- lib/utils/keys/key.rb
|
261
|
+
- lib/utils/keys/keypair.rb
|
219
262
|
- lib/utils/keys/random.iv.rb
|
220
263
|
- lib/utils/logs/logger.rb
|
221
264
|
- lib/utils/store/datamap.rb
|
222
265
|
- lib/utils/store/datastore.rb
|
266
|
+
- lib/utils/store/github.rb
|
223
267
|
- lib/utils/store/merge-boys-school.json
|
224
268
|
- lib/utils/store/merge-girls-school.json
|
225
269
|
- lib/utils/store/merge-merged-data.json
|
226
270
|
- lib/utils/store/struct.rb
|
227
|
-
- lib/utils/store/test-commands.sh
|
228
271
|
- lib/utils/time/timestamp.rb
|
229
272
|
- lib/version.rb
|
230
273
|
- safedb.gemspec
|
data/lib/controller/verse.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
|
3
|
-
module SafeDb
|
4
|
-
|
5
|
-
class Verse < Controller
|
6
|
-
|
7
|
-
def execute
|
8
|
-
|
9
|
-
return unless ops_key_exists?
|
10
|
-
master_db = get_master_database()
|
11
|
-
return if unopened_envelope?( master_db )
|
12
|
-
print master_db[ KEY_PATH ]
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
end
|
@@ -1,186 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
# coding: utf-8
|
3
|
-
|
4
|
-
module SafeDb
|
5
|
-
|
6
|
-
module Store
|
7
|
-
|
8
|
-
# Cold storage can sync repositories with a <b>bias during conflicts</b>
|
9
|
-
# either to the <em>remote repository</em> <b>when pulling</b>, and then
|
10
|
-
# conversely to the <em>local reposiory</em> <b>when pushing</b>.
|
11
|
-
#
|
12
|
-
# In between the sync operations a ColdStore can create, read, update and
|
13
|
-
# delete to and from the local mirror.
|
14
|
-
#
|
15
|
-
# == ColdStore | Use Cases
|
16
|
-
#
|
17
|
-
# Any <b>self-respecting coldstore</b> must, after initialization, provide
|
18
|
-
# some basic (and mandatory) behaviour.
|
19
|
-
#
|
20
|
-
# These include
|
21
|
-
#
|
22
|
-
# - <b>read</b> - reading text from a (possibly unavailable) frozen path
|
23
|
-
# - <b>write</b> - writing text (effectively freezing it) to a path
|
24
|
-
# - <b>pull</b> - sync with a <b>collision bias</b> that favours the remote mirror
|
25
|
-
# - <b>push</b> - sync with a <b>collision bias</b> that favours the local mirror
|
26
|
-
#
|
27
|
-
# <b>Cold Storage</b> is borrowed from BitCoin and represents offline storage
|
28
|
-
# for keys and crypts. safe separates keys and crypts so that you can
|
29
|
-
# transfer and share secrets by moving keys (not the crypts).
|
30
|
-
#
|
31
|
-
# == Houses and Gold Bullion
|
32
|
-
#
|
33
|
-
# You don't carry houses or gold bullion around to rent, share or transfer
|
34
|
-
# their ownership.
|
35
|
-
#
|
36
|
-
# You copy keys to rent secrets and when the tenure is up (or you change your
|
37
|
-
# mind) you revoke access with a metaphorical lock change.
|
38
|
-
#
|
39
|
-
# safe embodies concepts like an owner who rents as opposed to a change
|
40
|
-
# in ownership.
|
41
|
-
#
|
42
|
-
# == trade secrets | commoditizing secrets
|
43
|
-
#
|
44
|
-
# safe is a conduit through which secrets can be bought and sold.
|
45
|
-
#
|
46
|
-
# It commoditizes secrets so that they can be owned, traded, leased and
|
47
|
-
# auctioned. Options to acquire or relinquish them at set prices can easily
|
48
|
-
# be taken out.
|
49
|
-
class ColdStore
|
50
|
-
|
51
|
-
# @param base_path [String]
|
52
|
-
# path to the store's (mirror) base directory.
|
53
|
-
# If the denoted directory does not exist an attempt will be made to
|
54
|
-
# create it. If a file exists at this path an error will be thrown.
|
55
|
-
#
|
56
|
-
# @param domain [String]
|
57
|
-
# the domain is an identifier (and namespace) denoting which safe
|
58
|
-
# "account" is being accessed. safe allows the creation and use of
|
59
|
-
# multiple domains.
|
60
|
-
def initialize local_path
|
61
|
-
|
62
|
-
@store_path = local_path
|
63
|
-
FileUtils.mkdir_p @store_path
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
# Read the file frozen (in this store mirror) at this path and
|
69
|
-
# return its contents.
|
70
|
-
#
|
71
|
-
# Coldstores are usually frozen offline (offmachine) so for this
|
72
|
-
# to work the {ColdStore.pull} behaviour must have executed to
|
73
|
-
# create a local store mirror. This method reads from that mirror.
|
74
|
-
#
|
75
|
-
# @param from_path [String]
|
76
|
-
# read the file frozen at this path and return its contents
|
77
|
-
# so that the defreeze process can begin.
|
78
|
-
#
|
79
|
-
# This path is relative to the base of the store defined in
|
80
|
-
# the constructor.
|
81
|
-
#
|
82
|
-
# @return [String]
|
83
|
-
# return the text frozen in a file at the denoted local path
|
84
|
-
#
|
85
|
-
# nil is reurned if no file can be found in the local mirror
|
86
|
-
# at the configured path
|
87
|
-
#
|
88
|
-
# @raise [RuntimeError]
|
89
|
-
# unless the path exists in this coldstore and that path is
|
90
|
-
# a directory (as opposed to a file).
|
91
|
-
#
|
92
|
-
# @raise [ArgumentError]
|
93
|
-
# if more than one file match is made at the path specified.
|
94
|
-
def read from_path
|
95
|
-
|
96
|
-
frozen_filepath = File.join @store_path, from_path
|
97
|
-
frozen_dir_path = File.dirname(frozen_filepath)
|
98
|
-
|
99
|
-
log.info(x) { "Coldstore will search in folder [#{frozen_dir_path.hr_path}]" }
|
100
|
-
|
101
|
-
exists_msg = "Directory #{frozen_dir_path} does not exist in store."
|
102
|
-
is_dir_msg = "Path #{frozen_dir_path} should be a directory (not a file)."
|
103
|
-
raise RuntimeError, exists_msg unless File.exists? frozen_dir_path
|
104
|
-
raise RuntimeError, is_dir_msg unless File.directory? frozen_dir_path
|
105
|
-
|
106
|
-
full_filepath = ""
|
107
|
-
file_matched = false
|
108
|
-
|
109
|
-
Dir.glob("#{frozen_dir_path}/**/*.os.txt").each do |matched_path|
|
110
|
-
|
111
|
-
log.info(x) { "Coldstore search with [#{from_path}] has matched [#{matched_path.hr_path}]" }
|
112
|
-
log.info(x) { "Ignore directory at [#{matched_path.hr_path}]." } if File.directory? matched_path
|
113
|
-
next if File.directory? matched_path
|
114
|
-
|
115
|
-
two_match_msg = "More than one file matched. The second is #{matched_path}."
|
116
|
-
raise ArgumentError, two_match_msg if file_matched
|
117
|
-
file_matched = true
|
118
|
-
|
119
|
-
full_filepath = matched_path
|
120
|
-
|
121
|
-
end
|
122
|
-
|
123
|
-
no_file_msg = "Coldstore could not find path [#{from_path}] from [#{@store_path}]."
|
124
|
-
raise RuntimeError, no_file_msg unless file_matched
|
125
|
-
|
126
|
-
log.info(x) { "Coldstore matched exactly one envelope at [#{full_filepath.hr_path}]." }
|
127
|
-
return File.read full_filepath
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
|
132
|
-
# Write (freeze) the text into a file at the denoted path. The
|
133
|
-
# folder path will be created if need be.
|
134
|
-
#
|
135
|
-
# Coldstores are usually frozen offline (offmachine) so after
|
136
|
-
# this method completes the {ColdStore.push} behaviour must be
|
137
|
-
# executed to synchronize the local coldstore freezer with the
|
138
|
-
# remote mirror.
|
139
|
-
#
|
140
|
-
# @param this_text [String]
|
141
|
-
# this is the text that needs to be frozen into the local and
|
142
|
-
# subsequently the remote coldstore freezer.
|
143
|
-
#
|
144
|
-
# @param to_path [String]
|
145
|
-
# write the text (effectively freezing it) into the file at
|
146
|
-
# this path. An attempt will be made to put down the necessary
|
147
|
-
# directory structure.
|
148
|
-
#
|
149
|
-
# This path is relative to the base of the store defined in
|
150
|
-
# the constructor.
|
151
|
-
def write this_text, to_path
|
152
|
-
|
153
|
-
freeze_filepath = File.join @store_path, to_path
|
154
|
-
|
155
|
-
log.info(x) { "ColdStore freezing #{this_text.length} characters of worthless text."}
|
156
|
-
log.info(x) { "ColdStore freeze file path => #{freeze_filepath.hr_path}"}
|
157
|
-
|
158
|
-
FileUtils.mkdir_p(File.dirname(freeze_filepath))
|
159
|
-
File.write freeze_filepath, this_text
|
160
|
-
|
161
|
-
end
|
162
|
-
|
163
|
-
|
164
|
-
private
|
165
|
-
|
166
|
-
# @todo - write sync (with a local bias during conflicts)
|
167
|
-
# The open up to the public (published) api.
|
168
|
-
def push
|
169
|
-
|
170
|
-
|
171
|
-
end
|
172
|
-
|
173
|
-
# @todo - write sync (with a rmote bias during conflicts)
|
174
|
-
# The open up to the public (published) api.
|
175
|
-
def pull
|
176
|
-
|
177
|
-
end
|
178
|
-
|
179
|
-
|
180
|
-
end
|
181
|
-
|
182
|
-
|
183
|
-
end
|
184
|
-
|
185
|
-
|
186
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
First On Shell A
|
4
|
-
########################
|
5
|
-
|
6
|
-
safe init school
|
7
|
-
safe login school
|
8
|
-
|
9
|
-
|
10
|
-
safe open grounds football.pitch
|
11
|
-
safe put size "250sq/m"
|
12
|
-
safe put owner school
|
13
|
-
safe read boys.school.json projects/safedb.net/lib/utils/store/merge-boys-school.json
|
14
|
-
safe view
|
15
|
-
|
16
|
-
safe import ~/projects/safedb.net/lib/utils/store/merge-boys-school.json
|
17
|
-
safe show
|
18
|
-
safe checkin
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
Then On Shell B
|
23
|
-
########################
|
24
|
-
|