active-fedora 9.8.0 → 9.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (23) hide show
  1. checksums.yaml +4 -4
  2. data/lib/active_fedora/file.rb +46 -32
  3. data/lib/active_fedora/version.rb +1 -1
  4. data/lib/generators/active_fedora/config/solr/solr_generator.rb +1 -1
  5. data/lib/generators/active_fedora/config/solr/templates/solr/config/_rest_managed.json +3 -0
  6. data/lib/generators/active_fedora/config/solr/templates/solr/config/admin-extra.html +31 -0
  7. data/lib/generators/active_fedora/config/solr/templates/{solr_conf/solr.xml → solr/config/elevate.xml} +36 -35
  8. data/lib/generators/active_fedora/config/solr/templates/solr/config/mapping-ISOLatin1Accent.txt +246 -0
  9. data/lib/generators/active_fedora/config/solr/templates/solr/config/protwords.txt +21 -0
  10. data/lib/generators/active_fedora/config/solr/templates/{solr_conf/conf → solr/config}/schema.xml +217 -123
  11. data/lib/generators/active_fedora/config/solr/templates/solr/config/scripts.conf +24 -0
  12. data/lib/generators/active_fedora/config/solr/templates/solr/config/solrconfig.xml +419 -0
  13. data/lib/generators/active_fedora/config/solr/templates/solr/config/spellings.txt +2 -0
  14. data/lib/generators/active_fedora/config/solr/templates/solr/config/stopwords.txt +58 -0
  15. data/lib/generators/active_fedora/config/solr/templates/solr/config/stopwords_en.txt +58 -0
  16. data/lib/generators/active_fedora/config/solr/templates/solr/config/synonyms.txt +31 -0
  17. data/lib/generators/active_fedora/config/solr/templates/solr/config/xslt/example.xsl +132 -0
  18. data/lib/generators/active_fedora/config/solr/templates/solr/config/xslt/example_atom.xsl +67 -0
  19. data/lib/generators/active_fedora/config/solr/templates/solr/config/xslt/example_rss.xsl +66 -0
  20. data/lib/generators/active_fedora/config/solr/templates/solr/config/xslt/luke.xsl +337 -0
  21. data/spec/unit/file_spec.rb +105 -0
  22. metadata +17 -4
  23. data/lib/generators/active_fedora/config/solr/templates/solr_conf/conf/solrconfig.xml +0 -218
@@ -292,4 +292,109 @@ describe ActiveFedora::File do
292
292
  it { is_expected.to be_a(DateTime) }
293
293
  end
294
294
  end
295
+
296
+ describe "callbacks" do
297
+ before do
298
+ class MyFile < ActiveFedora::File
299
+ after_initialize :a_init
300
+ before_create :b_create
301
+ after_create :a_create
302
+ before_update :b_update
303
+ after_update :a_update
304
+ before_save :b_save
305
+ after_save :a_save
306
+ before_destroy :b_destroy
307
+ after_destroy :a_destroy
308
+
309
+ def a_init; end
310
+
311
+ def b_create; end
312
+
313
+ def a_create; end
314
+
315
+ def b_save; end
316
+
317
+ def a_save; end
318
+
319
+ def b_destroy; end
320
+
321
+ def a_destroy; end
322
+
323
+ def b_update; end
324
+
325
+ def a_update; end
326
+ end
327
+ end
328
+
329
+ after do
330
+ Object.send(:remove_const, :MyFile)
331
+ end
332
+
333
+ subject { MyFile.new }
334
+
335
+ describe "initialize" do
336
+ specify {
337
+ expect_any_instance_of(MyFile).to receive(:a_init)
338
+ MyFile.new
339
+ }
340
+ end
341
+
342
+ describe "create" do
343
+ describe "when content is not nil" do
344
+ specify {
345
+ expect(subject).to receive(:b_create).once
346
+ expect(subject).to receive(:a_create).once
347
+ expect(subject).to receive(:b_save).once
348
+ expect(subject).to receive(:a_save).once
349
+ subject.content = "foo"
350
+ subject.save
351
+ }
352
+ end
353
+ describe "when content is nil" do
354
+ specify {
355
+ expect(subject).to receive(:b_create).once
356
+ expect(subject).not_to receive(:a_create)
357
+ expect(subject).to receive(:b_save).once
358
+ expect(subject).not_to receive(:a_save)
359
+ subject.save
360
+ }
361
+ end
362
+ end
363
+
364
+ describe "update" do
365
+ describe "when content has changed" do
366
+ specify {
367
+ subject.content = "foo"
368
+ subject.save
369
+ expect(subject).to receive(:b_save).once
370
+ expect(subject).to receive(:a_save).once
371
+ expect(subject).to receive(:b_update).once
372
+ expect(subject).to receive(:a_update).once
373
+ subject.content = "bar"
374
+ subject.save
375
+ }
376
+ end
377
+ describe "when content has not changed" do
378
+ specify {
379
+ subject.content = "foo"
380
+ subject.save
381
+ expect(subject).to receive(:b_save).once
382
+ expect(subject).not_to receive(:a_save)
383
+ expect(subject).to receive(:b_update).once
384
+ expect(subject).not_to receive(:a_update)
385
+ subject.save
386
+ }
387
+ end
388
+ end
389
+
390
+ describe "destroy" do
391
+ specify {
392
+ subject.content = "foo"
393
+ subject.save
394
+ expect(subject).to receive(:b_destroy).once
395
+ expect(subject).to receive(:a_destroy).once
396
+ subject.destroy
397
+ }
398
+ end
399
+ end
295
400
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active-fedora
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.8.0
4
+ version: 9.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zumwalt
@@ -479,9 +479,22 @@ files:
479
479
  - lib/generators/active_fedora/config/fedora/templates/fedora.yml
480
480
  - lib/generators/active_fedora/config/solr/solr_generator.rb
481
481
  - lib/generators/active_fedora/config/solr/templates/solr.yml
482
- - lib/generators/active_fedora/config/solr/templates/solr_conf/conf/schema.xml
483
- - lib/generators/active_fedora/config/solr/templates/solr_conf/conf/solrconfig.xml
484
- - lib/generators/active_fedora/config/solr/templates/solr_conf/solr.xml
482
+ - lib/generators/active_fedora/config/solr/templates/solr/config/_rest_managed.json
483
+ - lib/generators/active_fedora/config/solr/templates/solr/config/admin-extra.html
484
+ - lib/generators/active_fedora/config/solr/templates/solr/config/elevate.xml
485
+ - lib/generators/active_fedora/config/solr/templates/solr/config/mapping-ISOLatin1Accent.txt
486
+ - lib/generators/active_fedora/config/solr/templates/solr/config/protwords.txt
487
+ - lib/generators/active_fedora/config/solr/templates/solr/config/schema.xml
488
+ - lib/generators/active_fedora/config/solr/templates/solr/config/scripts.conf
489
+ - lib/generators/active_fedora/config/solr/templates/solr/config/solrconfig.xml
490
+ - lib/generators/active_fedora/config/solr/templates/solr/config/spellings.txt
491
+ - lib/generators/active_fedora/config/solr/templates/solr/config/stopwords.txt
492
+ - lib/generators/active_fedora/config/solr/templates/solr/config/stopwords_en.txt
493
+ - lib/generators/active_fedora/config/solr/templates/solr/config/synonyms.txt
494
+ - lib/generators/active_fedora/config/solr/templates/solr/config/xslt/example.xsl
495
+ - lib/generators/active_fedora/config/solr/templates/solr/config/xslt/example_atom.xsl
496
+ - lib/generators/active_fedora/config/solr/templates/solr/config/xslt/example_rss.xsl
497
+ - lib/generators/active_fedora/config/solr/templates/solr/config/xslt/luke.xsl
485
498
  - lib/generators/active_fedora/model/USAGE
486
499
  - lib/generators/active_fedora/model/model_generator.rb
487
500
  - lib/generators/active_fedora/model/templates/datastream.rb.erb
@@ -1,218 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" ?>
2
- <config>
3
- <!-- NOTE: various comments and unused configuration possibilities have been purged
4
- from this file. Please refer to http://wiki.apache.org/solr/SolrConfigXml,
5
- as well as the default solrconfig file included with Solr -->
6
-
7
- <abortOnConfigurationError>${solr.abortOnConfigurationError:true}</abortOnConfigurationError>
8
-
9
- <luceneMatchVersion>LUCENE_40</luceneMatchVersion>
10
-
11
- <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.StandardDirectoryFactory}"/>
12
-
13
- <!-- solr lib dirs -->
14
- <lib dir="../lib/contrib/analysis-extras/lib" />
15
- <lib dir="../lib/contrib/analysis-extras/lucene-libs" />
16
-
17
- <dataDir>${solr.data.dir:}</dataDir>
18
-
19
- <!-- The default high-performance update handler -->
20
- <updateHandler class="solr.DirectUpdateHandler2">
21
-
22
- <!-- Enables a transaction log, used for real-time get, durability, and
23
- and solr cloud replica recovery. The log can grow as big as
24
- uncommitted changes to the index, so use of a hard autoCommit
25
- is recommended (see below).
26
- "dir" - the target directory for transaction logs, defaults to the
27
- solr data directory. -->
28
- <updateLog>
29
- <str name="dir">${solr.ulog.dir:}</str>
30
- </updateLog>
31
-
32
- <!-- AutoCommit
33
-
34
- Perform a hard commit automatically under certain conditions.
35
- Instead of enabling autoCommit, consider using "commitWithin"
36
- when adding documents.
37
-
38
- http://wiki.apache.org/solr/UpdateXmlMessages
39
-
40
- maxDocs - Maximum number of documents to add since the last
41
- commit before automatically triggering a new commit.
42
-
43
- maxTime - Maximum amount of time in ms that is allowed to pass
44
- since a document was added before automatically
45
- triggering a new commit.
46
- openSearcher - if false, the commit causes recent index changes
47
- to be flushed to stable storage, but does not cause a new
48
- searcher to be opened to make those changes visible.
49
-
50
- If the updateLog is enabled, then it's highly recommended to
51
- have some sort of hard autoCommit to limit the log size.
52
- -->
53
- <autoCommit>
54
- <maxTime>${solr.autoCommit.maxTime:15000}</maxTime>
55
- <openSearcher>false</openSearcher>
56
- </autoCommit>
57
-
58
- <!-- softAutoCommit is like autoCommit except it causes a
59
- 'soft' commit which only ensures that changes are visible
60
- but does not ensure that data is synced to disk. This is
61
- faster and more near-realtime friendly than a hard commit.
62
- -->
63
-
64
- <autoSoftCommit>
65
- <maxTime>${solr.autoSoftCommit.maxTime:-1}</maxTime>
66
- </autoSoftCommit>
67
-
68
- </updateHandler>
69
-
70
- <requestHandler name="search" class="solr.SearchHandler" default="true">
71
- <!-- default values for query parameters can be specified, these
72
- will be overridden by parameters in the request
73
- -->
74
- <lst name="defaults">
75
- <str name="defType">edismax</str>
76
- <str name="echoParams">explicit</str>
77
- <str name="q.alt">*:*</str>
78
- <str name="mm">2&lt;-1 5&lt;-2 6&lt;90%</str>
79
- <int name="qs">1</int>
80
- <int name="ps">2</int>
81
- <float name="tie">0.01</float>
82
- <!-- this qf and pf are used by default, if not otherwise specified by
83
- client. The default blacklight_config will use these for the
84
- "keywords" search. See the author_qf/author_pf, title_qf, etc
85
- below, which the default blacklight_config will specify for
86
- those searches. You may also be interested in:
87
- http://wiki.apache.org/solr/LocalParams
88
- -->
89
- <str name="qf">
90
- id
91
- active_fedora_model_ssi
92
- title_tesim
93
- author_tesim
94
- subject_tesim
95
- </str>
96
- <str name="pf">
97
- all_text_timv^10
98
- </str>
99
-
100
- <str name="author_qf">
101
- author_tesim
102
- </str>
103
- <str name="author_pf">
104
- </str>
105
- <str name="title_qf">
106
- title_tesim
107
- </str>
108
- <str name="title_pf">
109
- </str>
110
- <str name="subject_qf">
111
- subject_tesim
112
- </str>
113
- <str name="subject_pf">
114
- </str>
115
-
116
- <str name="fl">
117
- *,
118
- score
119
- </str>
120
-
121
- <str name="facet">true</str>
122
- <str name="facet.mincount">1</str>
123
- <str name="facet.limit">10</str>
124
- <str name="facet.field">active_fedora_model_ssi</str>
125
- <str name="facet.field">subject_sim</str>
126
-
127
- <str name="spellcheck">true</str>
128
- <str name="spellcheck.dictionary">default</str>
129
- <str name="spellcheck.onlyMorePopular">true</str>
130
- <str name="spellcheck.extendedResults">true</str>
131
- <str name="spellcheck.collate">false</str>
132
- <str name="spellcheck.count">5</str>
133
-
134
- </lst>
135
- <arr name="last-components">
136
- <str>spellcheck</str>
137
- </arr>
138
- </requestHandler>
139
-
140
- <requestHandler name="permissions" class="solr.SearchHandler" >
141
- <lst name="defaults">
142
- <str name="facet">off</str>
143
- <str name="echoParams">all</str>
144
- <str name="rows">1</str>
145
- <str name="q">{!raw f=id v=$id}</str> <!-- use id=666 instead of q=id:666 -->
146
- <str name="fl">
147
- id,
148
- access_ssim,
149
- discover_access_group_ssim,discover_access_person_ssim,
150
- read_access_group_ssim,read_access_person_ssim,
151
- edit_access_group_ssim,edit_access_person_ssim,
152
- depositor_ti,
153
- embargo_release_date_dtsi
154
- inheritable_access_ssim,
155
- inheritable_discover_access_group_ssim,inheritable_discover_access_person_ssim,
156
- inheritable_read_access_group_ssim,inheritable_read_access_person_ssim,
157
- inheritable_edit_access_group_ssim,inheritable_edit_access_person_ssim,
158
- inheritable_embargo_release_date_dtsi
159
- </str>
160
- </lst>
161
- </requestHandler>
162
-
163
- <requestHandler name="standard" class="solr.SearchHandler">
164
- <lst name="defaults">
165
- <str name="echoParams">explicit</str>
166
- <str name="defType">lucene</str>
167
- </lst>
168
- </requestHandler>
169
-
170
- <!-- for requests to get a single document; use id=666 instead of q=id:666 -->
171
- <requestHandler name="document" class="solr.SearchHandler" >
172
- <lst name="defaults">
173
- <str name="echoParams">all</str>
174
- <str name="fl">*</str>
175
- <str name="rows">1</str>
176
- <str name="q">{!raw f=id v=$id}</str> <!-- use id=666 instead of q=id:666 -->
177
- </lst>
178
- </requestHandler>
179
-
180
-
181
- <searchComponent name="spellcheck" class="solr.SpellCheckComponent">
182
- <str name="queryAnalyzerFieldType">textSpell</str>
183
- <!-- Multiple "Spell Checkers" can be declared and used by this component
184
- (e.g. for title_spell field)
185
- -->
186
- <lst name="spellchecker">
187
- <str name="name">default</str>
188
- <str name="field">spell</str>
189
- <str name="spellcheckIndexDir">./spell</str>
190
- <str name="buildOnOptimize">true</str>
191
- </lst>
192
- </searchComponent>
193
-
194
- <requestHandler name="/replication" class="solr.ReplicationHandler" startup="lazy" />
195
-
196
- <requestDispatcher handleSelect="true" >
197
- <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048" />
198
- </requestDispatcher>
199
-
200
- <requestHandler name="/analysis/field" startup="lazy" class="solr.FieldAnalysisRequestHandler" />
201
- <requestHandler name="/update" class="solr.UpdateRequestHandler" />
202
- <requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
203
-
204
- <requestHandler name="/admin/ping" class="solr.PingRequestHandler">
205
- <lst name="invariants">
206
- <str name="q">solrpingquery</str>
207
- </lst>
208
- <lst name="defaults">
209
- <str name="echoParams">all</str>
210
- </lst>
211
- </requestHandler>
212
-
213
- <!-- config for the admin interface -->
214
- <admin>
215
- <defaultQuery>search</defaultQuery>
216
- </admin>
217
-
218
- </config>