active_fedora-noid 1.1.1 → 1.1.2

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: 4dfe7eb78a1ea93066a65a212cee6470d330c313
4
- data.tar.gz: 45975a62c716cabe2e686e03cb4d444fb226d1eb
3
+ metadata.gz: 58331d11f13b03e0afbb2768cefd92dc9c9f407e
4
+ data.tar.gz: 8ce905f51981b34871da889019175afbb51a255e
5
5
  SHA512:
6
- metadata.gz: 18546143cd33f6e2cc59af5080afb96510bed1e32ffbda3115317081b21a927ca1a9a7a699aebb0bc0077d2ca3e820fd4859e072c046d82c4576ea24f059d271
7
- data.tar.gz: 5d6acecefb830f970673e5a451cba0e94989f8e636bb9eb6f8f834f8eab9c489552be7eb8f6d5f56909692b307ed8cc1126566f9137756213f0de36516b1263b
6
+ metadata.gz: f518f02cd6051a6a890d837eda8de798c586fe4a24ada26b6a2480f6ab5e75f04c9374af38865a22cc07df3277448b011ea582fc32c89a41c9cc2407c874ebc3
7
+ data.tar.gz: c57803c1c8970842d232e1217257fe7a51f0717dcca2fae9d45db511bb29f955c572a4e3611930573408ad6f2705fa263f19dc87fb06f7b53258e66ab14b2033
@@ -1,5 +1,5 @@
1
1
  module ActiveFedora
2
2
  module Noid
3
- VERSION = '1.1.1'.freeze
3
+ VERSION = '1.1.2'.freeze
4
4
  end
5
5
  end
@@ -15,7 +15,9 @@ module ActiveFedora
15
15
  end
16
16
 
17
17
  def treeify(identifier)
18
- (identifier.scan(/..?/).first(4) + [identifier]).join('/')
18
+ head = identifier.split('/').first
19
+ head.gsub!(/#.*/, '')
20
+ (head.scan(/..?/).first(4) + [identifier]).join('/')
19
21
  end
20
22
  end
21
23
  end
@@ -39,10 +39,10 @@ describe ActiveFedora::Noid::Config do
39
39
 
40
40
  context "with a hash code uri" do
41
41
  let(:uri) { "http://localhost:8983/fedora/rest/test/hh/63/vz/22/hh63vz22q#g123" }
42
- it { is_expected.to eq 'hh63vz22q#g123' }
42
+ it { is_expected.to eq 'hh63vz22q#g123' }
43
43
  end
44
44
 
45
- describe 'with a short custom template' do
45
+ context 'with a short custom template' do
46
46
  let(:uri) { "http://localhost:8983/fedora/rest/test/ab/cd/abcd/members" }
47
47
  let(:custom_template) { '.reeee' }
48
48
  before { config.template = custom_template }
@@ -51,7 +51,7 @@ describe ActiveFedora::Noid::Config do
51
51
  it { is_expected.to eq 'abcd/members' }
52
52
  end
53
53
 
54
- describe 'with an even shorter custom template' do
54
+ context 'with an even shorter custom template' do
55
55
  let(:uri) { "http://localhost:8983/fedora/rest/test/ab/c/abc/members" }
56
56
  let(:custom_template) { '.reee' }
57
57
  before { config.template = custom_template }
@@ -60,7 +60,7 @@ describe ActiveFedora::Noid::Config do
60
60
  it { is_expected.to eq 'abc/members' }
61
61
  end
62
62
 
63
- describe 'with a long custom template' do
63
+ context 'with a long custom template' do
64
64
  let(:uri) { "http://localhost:8983/fedora/rest/test/ab/cd/ef/gh/abcdefghijklmnopqrstuvwxyz/members" }
65
65
  let(:custom_template) { '.reeeeeeeeeeeeeeeeeeeeeeeeee' }
66
66
  before { config.template = custom_template }
@@ -68,6 +68,48 @@ describe ActiveFedora::Noid::Config do
68
68
 
69
69
  it { is_expected.to eq 'abcdefghijklmnopqrstuvwxyz/members' }
70
70
  end
71
+ end
72
+
73
+ describe '#translate_id_to_uri' do
74
+ let(:config) { described_class.new }
75
+ let(:translator) { config.translate_id_to_uri }
76
+ let(:id) { "hh63vz2/members" }
77
+ let(:ActiveFedora) { double(ActiveFedora) }
78
+ subject { translator.call(id) }
79
+ before do
80
+ allow(ActiveFedora).to receive_message_chain("fedora.host") { "http://localhost:8983" }
81
+ allow(ActiveFedora).to receive_message_chain("fedora.base_path") { "/fedora/rest/test" }
82
+ end
83
+
84
+ it { is_expected.to eq "http://localhost:8983/fedora/rest/test/hh/63/vz/2/hh63vz2/members" }
85
+
86
+ context "with a hash code id" do
87
+ let(:id) { 'hh63vz2#g123' }
88
+ it { is_expected.to eq "http://localhost:8983/fedora/rest/test/hh/63/vz/2/hh63vz2#g123" }
89
+ end
71
90
 
91
+ context 'with a short custom template' do
92
+ let(:id) { "abcd/members" }
93
+ let(:custom_template) { '.reeee' }
94
+ before { config.template = custom_template }
95
+ subject { translator.call(id) }
96
+ it { is_expected.to eq "http://localhost:8983/fedora/rest/test/ab/cd/abcd/members" }
97
+ end
98
+
99
+ context 'with an even shorter custom template' do
100
+ let(:id) { 'abc/members' }
101
+ let(:custom_template) { '.reee' }
102
+ before { config.template = custom_template }
103
+ subject { translator.call(id) }
104
+ it { is_expected.to eq "http://localhost:8983/fedora/rest/test/ab/c/abc/members" }
105
+ end
106
+
107
+ context 'with a long custom template' do
108
+ let(:id) { "abcdefghijklmnopqrstuvwxyz/members" }
109
+ let(:custom_template) { '.reeeeeeeeeeeeeeeeeeeeeeeeee' }
110
+ before { config.template = custom_template }
111
+ subject { translator.call(id) }
112
+ it { is_expected.to eq "http://localhost:8983/fedora/rest/test/ab/cd/ef/gh/abcdefghijklmnopqrstuvwxyz/members" }
113
+ end
72
114
  end
73
115
  end
@@ -15,5 +15,9 @@ describe ActiveFedora::Noid do
15
15
  subject { ActiveFedora::Noid.treeify(id) }
16
16
  let(:id) { 'abc123def45' }
17
17
  it { is_expected.to eq 'ab/c1/23/de/abc123def45' }
18
+ context 'with a seven-digit identifier' do
19
+ let(:id) { 'abc123z' }
20
+ it { is_expected.to eq 'ab/c1/23/z/abc123z' }
21
+ end
18
22
  end
19
23
  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: 1.1.1
4
+ version: 1.1.2
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: 2016-06-15 00:00:00.000000000 Z
11
+ date: 2016-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active-fedora
@@ -146,4 +146,3 @@ test_files:
146
146
  - spec/unit/noid_spec.rb
147
147
  - spec/unit/service_spec.rb
148
148
  - spec/unit/synchronized_minter_spec.rb
149
- has_rdoc: