hydra-validations 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTORS.md +1 -0
- data/README.md +3 -2
- data/hydra-validations.gemspec +0 -1
- data/lib/hydra/validations/inclusion.rb +1 -1
- data/lib/hydra/validations/version.rb +1 -1
- data/spec/validators/uniqueness_validator_spec.rb +17 -6
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2420e8bab9e84e4208c4cad52baeb3b8b0e7f4b
|
4
|
+
data.tar.gz: 889cba23c9ce004052a4418fca5998f5243e8c1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d076b873438ea19423e095d61aa24425cb160dd0c918346c6b1c480bf180919b42df10cd6865e9e13d7a741f5e2a5852980d1e3938e369dcae8a001a5823cc2e
|
7
|
+
data.tar.gz: 70ef6f6ec3a124046861bfc361a5d9486776d3efb9dbb788d3a969f081a6e94612aeb60c9c440601bc52eea8a78d224813c032882a6a18292fd046f1a2140e8a
|
data/CONTRIBUTORS.md
CHANGED
data/README.md
CHANGED
@@ -10,7 +10,6 @@ Custom validators for Hydra applications, based on ActiveModel::Validations.
|
|
10
10
|
|
11
11
|
* Ruby >= 1.9.3
|
12
12
|
* ActiveModel 4.x
|
13
|
-
* ActiveFedora 7.x
|
14
13
|
|
15
14
|
## Installation
|
16
15
|
|
@@ -92,10 +91,12 @@ end
|
|
92
91
|
=> ["Field value \"spam\" is not included in the list", "Field value \"eggs\" is not included in the list"]
|
93
92
|
```
|
94
93
|
|
95
|
-
### UniquenessValidator
|
94
|
+
### UniquenessValidator
|
96
95
|
|
97
96
|
Validates the uniqueness of an attribute based on a Solr index query.
|
98
97
|
|
98
|
+
Intended for ActiveFedora 7.x.
|
99
|
+
|
99
100
|
```ruby
|
100
101
|
class UniquenessValidatable < ActiveFedora::Base
|
101
102
|
include Hydra::Validations
|
data/hydra-validations.gemspec
CHANGED
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ["lib", "app/validators"]
|
22
22
|
|
23
23
|
spec.add_dependency "activemodel", "~> 4.0"
|
24
|
-
spec.add_dependency "active-fedora", "~> 7.0"
|
25
24
|
spec.add_development_dependency "bundler", "~> 1.6"
|
26
25
|
spec.add_development_dependency "rake"
|
27
26
|
spec.add_development_dependency "rspec"
|
@@ -3,7 +3,7 @@ require 'hydra/validations/enumerable_behavior'
|
|
3
3
|
module Hydra
|
4
4
|
module Validations
|
5
5
|
#
|
6
|
-
#
|
6
|
+
# InclusionValidator - Adds EnumerableBehavior to ActiveModel's InclusionValidator
|
7
7
|
#
|
8
8
|
# See ActiveModel::Validations::InclusionValidator for usage and options
|
9
9
|
#
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'active_fedora'
|
3
2
|
require 'support/shared_examples_for_validators'
|
4
3
|
|
5
4
|
shared_examples "it validates the uniqueness of the attribute value" do
|
@@ -20,11 +19,23 @@ end
|
|
20
19
|
describe Hydra::Validations::UniquenessValidator do
|
21
20
|
|
22
21
|
before(:all) do
|
23
|
-
class Validatable
|
22
|
+
class Validatable
|
23
|
+
def self.exists?(*args)
|
24
|
+
end
|
25
|
+
def self.name
|
26
|
+
'Validatable'
|
27
|
+
end
|
28
|
+
def persisted?
|
29
|
+
end
|
30
|
+
def initialize(attributes = {})
|
31
|
+
attributes.each do |k,v|
|
32
|
+
send("#{k}=", v)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
include ActiveModel::Validations
|
24
36
|
include Hydra::Validations
|
25
|
-
|
26
|
-
|
27
|
-
has_attributes :source, datastream: 'descMetadata', multiple: true
|
37
|
+
attr_accessor :pid, :title, :source
|
38
|
+
alias_method :id, :pid
|
28
39
|
end
|
29
40
|
end
|
30
41
|
|
@@ -88,7 +99,7 @@ describe Hydra::Validations::UniquenessValidator do
|
|
88
99
|
it_behaves_like "it validates the uniqueness of the attribute value" do
|
89
100
|
let(:conditions) { {"source_ssim" => subject.source.first, "-id" => subject.pid} }
|
90
101
|
end
|
91
|
-
end
|
102
|
+
end
|
92
103
|
end
|
93
104
|
end
|
94
105
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dchandekstark
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -24,20 +24,6 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.0'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: active-fedora
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '7.0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '7.0'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: bundler
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|