pebbles-uid 0.0.19 → 0.0.20
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/pebbles-uid/query.rb +25 -1
- data/lib/pebbles-uid/version.rb +1 -1
- data/spec/query_spec.rb +6 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98fe8a6033359135f0ecf19a028fa6df1ced9089
|
4
|
+
data.tar.gz: abce3cd9356eceebacbe10d4c30651930db04d71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efec10260b9dd0e9baf4673d3c35b1899c48c47f8282ced747443ca7e89600f1f9ce1d61b5c148f39afdbf981533875095800b14beea953a9f1ddc8fca9e5b0f
|
7
|
+
data.tar.gz: 1764799c02510c39eb7551b4c8fad90da34d55cd0e0e73741bdb0663b0c9c8f326457d59bf787d9ae1421a05a2d7b7f46a0a58c7623c9f9c1e1732ead8b2448c
|
data/lib/pebbles-uid/query.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "its";
|
1
2
|
module Pebbles
|
2
3
|
class Uid
|
3
4
|
class Query
|
@@ -13,7 +14,9 @@ module Pebbles
|
|
13
14
|
@suffix = options[:suffix]
|
14
15
|
@stop = options.fetch(:stop) { NO_MARKER }
|
15
16
|
|
16
|
-
if
|
17
|
+
if multi_oid_query?
|
18
|
+
@terms = expand_uid(term)
|
19
|
+
elsif wildcard_query?
|
17
20
|
@terms = [term]
|
18
21
|
else
|
19
22
|
@terms = extract_terms
|
@@ -118,6 +121,27 @@ module Pebbles
|
|
118
121
|
false
|
119
122
|
end
|
120
123
|
|
124
|
+
def multi_oid_query?
|
125
|
+
_, _, oid = Pebbles::Uid.parse(term)
|
126
|
+
oid and oid.include?('|')
|
127
|
+
end
|
128
|
+
|
129
|
+
def expand_uid(uid)
|
130
|
+
_species, _path, _oid = Pebbles::Uid.parse(uid)
|
131
|
+
path_labels = Labels.new(_path)
|
132
|
+
oid_box = Oid.new(_oid)
|
133
|
+
|
134
|
+
raise ArgumentError.new('Realm must be specified') if path_labels.empty? || path_labels.first == '*'
|
135
|
+
|
136
|
+
if oid_box.multiple?
|
137
|
+
_oid.split('|').map do |s|
|
138
|
+
"#{_species}:#{_path}$#{s}"
|
139
|
+
end
|
140
|
+
else
|
141
|
+
uid
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
121
145
|
def extract_terms
|
122
146
|
term.split(',').map do |uid|
|
123
147
|
_species, _path, _oid = Pebbles::Uid.parse(uid)
|
data/lib/pebbles-uid/version.rb
CHANGED
data/spec/query_spec.rb
CHANGED
@@ -67,8 +67,12 @@ describe Pebbles::Uid::Query do
|
|
67
67
|
query.cache_keys.should eq(['post:area51.*$abc', 'post:area51.*$xyz'])
|
68
68
|
end
|
69
69
|
|
70
|
-
it "
|
71
|
-
|
70
|
+
it "works with wildcard as class" do
|
71
|
+
Pebbles::Uid::Query.new('*:area51.*$abc|xyz').list?.should == true
|
72
|
+
end
|
73
|
+
|
74
|
+
it "works with a trailing pipe on oid" do
|
75
|
+
Pebbles::Uid::Query.new('*:area51.*$abc|').list?.should == true
|
72
76
|
end
|
73
77
|
|
74
78
|
it "must have only one realm" do
|