pebbles-uid 0.0.19 → 0.0.20

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: 9f1bf5b61101cf67c6f0ef169d4cd9233db7f9ec
4
- data.tar.gz: 530393b0ea0648008ac270b41ac98a79eb90a9b8
3
+ metadata.gz: 98fe8a6033359135f0ecf19a028fa6df1ced9089
4
+ data.tar.gz: abce3cd9356eceebacbe10d4c30651930db04d71
5
5
  SHA512:
6
- metadata.gz: 433861dfdd24ec9dc4e03363a3c208d00e1177f98a2246f4e8d2871ba3c57b9e6b79f2e32adb066deeaa1b98968a28580a7efcac2be43d38a5f86431afe1112e
7
- data.tar.gz: 7e808508c3028bc0649c0ba37c7d5d36419c2104b96e42ef9bb99b037e583d9e5d866d0cc587c1de913674a917ce88aed8bcddd0315308955fa8296aa95cbe52
6
+ metadata.gz: efec10260b9dd0e9baf4673d3c35b1899c48c47f8282ced747443ca7e89600f1f9ce1d61b5c148f39afdbf981533875095800b14beea953a9f1ddc8fca9e5b0f
7
+ data.tar.gz: 1764799c02510c39eb7551b4c8fad90da34d55cd0e0e73741bdb0663b0c9c8f326457d59bf787d9ae1421a05a2d7b7f46a0a58c7623c9f9c1e1732ead8b2448c
@@ -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 wildcard_query?
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)
@@ -1,5 +1,5 @@
1
1
  module Pebbles
2
2
  class Uid
3
- VERSION = "0.0.19"
3
+ VERSION = "0.0.20"
4
4
  end
5
5
  end
@@ -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 "bails without realm" do
71
- ->{ Pebbles::Uid::Query.new('post:*$abc,post:*$xyz') }.should raise_error(ArgumentError)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pebbles-uid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katrina Owen