common_repository_model 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/common_repository_model.gemspec +4 -4
- data/config/schema.xml +125 -0
- data/config/solrconfig.xml +1882 -1858
- data/lib/common_repository_model.rb +1 -0
- data/lib/common_repository_model/exceptions.rb +10 -0
- data/lib/common_repository_model/persistence_base.rb +9 -11
- data/lib/common_repository_model/version.rb +1 -1
- data/lib/generators/common_repository_model/collection/collection_generator.rb +1 -1
- data/lib/tasks/common_repository_model.tasks +15 -0
- data/spec/common_respository_model/data_spec.rb +13 -12
- data/spec/common_respository_model/persistence_base_spec.rb +13 -0
- metadata +18 -16
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'active_fedora'
|
2
|
+
module CommonRepositoryModel
|
3
|
+
class ObjectNotFoundError < ActiveFedora::ObjectNotFoundError
|
4
|
+
attr_reader :original_exception
|
5
|
+
def initialize(message, original_exception = nil)
|
6
|
+
super(message)
|
7
|
+
@original_exception = original_exception || self
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -1,24 +1,22 @@
|
|
1
1
|
require 'active_fedora'
|
2
2
|
require 'active_model_serializers'
|
3
3
|
require_relative './persistence_base_serializer'
|
4
|
+
require_relative './exceptions'
|
4
5
|
module CommonRepositoryModel
|
5
|
-
class ObjectNotFoundError < ActiveFedora::ObjectNotFoundError
|
6
|
-
end
|
7
|
-
|
8
6
|
class PersistenceBase < ActiveFedora::Base
|
9
7
|
include ActiveModel::SerializerSupport
|
10
8
|
def active_model_serializer
|
11
9
|
"#{self.class}Serializer".constantize
|
12
10
|
end
|
13
11
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
def self.find(*args,&block)
|
13
|
+
super
|
14
|
+
rescue RSolr::Error::Http => e
|
15
|
+
raise CommonRepositoryModel::ObjectNotFoundError.new(
|
16
|
+
"#{self}.find(#{args.inspect}) had a SOLR error.", e
|
17
|
+
)
|
18
|
+
rescue ActiveFedora::ObjectNotFoundError => e
|
19
|
+
raise CommonRepositoryModel::ObjectNotFoundError.new(e.message, e)
|
21
20
|
end
|
22
|
-
|
23
21
|
end
|
24
22
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'rails/generators'
|
2
2
|
|
3
3
|
class CommonRepositoryModel::CollectionGenerator < Rails::Generators::NamedBase
|
4
|
+
check_class_collision
|
4
5
|
source_root File.expand_path('../templates', __FILE__)
|
5
|
-
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
6
6
|
class_option :test_dir, :type => :string, :default => "spec/factories", :desc => "The directory where the factories should go"
|
7
7
|
|
8
8
|
def create_collection
|
@@ -1,4 +1,19 @@
|
|
1
1
|
namespace :common_repository_model do
|
2
|
+
task :configure_hydra_jetty do
|
3
|
+
require 'fileutils'
|
4
|
+
path_to_hydra_jetty_project = "../hydra-jetty"
|
5
|
+
|
6
|
+
['solr/test-core','solr/development-core'].each do |subdir|
|
7
|
+
FileUtils.cp(
|
8
|
+
'config/schema.xml',
|
9
|
+
File.join(path_to_hydra_jetty_project, subdir, 'conf/schema.xml')
|
10
|
+
)
|
11
|
+
FileUtils.cp(
|
12
|
+
'config/solrconfig.xml',
|
13
|
+
File.join(path_to_hydra_jetty_project, subdir, 'conf/solrconfig.xml')
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
2
17
|
task :prompt_for_area => :environment do
|
3
18
|
require 'highline'
|
4
19
|
highline = HighLine.new
|
@@ -24,6 +24,7 @@ describe CommonRepositoryModel::Data do
|
|
24
24
|
it 'should have content versions' do
|
25
25
|
subject.content = file_1
|
26
26
|
subject.save
|
27
|
+
file_1.reopen(file_1.path,'r')
|
27
28
|
subject.content.content.must_equal file_1.read
|
28
29
|
subject.content = file_2
|
29
30
|
subject.save
|
@@ -31,21 +32,21 @@ describe CommonRepositoryModel::Data do
|
|
31
32
|
subject.content.versions.count.must_equal 2
|
32
33
|
end
|
33
34
|
|
34
|
-
it 'should save' do
|
35
|
-
|
35
|
+
# it 'should save' do
|
36
|
+
# with_persisted_area(collection.name_of_area_to_assign) do |area|
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
# # Before we can add a collection, the containing object
|
39
|
+
# # must be saved
|
40
|
+
# collection.save!
|
41
|
+
# subject.collection = collection
|
42
|
+
# subject.save!
|
42
43
|
|
43
|
-
|
44
|
+
# @subject = subject.class.find(subject.pid)
|
44
45
|
|
45
|
-
|
46
|
-
|
46
|
+
# assert_rels_ext(@subject, :is_part_of, [collection])
|
47
|
+
# assert_active_fedora_belongs_to(@subject, :collection, collection)
|
47
48
|
|
48
|
-
|
49
|
-
end
|
49
|
+
# end
|
50
|
+
# end
|
50
51
|
end
|
51
52
|
end
|
@@ -5,4 +5,17 @@ describe CommonRepositoryModel::PersistenceBase do
|
|
5
5
|
|
6
6
|
subject { CommonRepositoryModel::PersistenceBase.new }
|
7
7
|
|
8
|
+
describe '.find' do
|
9
|
+
it 'should handle find with missing parameter' do
|
10
|
+
lambda {
|
11
|
+
subject.class.find(nil)
|
12
|
+
}.must_raise(CommonRepositoryModel::ObjectNotFoundError)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should handle find with invalid PID' do
|
16
|
+
lambda {
|
17
|
+
subject.class.find('-1')
|
18
|
+
}.must_raise(CommonRepositoryModel::ObjectNotFoundError)
|
19
|
+
end
|
20
|
+
end
|
8
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: common_repository_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11
|
12
|
+
date: 2012-12-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -76,30 +76,30 @@ dependencies:
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
79
|
+
name: active-fedora
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
83
|
-
- -
|
83
|
+
- - '='
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
85
|
+
version: 5.2.0
|
86
86
|
type: :runtime
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
90
90
|
requirements:
|
91
|
-
- -
|
91
|
+
- - '='
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
93
|
+
version: 5.2.0
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
|
-
name: minitest
|
95
|
+
name: minitest
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
99
99
|
- - ! '>='
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
|
-
type: :
|
102
|
+
type: :development
|
103
103
|
prerelease: false
|
104
104
|
version_requirements: !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
@@ -108,21 +108,21 @@ dependencies:
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
|
-
name:
|
111
|
+
name: minitest-matchers
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
113
113
|
none: false
|
114
114
|
requirements:
|
115
|
-
- - '
|
115
|
+
- - ! '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
118
|
-
type: :
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
122
122
|
requirements:
|
123
|
-
- - '
|
123
|
+
- - ! '>='
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
125
|
+
version: '0'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: factory_girl
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,7 +131,7 @@ dependencies:
|
|
131
131
|
- - ! '>='
|
132
132
|
- !ruby/object:Gem::Version
|
133
133
|
version: '0'
|
134
|
-
type: :
|
134
|
+
type: :development
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
137
137
|
none: false
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- Rakefile
|
155
155
|
- common_repository_model.gemspec
|
156
156
|
- config/README.md
|
157
|
+
- config/schema.xml
|
157
158
|
- config/solrconfig.xml
|
158
159
|
- lib/common_repository_model.rb
|
159
160
|
- lib/common_repository_model/area.rb
|
@@ -162,6 +163,7 @@ files:
|
|
162
163
|
- lib/common_repository_model/collection_serializer.rb
|
163
164
|
- lib/common_repository_model/data.rb
|
164
165
|
- lib/common_repository_model/data_serializer.rb
|
166
|
+
- lib/common_repository_model/exceptions.rb
|
165
167
|
- lib/common_repository_model/file_datastream.rb
|
166
168
|
- lib/common_repository_model/persistence_base.rb
|
167
169
|
- lib/common_repository_model/persistence_base_serializer.rb
|