active_fedora-noid 2.1.0 → 2.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: 3010e0172967f37af1602afec2ac7f6a789eadd2
4
- data.tar.gz: e1b488cf669990c9b90a50a1519854c720501837
3
+ metadata.gz: b77c4228633cc511a2c5b40bcf7846c5bdb6072a
4
+ data.tar.gz: 9c55bcce4630ec410ee377aaa3ad850b879a31a4
5
5
  SHA512:
6
- metadata.gz: 80a447788391b889081c905994d7470f75f55fc1f26be78c3d3f08292e271c8fd4793b8425b2f858c0b7814a06294cc6890ffcea1c039f33b7e9fe7e0edccc80
7
- data.tar.gz: 638ce50e9d8c6258bdf1365848f46cb11dfb70c556e559eebc66d48160aafc380f8464a251d05d98d1948e21aebabe93595e2159d6574e506b19da4333ad7c99
6
+ metadata.gz: bc8379b41b735e0ba4836b006d6f53ef7f000c4f186ff2d949042784b7cf2cba4e77cd1c62bc9de7452c5dc306d9ae4cc8ad347a6b4313fa29e3a1aa9d017df0
7
+ data.tar.gz: e5c79c8c42dab66dffa09ff5f01418177e7d7ec58d73b587434f7add3397f26dc167c38301010223618f7fac9dca3487b3257b1d652f4813c3348b9201ffe56c
data/README.md CHANGED
@@ -63,26 +63,14 @@ noid_service.valid? 'xyz123foobar'
63
63
 
64
64
  ## ActiveFedora integration
65
65
 
66
- To get ActiveFedora to automatically call your Noid service whenever a new ActiveFedora object is saved, create a method on your model called `assign_id` and have it talk to your Noid service, e.g.:
66
+ To get ActiveFedora to automatically call your Noid service whenever a new ActiveFedora object is saved, include the `ActiveFedora::Noid::Model`, e.g.:
67
67
 
68
68
  ```ruby
69
69
  # app/models/my_object.rb
70
70
  require 'active_fedora/noid'
71
71
 
72
72
  class MyObject < ActiveFedora::Base
73
- # ...
74
-
75
- def assign_id
76
- noid_service.mint
77
- end
78
-
79
- # ...
80
-
81
- private
82
-
83
- def noid_service
84
- @noid_service ||= ActiveFedora::Noid::Service.new
85
- end
73
+ include ActiveFedora::Noid::Model
86
74
  end
87
75
  ```
88
76
 
@@ -4,6 +4,7 @@ require 'active_fedora/noid/config'
4
4
  require 'active_fedora/noid/engine'
5
5
  require 'active_fedora/noid/service'
6
6
  require 'active_fedora/noid/minter'
7
+ require 'active_fedora/noid/model'
7
8
 
8
9
  module ActiveFedora
9
10
  module Noid
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveFedora
4
+ module Noid
5
+ # Mix this class into an ActiveFedora:Base model in order to have you new objects
6
+ # created with a noid id.
7
+ module Model
8
+ ## This overrides the default behavior, which is to ask Fedora for an id
9
+ # @see ActiveFedora::Persistence.assign_id
10
+ def assign_id
11
+ service.mint
12
+ end
13
+
14
+ private
15
+
16
+ def service
17
+ @service ||= ActiveFedora::Noid::Service.new
18
+ end
19
+ end
20
+ end
21
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActiveFedora
4
4
  module Noid
5
- VERSION = '2.1.0'
5
+ VERSION = '2.2.0'
6
6
  end
7
7
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ require 'spec_helper'
3
+
4
+ RSpec.describe ActiveFedora::Noid::Model do
5
+ let(:sample_class) do
6
+ Class.new(ActiveFedora::Base) do
7
+ include ActiveFedora::Noid::Model
8
+ end
9
+ end
10
+ let(:instance) { sample_class.new }
11
+ let(:service) { instance_double(ActiveFedora::Noid::Service, mint: '1234') }
12
+
13
+ before do
14
+ allow(ActiveFedora::Noid::Service).to receive(:new).and_return(service)
15
+ end
16
+
17
+ describe '#assign_id' do
18
+ it 'returns the id from the noid service' do
19
+ expect(instance.assign_id).to eq '1234'
20
+ end
21
+ end
22
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_fedora-noid
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael J. Giarlo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-18 00:00:00.000000000 Z
11
+ date: 2017-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active-fedora
@@ -190,12 +190,14 @@ files:
190
190
  - lib/active_fedora/noid/minter/base.rb
191
191
  - lib/active_fedora/noid/minter/db.rb
192
192
  - lib/active_fedora/noid/minter/file.rb
193
+ - lib/active_fedora/noid/model.rb
193
194
  - lib/active_fedora/noid/rspec.rb
194
195
  - lib/active_fedora/noid/service.rb
195
196
  - lib/active_fedora/noid/version.rb
196
197
  - lib/generators/active_fedora/noid/install_generator.rb
197
198
  - lib/generators/active_fedora/noid/seed_generator.rb
198
199
  - lib/tasks/noid_tasks.rake
200
+ - spec/models/active_fedora/noid/model_spec.rb
199
201
  - spec/models/minter_state_spec.rb
200
202
  - spec/spec_helper.rb
201
203
  - spec/support/minterstate_table.rb
@@ -232,6 +234,7 @@ signing_key:
232
234
  specification_version: 4
233
235
  summary: Noid identifier services for ActiveFedora-based applications
234
236
  test_files:
237
+ - spec/models/active_fedora/noid/model_spec.rb
235
238
  - spec/models/minter_state_spec.rb
236
239
  - spec/spec_helper.rb
237
240
  - spec/support/minterstate_table.rb