active-fedora 4.6.0.rc3 → 4.6.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/active-fedora.gemspec +1 -1
- data/lib/active_fedora/attributes/serializers.rb +0 -44
- data/lib/active_fedora/version.rb +1 -1
- data/spec/unit/serializers_spec.rb +0 -54
- metadata +5 -5
data/History.txt
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
4.6.0
|
2
|
+
Depend on solrizer 2.0.0 (for HYDRA-827 DO NOT index terms by default)
|
3
|
+
|
4
|
+
|
1
5
|
4.5.1
|
2
6
|
Removes .rvmrc and Gemfile.lock from version control (devs should deal with these themselves)
|
3
7
|
HYDRA-837: ActiveFedora::Datastreams#has_file_datastream should support :versionable argument (re-opened)
|
data/active-fedora.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
s.add_dependency('rsolr')
|
19
19
|
s.add_dependency('om', '~> 1.7.0.rc2')
|
20
|
-
s.add_dependency('solrizer', '~>
|
20
|
+
s.add_dependency('solrizer', '~>2.0.0.rc1')
|
21
21
|
s.add_dependency("activeresource", '>= 3.0.0')
|
22
22
|
s.add_dependency("activesupport", '>= 3.0.0')
|
23
23
|
s.add_dependency("builder", '~> 3.0.0')
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module ActiveFedora
|
2
2
|
module Attributes
|
3
3
|
module Serializers
|
4
|
-
extend ActiveSupport::Concern
|
5
4
|
|
6
5
|
## This allows you to use date_select helpers in rails views
|
7
6
|
# @param [Hash] parms parameters hash
|
@@ -26,49 +25,6 @@ module ActiveFedora
|
|
26
25
|
def attributes=(params)
|
27
26
|
super(deserialize_dates_from_form(params))
|
28
27
|
end
|
29
|
-
|
30
|
-
module ClassMethods
|
31
|
-
# @param [String] value a string to be cast to integer
|
32
|
-
# @param [Hash] options
|
33
|
-
# @option options [Integer] :default a value to return if the passed value argument is blank
|
34
|
-
# @return [Integer]
|
35
|
-
def coerce_to_integer(value, options={})
|
36
|
-
if value.blank?
|
37
|
-
options[:default] || nil
|
38
|
-
else
|
39
|
-
value.to_i
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# @param [String] value a string to be cast to boolean
|
44
|
-
# @param [Hash] options
|
45
|
-
# @option options [Boolean] :default a value to return if the passed value argument is blank
|
46
|
-
# @return [Boolean] true if value == "true" or default if value is blank
|
47
|
-
def coerce_to_boolean(value, options={})
|
48
|
-
if value.blank?
|
49
|
-
options[:default] || nil
|
50
|
-
else
|
51
|
-
value=="true"
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
# @param [String] value a string to be cast to boolean
|
56
|
-
# @param [Hash] options
|
57
|
-
# @option options [Boolean] :default a value to return if the passed value argument is blank
|
58
|
-
# @return [Boolean] true if value == "true" or default if value is blank
|
59
|
-
def coerce_to_date(v, options={})
|
60
|
-
if v.blank? && options[:default]
|
61
|
-
options[:default] == :today ? Date.today : options[:default]
|
62
|
-
else
|
63
|
-
begin
|
64
|
-
Date.parse(v)
|
65
|
-
rescue TypeError, ArgumentError
|
66
|
-
nil
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
28
|
end
|
73
29
|
end
|
74
30
|
end
|
@@ -2,60 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe ActiveFedora::Attributes::Serializers do
|
4
4
|
subject { ActiveFedora::Base }
|
5
|
-
describe "serialize to integer" do
|
6
|
-
it "should cast to integer" do
|
7
|
-
subject.coerce_to_integer("0").should == 0
|
8
|
-
subject.coerce_to_integer("01").should == 1
|
9
|
-
subject.coerce_to_integer("seven").should == 0 # same as "seven".to_i => 0
|
10
|
-
subject.coerce_to_integer("007seven").should == 7 # same as "007seven".to_i => 7
|
11
|
-
subject.coerce_to_integer("").should be_nil
|
12
|
-
subject.coerce_to_integer(nil).should be_nil
|
13
|
-
subject.coerce_to_integer("", :default=>7).should == 7
|
14
|
-
subject.coerce_to_integer(nil, :default=>7).should == 7
|
15
|
-
subject.coerce_to_integer("9", :default=>7).should == 9
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "serialize to date" do
|
20
|
-
it "should cast to date" do
|
21
|
-
unless RUBY_VERSION < "1.9"
|
22
|
-
subject.coerce_to_date("30/10/2010").should == Date.parse('2010-10-30') # ruby interprets this as DD/MM/YYYY
|
23
|
-
end
|
24
|
-
subject.coerce_to_date("2010-01-31").should == Date.parse('2010-01-31')
|
25
|
-
end
|
26
|
-
it "should handle invalid dates" do
|
27
|
-
subject.coerce_to_date("0").should == nil #
|
28
|
-
unless RUBY_VERSION < "1.9"
|
29
|
-
subject.coerce_to_date("01/15/2010").should == nil # ruby interprets this as DD/MM/YYYY
|
30
|
-
end
|
31
|
-
subject.coerce_to_date("2010-31-01").should == nil
|
32
|
-
end
|
33
|
-
it "should work with a blank string" do
|
34
|
-
subject.coerce_to_date("").should == nil
|
35
|
-
subject.coerce_to_date("", :default=>:today).should be_kind_of Date
|
36
|
-
subject.coerce_to_date("", :default=>Date.parse('2010-01-31')).should == Date.parse('2010-01-31')
|
37
|
-
end
|
38
|
-
it "should work when nil is passed in" do
|
39
|
-
subject.coerce_to_date(nil).should == nil
|
40
|
-
subject.coerce_to_date(nil, :default=>:today).should be_kind_of Date
|
41
|
-
subject.coerce_to_date(nil, :default=>Date.parse('2010-01-31')).should == Date.parse('2010-01-31')
|
42
|
-
end
|
43
|
-
end
|
44
|
-
describe "serialize to boolean" do
|
45
|
-
it "should cast to bool" do
|
46
|
-
subject.coerce_to_boolean("true").should be_true
|
47
|
-
subject.coerce_to_boolean("false").should be_false
|
48
|
-
subject.coerce_to_boolean("faoo").should be_false
|
49
|
-
subject.coerce_to_boolean("").should be_false
|
50
|
-
subject.coerce_to_boolean("", :default=>true).should be_true
|
51
|
-
subject.coerce_to_boolean("", :default=>false).should be_false
|
52
|
-
subject.coerce_to_boolean("x", :default=>true).should be_false
|
53
|
-
subject.coerce_to_boolean("x", :default=>false).should be_false
|
54
|
-
subject.coerce_to_boolean(nil, :default=>true).should be_true
|
55
|
-
subject.coerce_to_boolean(nil, :default=>false).should be_false
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
5
|
describe "deserialize_dates_from_form" do
|
60
6
|
before do
|
61
7
|
class Foo < ActiveFedora::Base
|
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: 4.6.0.
|
4
|
+
version: 4.6.0.rc4
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-10-
|
14
|
+
date: 2012-10-24 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rsolr
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: 2.0.0.rc1
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
58
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -60,7 +60,7 @@ dependencies:
|
|
60
60
|
requirements:
|
61
61
|
- - ~>
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
63
|
+
version: 2.0.0.rc1
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
65
|
name: activeresource
|
66
66
|
requirement: !ruby/object:Gem::Requirement
|
@@ -542,7 +542,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
542
542
|
version: '0'
|
543
543
|
segments:
|
544
544
|
- 0
|
545
|
-
hash: -
|
545
|
+
hash: -4003154784949769176
|
546
546
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
547
547
|
none: false
|
548
548
|
requirements:
|