showcase_filter 0.0.1 → 0.0.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/showcase_filter.rb +3 -0
- data/lib/showcase_filter/core.rb +3 -3
- data/lib/showcase_filter/version.rb +1 -1
- data/spec/lib/showcase_filter_spec.rb +10 -1
- 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: 087d61973649b6ffd53c8edb667ea8c09ef5694e
|
4
|
+
data.tar.gz: 1433038e40759343a30ff459f17185bb49a24922
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f390298105e865e836dc5fc3f6a3c16ad7e477da32795588c5bf6ddd3e1cee5bc62f8b78def9e4e857ce0e80eaafde9c8217ee79fdbf059fb2820c291437f96
|
7
|
+
data.tar.gz: 3475e2afd9ff41350495a0f55d79dbe6171a12ff52d2eb3c39686406f63e3c0f4243d92b350b65bae38a7efa13e26da760ef13a82e180deae6aeb7c3a10e9a4f
|
data/lib/showcase_filter.rb
CHANGED
data/lib/showcase_filter/core.rb
CHANGED
@@ -37,15 +37,15 @@ module ShowcaseFilter
|
|
37
37
|
|
38
38
|
def self.evaluate_expression(expression)
|
39
39
|
# Supported operators are : union(+), exclusion(-) and intersection(&)
|
40
|
-
regex = /(
|
40
|
+
regex = /([[:alpha:]|\s]+)\s*(\+|\-|\&)\s*(\w+)/i
|
41
41
|
match_result = expression.match(regex)
|
42
42
|
return nil if match_result.nil?
|
43
43
|
|
44
44
|
ShowcaseFilter::Models::Expression.new({
|
45
45
|
:expression => match_result[0],
|
46
46
|
:operator => match_result[2],
|
47
|
-
:group1 => match_result[1],
|
48
|
-
:group2 => match_result[3]
|
47
|
+
:group1 => match_result[1].strip,
|
48
|
+
:group2 => match_result[3].strip
|
49
49
|
})
|
50
50
|
end
|
51
51
|
end
|
@@ -30,6 +30,14 @@ describe ShowcaseFilter do
|
|
30
30
|
expect(s.find_by_label("azul").label).to eq "azul"
|
31
31
|
}
|
32
32
|
|
33
|
+
it "should work with alias" do
|
34
|
+
s = ShowcaseFilter.filter(variants) do |e,ex|
|
35
|
+
e.color
|
36
|
+
end
|
37
|
+
|
38
|
+
expect(s.find_by_label("azul").label).to eq "azul"
|
39
|
+
end
|
40
|
+
|
33
41
|
it "concat group collections should generate a new GroupCollection" do
|
34
42
|
g1 = ShowcaseFilter::Models::GroupCollection.new([1])
|
35
43
|
g2 = ShowcaseFilter::Models::GroupCollection.new([2])
|
@@ -43,7 +51,8 @@ describe ShowcaseFilter do
|
|
43
51
|
{ :type => "union", :expression => "dog+cat", :match1 => "dog", :match2 => "+", :match3 => "cat" },
|
44
52
|
{ :type => "intersection", :expression => "dog&cat", :match1 => "dog", :match2 => "&", :match3 => "cat" },
|
45
53
|
{ :type => "exclusion", :expression => "dog-cat", :match1 => "dog", :match2 => "-", :match3 => "cat" },
|
46
|
-
{ :type => "spaces", :expression => "dog + cat", :match1 => "dog", :match2 => "+", :match3 => "cat" }
|
54
|
+
{ :type => "spaces", :expression => "dog + cat", :match1 => "dog", :match2 => "+", :match3 => "cat" },
|
55
|
+
{ :type => 'acents', :expression => "verde água & p", :match1 => "verde água", :match2 => "&", :match3 => "p"}
|
47
56
|
].each do |info|
|
48
57
|
it "should evaluate #{info[:type]} expression" do
|
49
58
|
match = ShowcaseFilter::Core.evaluate_expression(info[:expression])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: showcase_filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Santana
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-03-
|
12
|
+
date: 2015-03-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|