active_fedora-registered_attributes 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06ee85f6f0ae625db22d43140c987cb8b47cd317
4
- data.tar.gz: a19e3fca5ad2e5b920c763c73e2ee5387e9d18a5
3
+ metadata.gz: 4dc9320ae00b5cf5bb2128d3d6174300ea078e14
4
+ data.tar.gz: 669c91334c14819d2c81d2bca307330f9d225b7f
5
5
  SHA512:
6
- metadata.gz: 7058001b7d437cef228a70989f71380ac281c9dfe3c6e631760ef284a5e784edce847bf9f44a968ff0b7295f1442e239339e30b0b1930044846648b2dc814007
7
- data.tar.gz: 74329cf1c0dcd822971766c1d44f134060490595e417cdaf65c368a7db56aed8f759bfe1f61d6682617da7d8940f3c7f54d49734561c23b0e3096ebfc6bbbe60
6
+ metadata.gz: 2abaf01c420893621250fc64e6f2de6b8dad920611c72ed17824ccb64821689a6c907371602fc486075e2afd900cb37122176c468380985dff90bc6dd3157889
7
+ data.tar.gz: 72631225b897f31797a2c1cb3abf1084a473e318a47d6ed79f0bd0bb67f341a3ccd70da18fac29ee8084b918fdd9ac9ec358354e9fc06cc3b01cbc4528fa0ff0
@@ -3,10 +3,13 @@ rvm:
3
3
  - "1.9.3"
4
4
  - "2.0.0"
5
5
 
6
- script: "rspec"
6
+ script: "bundle exec rspec"
7
+
8
+ env:
9
+ global:
10
+ - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
7
11
 
8
12
  notifications:
9
13
  irc: "irc.freenode.org#ndlib"
10
14
 
11
- before_install:
12
- - gem install bundler
15
+ cache: bundler
data/Guardfile CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  guard 'rspec' do
5
5
  watch(%r{^spec/.+_spec\.rb$})
6
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
7
  watch('spec/spec_helper.rb') { "spec" }
8
8
  watch('spec/support/*') { "spec" }
9
9
  end
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # ActiveFedora::RegisteredAttributes
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/active_fedora-registered_attributes.png)](http://badge.fury.io/rb/active_fedora-registered_attributes)
3
4
  [![Build Status](https://travis-ci.org/projecthydra/active_fedora-registered_attributes.png?branch=master)](https://travis-ci.org/projecthydra/active_fedora-registered_attributes)
4
5
 
5
6
  An ActiveFedora extension for consolidating the attribute definitions for an object.
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "active-fedora", ">= 6.6.0.rc2"
21
+ spec.add_dependency "active-fedora", ">= 6.7.0"
22
22
  spec.add_dependency "active_attr", "~> 0.8.2"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
@@ -47,7 +47,7 @@ module ActiveFedora
47
47
  end
48
48
 
49
49
  attribute.with_delegation_options do |name, opts|
50
- delegate(name, opts)
50
+ has_attributes(name, opts)
51
51
  end
52
52
 
53
53
  attribute.wrap_writer_method(self)
@@ -2,6 +2,11 @@ module ActiveFedora
2
2
  module RegisteredAttributes
3
3
  class Attribute
4
4
 
5
+ VALID_ATTRIBUTE_OPTIONS = [
6
+ :default, :displayable, :editable, :form, :datastream, :validates,
7
+ :multiple, :writer, :reader, :label, :hint, :skip_accessor
8
+ ].freeze
9
+
5
10
  attr_reader :context_class, :name, :datastream
6
11
  private :context_class
7
12
 
@@ -40,7 +45,7 @@ module ActiveFedora
40
45
  # A supplement to the Attribute's :label
41
46
  def initialize(context_class, name, options = {})
42
47
  @options = options.symbolize_keys
43
- @options.assert_valid_keys(:default, :displayable, :editable, :form, :datastream, :validates, :multiple, :writer, :reader, :label, :hint, :skip_accessor)
48
+ @options.assert_valid_keys(VALID_ATTRIBUTE_OPTIONS)
44
49
  @context_class = context_class
45
50
  @datastream = @options.fetch(:datastream, false)
46
51
  @name = name
@@ -136,7 +141,7 @@ module ActiveFedora
136
141
  datastream.merge(multiple: multiple?)
137
142
  else
138
143
  {
139
- to: datastream,
144
+ datastream: datastream,
140
145
  multiple: multiple?
141
146
  }
142
147
  end
@@ -20,16 +20,14 @@ module ActiveFedora
20
20
  end
21
21
 
22
22
  def editable_attributes
23
- @editable_attributes ||= each_with_object([]) {|(name, attribute), m|
24
- m << attribute if attribute.editable?
25
- m
23
+ @editable_attributes ||= select_matching_attributes { |attribute|
24
+ attribute.editable?
26
25
  }
27
26
  end
28
27
 
29
28
  def displayable_attributes
30
- @displayable_attributes ||= each_with_object([]) {|(name, attribute),m|
31
- m << attribute if attribute.displayable?
32
- m
29
+ @displayable_attributes ||= select_matching_attributes { |attribute|
30
+ attribute.displayable?
33
31
  }
34
32
  end
35
33
 
@@ -51,6 +49,14 @@ module ActiveFedora
51
49
  rescue KeyError
52
50
  name.to_s.titleize
53
51
  end
52
+
53
+ private
54
+ def select_matching_attributes
55
+ each_with_object([]) do |(name, attribute),m|
56
+ m << attribute if yield(attribute)
57
+ m
58
+ end
59
+ end
54
60
  end
55
61
 
56
62
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora
2
2
  module RegisteredAttributes
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -5,7 +5,7 @@ describe ActiveFedora::RegisteredAttributes::AttributeRegistry do
5
5
  let(:context) { Book }
6
6
  let(:name) { "My Name" }
7
7
  let(:options) { {} }
8
- subject { ActiveFedora::RegisteredAttributes::AttributeRegistry.new(context) }
8
+ subject { described_class.new(context) }
9
9
 
10
10
  describe '#register' do
11
11
  it 'yields an attribute' do
@@ -21,7 +21,7 @@ describe ActiveFedora::RegisteredAttributes::Attribute do
21
21
  let(:displayable) { true }
22
22
  let(:editable) { true }
23
23
  let(:default_value) { nil }
24
- subject { ActiveFedora::RegisteredAttributes::Attribute.new(context, field_name, options) }
24
+ subject { described_class.new(context, field_name, options) }
25
25
 
26
26
  describe '#displayable?' do
27
27
  its (:displayable?) { should == displayable }
@@ -60,7 +60,7 @@ describe ActiveFedora::RegisteredAttributes::Attribute do
60
60
  subject.with_delegation_options {|name,opts|
61
61
  @yielded = true
62
62
  expect(name).to eq(field_name)
63
- expect(opts).to eq(to: datastream, multiple: true)
63
+ expect(opts).to eq(datastream: datastream, multiple: true)
64
64
  }
65
65
  expect(@yielded).to eq(true)
66
66
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_fedora-registered_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Friesen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-03 00:00:00.000000000 Z
11
+ date: 2013-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active-fedora
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 6.6.0.rc2
19
+ version: 6.7.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 6.6.0.rc2
26
+ version: 6.7.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: active_attr
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -102,9 +102,9 @@ files:
102
102
  - lib/active_fedora/registered_attributes/attribute.rb
103
103
  - lib/active_fedora/registered_attributes/attribute_registry.rb
104
104
  - lib/active_fedora/registered_attributes/version.rb
105
- - spec/active_fedora/registered_attributes/attribute_registry_spec.rb
106
- - spec/active_fedora/registered_attributes/attribute_spec.rb
107
- - spec/active_fedora/registered_attributes_spec.rb
105
+ - spec/lib/active_fedora/registered_attributes/attribute_registry_spec.rb
106
+ - spec/lib/active_fedora/registered_attributes/attribute_spec.rb
107
+ - spec/lib/active_fedora/registered_attributes_spec.rb
108
108
  - spec/spec_helper.rb
109
109
  - spec/support/book.rb
110
110
  homepage: http://github.com/projecthydra/active_fedora-registered_attributes
@@ -127,14 +127,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  version: '0'
128
128
  requirements: []
129
129
  rubyforge_project:
130
- rubygems_version: 2.0.5
130
+ rubygems_version: 2.0.3
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: An ActiveFedora extension for registring attributes
134
134
  test_files:
135
- - spec/active_fedora/registered_attributes/attribute_registry_spec.rb
136
- - spec/active_fedora/registered_attributes/attribute_spec.rb
137
- - spec/active_fedora/registered_attributes_spec.rb
135
+ - spec/lib/active_fedora/registered_attributes/attribute_registry_spec.rb
136
+ - spec/lib/active_fedora/registered_attributes/attribute_spec.rb
137
+ - spec/lib/active_fedora/registered_attributes_spec.rb
138
138
  - spec/spec_helper.rb
139
139
  - spec/support/book.rb
140
140
  has_rdoc: