rffdb 0.1.3 → 0.1.4
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/rffdb/document.rb +19 -2
- data/lib/rffdb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fb7573af91b606dd573a4bfdf7f8d876b6a5ec2
|
4
|
+
data.tar.gz: 2141017eec360eaac99978941b347a58d3972816
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed730016671f66831c47e9da542f871f06ca8d7a1057c19d17072eb89c2a1b87ab037018cb989f500a20c62f9ba61ab374ccd77c49e2bc81e32acefb6a41ccda
|
7
|
+
data.tar.gz: dc30384cadf4d94c954a5de409053122364fe55db7068cdbe4eaf79293f5be03b7091631746f1c413c06cbc88999c10a0669cd63bf7f8cdc704ac4c519e6a2f2
|
data/lib/rffdb/document.rb
CHANGED
@@ -5,6 +5,8 @@ module RubyFFDB
|
|
5
5
|
|
6
6
|
# @raise [Exceptions::NoSuchDocument] retrieved a non-existing document
|
7
7
|
def initialize(existing_id = false, lazy = true)
|
8
|
+
@read_lock = Mutex.new
|
9
|
+
@write_lock = Mutex.new
|
8
10
|
if existing_id
|
9
11
|
@id = existing_id
|
10
12
|
fail Exceptions::NoSuchDocument unless File.exist?(file_path)
|
@@ -21,8 +23,6 @@ module RubyFFDB
|
|
21
23
|
# relative to database root
|
22
24
|
@saved = false
|
23
25
|
end
|
24
|
-
@read_lock = Mutex.new
|
25
|
-
@write_lock = Mutex.new
|
26
26
|
end
|
27
27
|
|
28
28
|
# The location of the flat-file
|
@@ -69,6 +69,7 @@ module RubyFFDB
|
|
69
69
|
@read_lock.synchronize do
|
70
70
|
@write_lock.synchronize { @saved = true }
|
71
71
|
end
|
72
|
+
return self
|
72
73
|
end
|
73
74
|
|
74
75
|
# Overwrites the document's data, either from disk or from cache. Useful for
|
@@ -82,6 +83,14 @@ module RubyFFDB
|
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
86
|
+
# Allow saving an already saved Document. Useful for reindexing, maybe more.
|
87
|
+
def touch
|
88
|
+
@read_lock.synchronize do
|
89
|
+
@write_lock.synchronize { @saved = false }
|
90
|
+
end
|
91
|
+
return self
|
92
|
+
end
|
93
|
+
|
85
94
|
# Currently an alias for #new, but used as a wrapper in case more work needs
|
86
95
|
# to be done before pulling a document from the storage engine (such as
|
87
96
|
# sanitizing input, etc)
|
@@ -91,6 +100,14 @@ module RubyFFDB
|
|
91
100
|
|
92
101
|
singleton_class.send(:alias_method, :get, :load)
|
93
102
|
|
103
|
+
# Reindex all documents of this type. This can take a while on large DBs.
|
104
|
+
def self.reindex
|
105
|
+
storage.all(self).each do |doc_id|
|
106
|
+
new(doc_id, false).touch.commit
|
107
|
+
end
|
108
|
+
return true
|
109
|
+
end
|
110
|
+
|
94
111
|
# This DSL method is used to define the schema for a document. It sets up
|
95
112
|
# all data access for the class, and allows specifying strict checks
|
96
113
|
# on that schema during its use, such as validations, class types, regexp
|
data/lib/rffdb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rffdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Gnagy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|