fedora_lens 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4327c804e83a80178cf702ee3a33c69aaf598b3c
4
- data.tar.gz: fe2f5b45ec70975ddd452803f998f44c0600d5c0
3
+ metadata.gz: 59868cf695e91e962aacef17bd8ca68be6fd43f4
4
+ data.tar.gz: b521e38a55129333c18b9f29e4d2e48246632e46
5
5
  SHA512:
6
- metadata.gz: ed807150e20a30089687a089fade449c9366ac7fdb4b81adff2a9f70dc9eae16a68e066f56e3e945ed22aeda5b8af96ed2feb3507e12f7f07e4972c25e5b6506
7
- data.tar.gz: fc63d6caab8880c71921e7d3e276f0faa16c59006edfe08cbf1a24d39307d7dc66da939efcfd8176a92de6925f71ccc4b7663ad5aa3c9c9ffa81f6456abbe471
6
+ metadata.gz: 12bb8eebff4fbfb97d88e482e6ada5e0fd5a23b433ed5a748441210cc4ddea23d7069ad5ad07df63039148ab7083432f528df3df4f2497c7a5671be21cfb6e48
7
+ data.tar.gz: 67531804cf5e3ea11544ff2191ccc1710006a2a83c6358a68b86b5ff18645823e4b216b0587a402673bb3c06a2e2aa41d0046739f1c920a11cc018ef0ef8400b
@@ -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]},
@@ -1,3 +1,3 @@
1
1
  module FedoraLens
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -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
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-15 00:00:00.000000000 Z
12
+ date: 2014-04-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler