rffdb 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 37838db2bfccfd088505b989e6ad5e7e23d9d7d2
4
- data.tar.gz: a41f4ce7ddf7175fedd855951af01361d03514ce
3
+ metadata.gz: 9fb7573af91b606dd573a4bfdf7f8d876b6a5ec2
4
+ data.tar.gz: 2141017eec360eaac99978941b347a58d3972816
5
5
  SHA512:
6
- metadata.gz: 9f5a755761ebf31cc18fb208edcd607162a67b052bcbcd97a6e12ebd958fd57e016c5df9806c8b0b303fe9a3e1d6c40063583f4f8fd0dd025114e533ad886c8a
7
- data.tar.gz: 6642ec484386203f3c1f7fad6aaef202b33bd1448a1be603ea4f340a830a09be5fb0808cd8db7ce97b0f947aa49eac123bf22b5e048a926a89747643d5288516
6
+ metadata.gz: ed730016671f66831c47e9da542f871f06ca8d7a1057c19d17072eb89c2a1b87ab037018cb989f500a20c62f9ba61ab374ccd77c49e2bc81e32acefb6a41ccda
7
+ data.tar.gz: dc30384cadf4d94c954a5de409053122364fe55db7068cdbe4eaf79293f5be03b7091631746f1c413c06cbc88999c10a0669cd63bf7f8cdc704ac4c519e6a2f2
@@ -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
@@ -1,3 +1,3 @@
1
1
  module RubyFFDB
2
- VERSION = [0, 1, 3].join('.')
2
+ VERSION = [0, 1, 4].join('.')
3
3
  end
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.3
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-21 00:00:00.000000000 Z
11
+ date: 2016-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec