curate-indexer 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/curate/indexer/adapters/in_memory_adapter.rb +97 -0
- data/lib/curate/indexer/configuration.rb +1 -0
- data/lib/curate/indexer/relationship_reindexer.rb +0 -2
- data/lib/curate/indexer/version.rb +1 -1
- metadata +2 -5
- data/lib/curate/indexer/index.rb +0 -39
- data/lib/curate/indexer/preservation.rb +0 -39
- data/lib/curate/indexer/storage_module.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 180b9a34980ab4a17aaf58de88a79bb7421e4d8c
|
4
|
+
data.tar.gz: 9ee184bed40c4454bf0d4ae2b09c7b21d65554d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0e1e6cf6e7f5e7090949c7cfe86d1462a86bf24a1aa8f16e4d7f47d0c5b0d39999d410a8ee491d487999e35d0a6743b1ece6348bb74ceea57f479e6df4e196b
|
7
|
+
data.tar.gz: cebeb033701dcc18e058ef26583f39413e61f8b8c8057a4cee9b61d2a8cfad2ac86bd7b165fcb52a960b9141ff1cff14fad8df51e5566c7ea73572fbc9e14027
|
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'curate/indexer/adapters/abstract_adapter'
|
2
|
+
require 'curate/indexer/documents'
|
3
|
+
|
2
4
|
module Curate
|
3
5
|
module Indexer
|
4
6
|
module Adapters
|
@@ -54,6 +56,101 @@ module Curate
|
|
54
56
|
Preservation.clear_cache!
|
55
57
|
Index.clear_cache!
|
56
58
|
end
|
59
|
+
|
60
|
+
# @api private
|
61
|
+
#
|
62
|
+
# A module mixin to expose rudimentary read/write capabilities
|
63
|
+
#
|
64
|
+
# @example
|
65
|
+
# module Foo
|
66
|
+
# extend Curate::Indexer::StorageModule
|
67
|
+
# end
|
68
|
+
module StorageModule
|
69
|
+
def write(doc)
|
70
|
+
cache[doc.pid] = doc
|
71
|
+
end
|
72
|
+
|
73
|
+
def find(pid)
|
74
|
+
cache.fetch(pid.to_s)
|
75
|
+
end
|
76
|
+
|
77
|
+
def find_each
|
78
|
+
cache.each { |_key, document| yield(document) }
|
79
|
+
end
|
80
|
+
|
81
|
+
def clear_cache!
|
82
|
+
@cache = {}
|
83
|
+
end
|
84
|
+
|
85
|
+
def cache
|
86
|
+
@cache ||= {}
|
87
|
+
end
|
88
|
+
private :cache
|
89
|
+
end
|
90
|
+
|
91
|
+
# @api private
|
92
|
+
#
|
93
|
+
# A module responsible for containing the "preservation interface" logic.
|
94
|
+
# In the case of CurateND, there will need to be an adapter to get a Fedora
|
95
|
+
# object coerced into a Curate::Indexer::Preservation::Document
|
96
|
+
module Preservation
|
97
|
+
def self.find(pid, *)
|
98
|
+
MemoryStorage.find(pid)
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.find_each(*, &block)
|
102
|
+
MemoryStorage.find_each(&block)
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.clear_cache!
|
106
|
+
MemoryStorage.clear_cache!
|
107
|
+
end
|
108
|
+
|
109
|
+
def self.write_document(attributes = {})
|
110
|
+
Documents::PreservationDocument.new(attributes).tap do |doc|
|
111
|
+
MemoryStorage.write(doc)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# :nodoc:
|
116
|
+
module MemoryStorage
|
117
|
+
extend StorageModule
|
118
|
+
end
|
119
|
+
private_constant :MemoryStorage
|
120
|
+
end
|
121
|
+
private_constant :Preservation
|
122
|
+
|
123
|
+
# @api private
|
124
|
+
#
|
125
|
+
# An abstract representation of the underlying index service. In the case of
|
126
|
+
# CurateND this is an abstraction of Solr.
|
127
|
+
module Index
|
128
|
+
def self.clear_cache!
|
129
|
+
Storage.clear_cache!
|
130
|
+
end
|
131
|
+
|
132
|
+
def self.find(pid)
|
133
|
+
Storage.find(pid)
|
134
|
+
end
|
135
|
+
|
136
|
+
def self.each_child_document_of(document, &block)
|
137
|
+
Storage.find_children_of_pid(document.pid).each(&block)
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.write_document(attributes = {})
|
141
|
+
Documents::IndexDocument.new(attributes).tap { |doc| Storage.write(doc) }
|
142
|
+
end
|
143
|
+
|
144
|
+
# :nodoc:
|
145
|
+
module Storage
|
146
|
+
extend StorageModule
|
147
|
+
def self.find_children_of_pid(pid)
|
148
|
+
cache.values.select { |document| document.parent_pids.include?(pid) }
|
149
|
+
end
|
150
|
+
end
|
151
|
+
private_constant :Storage
|
152
|
+
end
|
153
|
+
private_constant :Index
|
57
154
|
end
|
58
155
|
end
|
59
156
|
end
|
@@ -12,6 +12,7 @@ module Curate
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def default_adapter
|
15
|
+
$stdout.puts "WARNING: You are using the default Curate::Indexer::Adapters::InMemoryAdapter for the Curate::Indexer.adapter."
|
15
16
|
require 'curate/indexer/adapters/in_memory_adapter'
|
16
17
|
Adapters::InMemoryAdapter
|
17
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: curate-indexer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -261,12 +261,9 @@ files:
|
|
261
261
|
- lib/curate/indexer/configuration.rb
|
262
262
|
- lib/curate/indexer/documents.rb
|
263
263
|
- lib/curate/indexer/exceptions.rb
|
264
|
-
- lib/curate/indexer/index.rb
|
265
|
-
- lib/curate/indexer/preservation.rb
|
266
264
|
- lib/curate/indexer/railtie.rb
|
267
265
|
- lib/curate/indexer/relationship_reindexer.rb
|
268
266
|
- lib/curate/indexer/repository_reindexer.rb
|
269
|
-
- lib/curate/indexer/storage_module.rb
|
270
267
|
- lib/curate/indexer/version.rb
|
271
268
|
homepage: https://github.com/ndlib/curate-indexer
|
272
269
|
licenses: []
|
data/lib/curate/indexer/index.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'curate/indexer/storage_module'
|
2
|
-
require 'curate/indexer/documents'
|
3
|
-
|
4
|
-
module Curate
|
5
|
-
# :nodoc:
|
6
|
-
module Indexer
|
7
|
-
# @api private
|
8
|
-
#
|
9
|
-
# An abstract representation of the underlying index service. In the case of
|
10
|
-
# CurateND this is an abstraction of Solr.
|
11
|
-
module Index
|
12
|
-
def self.clear_cache!
|
13
|
-
Storage.clear_cache!
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.find(pid)
|
17
|
-
Storage.find(pid)
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.each_child_document_of(document, &block)
|
21
|
-
Storage.find_children_of_pid(document.pid).each(&block)
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.write_document(attributes = {})
|
25
|
-
Documents::IndexDocument.new(attributes).tap { |doc| Storage.write(doc) }
|
26
|
-
end
|
27
|
-
|
28
|
-
# :nodoc:
|
29
|
-
module Storage
|
30
|
-
extend StorageModule
|
31
|
-
def self.find_children_of_pid(pid)
|
32
|
-
cache.values.select { |document| document.parent_pids.include?(pid) }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
private_constant :Storage
|
36
|
-
end
|
37
|
-
private_constant :Index
|
38
|
-
end
|
39
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'curate/indexer/storage_module'
|
2
|
-
require 'curate/indexer/documents'
|
3
|
-
|
4
|
-
module Curate
|
5
|
-
# :nodoc:
|
6
|
-
module Indexer
|
7
|
-
# @api private
|
8
|
-
#
|
9
|
-
# A module responsible for containing the "preservation interface" logic.
|
10
|
-
# In the case of CurateND, there will need to be an adapter to get a Fedora
|
11
|
-
# object coerced into a Curate::Indexer::Preservation::Document
|
12
|
-
module Preservation
|
13
|
-
def self.find(pid, *)
|
14
|
-
MemoryStorage.find(pid)
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.find_each(*, &block)
|
18
|
-
MemoryStorage.find_each(&block)
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.clear_cache!
|
22
|
-
MemoryStorage.clear_cache!
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.write_document(attributes = {})
|
26
|
-
Documents::PreservationDocument.new(attributes).tap do |doc|
|
27
|
-
MemoryStorage.write(doc)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
# :nodoc:
|
32
|
-
module MemoryStorage
|
33
|
-
extend StorageModule
|
34
|
-
end
|
35
|
-
private_constant :MemoryStorage
|
36
|
-
end
|
37
|
-
private_constant :Preservation
|
38
|
-
end
|
39
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module Curate
|
2
|
-
module Indexer
|
3
|
-
# @api private
|
4
|
-
#
|
5
|
-
# A module mixin to expose rudimentary read/write capabilities
|
6
|
-
#
|
7
|
-
# @example
|
8
|
-
# module Foo
|
9
|
-
# extend Curate::Indexer::StorageModule
|
10
|
-
# end
|
11
|
-
module StorageModule
|
12
|
-
def write(doc)
|
13
|
-
cache[doc.pid] = doc
|
14
|
-
end
|
15
|
-
|
16
|
-
def find(pid)
|
17
|
-
cache.fetch(pid.to_s)
|
18
|
-
end
|
19
|
-
|
20
|
-
def find_each
|
21
|
-
cache.each { |_key, document| yield(document) }
|
22
|
-
end
|
23
|
-
|
24
|
-
def clear_cache!
|
25
|
-
@cache = {}
|
26
|
-
end
|
27
|
-
|
28
|
-
def cache
|
29
|
-
@cache ||= {}
|
30
|
-
end
|
31
|
-
private :cache
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|