fedora_lens 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fedora_lens/lenses.rb +13 -0
- data/lib/fedora_lens/version.rb +1 -1
- data/spec/fedora_lens/lenses_spec.rb +43 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59868cf695e91e962aacef17bd8ca68be6fd43f4
|
4
|
+
data.tar.gz: b521e38a55129333c18b9f29e4d2e48246632e46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12bb8eebff4fbfb97d88e482e6ada5e0fd5a23b433ed5a748441210cc4ddea23d7069ad5ad07df63039148ab7083432f528df3df4f2497c7a5671be21cfb6e48
|
7
|
+
data.tar.gz: 67531804cf5e3ea11544ff2191ccc1710006a2a83c6358a68b86b5ff18645823e4b216b0587a402673bb3c06a2e2aa41d0046739f1c920a11cc018ef0ef8400b
|
data/lib/fedora_lens/lenses.rb
CHANGED
@@ -47,6 +47,19 @@ module FedoraLens
|
|
47
47
|
]
|
48
48
|
end
|
49
49
|
|
50
|
+
def uris_to_ids
|
51
|
+
Lens[
|
52
|
+
get: lambda do |source|
|
53
|
+
source.map { |uri| URI.parse(uri).to_s.sub(HOST + PATH, '') }
|
54
|
+
end,
|
55
|
+
put: lambda do |sources, values|
|
56
|
+
Array(values).compact.map do |value|
|
57
|
+
RDF::URI.new(HOST + PATH + value)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
]
|
61
|
+
end
|
62
|
+
|
50
63
|
def hash_update
|
51
64
|
Lens[
|
52
65
|
get: lambda {|hash| hash[key]},
|
data/lib/fedora_lens/version.rb
CHANGED
@@ -56,6 +56,49 @@ module FedoraLens
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
describe ".uris_to_ids" do
|
60
|
+
let(:lens) { Lenses.uris_to_ids }
|
61
|
+
|
62
|
+
let(:original) { [RDF::URI.new(HOST+PATH+'/id/123'), RDF::URI.new(HOST+PATH+'/id/321')] }
|
63
|
+
|
64
|
+
describe "#get" do
|
65
|
+
subject { lens.get(input) }
|
66
|
+
|
67
|
+
context "with exiting content" do
|
68
|
+
let(:input) { original }
|
69
|
+
it "casts them to string" do
|
70
|
+
expect(subject).to eq ['/id/123', '/id/321']
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "with an empty result" do
|
75
|
+
let(:input) { [] }
|
76
|
+
it "casts them to string" do
|
77
|
+
expect(subject).to eq []
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "#put" do
|
83
|
+
subject { lens.put(original, input) }
|
84
|
+
|
85
|
+
context "with new values " do
|
86
|
+
let(:input) { ['/id/777', '/id/888'] }
|
87
|
+
it "overwrites the items" do
|
88
|
+
expect(subject).to eq [RDF::URI.new(HOST+PATH+'/id/777'), RDF::URI.new(HOST+PATH+'/id/888')]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "with an empty set" do
|
93
|
+
let(:input) { [nil] }
|
94
|
+
it "casts them to string" do
|
95
|
+
expect(subject).to eq []
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
59
102
|
describe ".as_dom" do
|
60
103
|
it "converts xml to a Nokogiri::XML::Document" do
|
61
104
|
xml = "<foo><bar>content</bar></foo>"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fedora_lens
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|