active_fedora-noid 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/active_fedora/noid/version.rb +1 -1
- data/lib/active_fedora/noid.rb +3 -1
- data/spec/unit/config_spec.rb +46 -4
- data/spec/unit/noid_spec.rb +4 -0
- metadata +2 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 58331d11f13b03e0afbb2768cefd92dc9c9f407e
|
|
4
|
+
data.tar.gz: 8ce905f51981b34871da889019175afbb51a255e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f518f02cd6051a6a890d837eda8de798c586fe4a24ada26b6a2480f6ab5e75f04c9374af38865a22cc07df3277448b011ea582fc32c89a41c9cc2407c874ebc3
|
|
7
|
+
data.tar.gz: c57803c1c8970842d232e1217257fe7a51f0717dcca2fae9d45db511bb29f955c572a4e3611930573408ad6f2705fa263f19dc87fb06f7b53258e66ab14b2033
|
data/lib/active_fedora/noid.rb
CHANGED
|
@@ -15,7 +15,9 @@ module ActiveFedora
|
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def treeify(identifier)
|
|
18
|
-
|
|
18
|
+
head = identifier.split('/').first
|
|
19
|
+
head.gsub!(/#.*/, '')
|
|
20
|
+
(head.scan(/..?/).first(4) + [identifier]).join('/')
|
|
19
21
|
end
|
|
20
22
|
end
|
|
21
23
|
end
|
data/spec/unit/config_spec.rb
CHANGED
|
@@ -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
|
-
|
|
42
|
+
it { is_expected.to eq 'hh63vz22q#g123' }
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
data/spec/unit/noid_spec.rb
CHANGED
|
@@ -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.
|
|
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-
|
|
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:
|