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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b9efe3a7eae6a21bc263f7bc758aa8de6b11c275
4
- data.tar.gz: e464717f66488bf624ba072bff344d28da6f012a
3
+ metadata.gz: 087d61973649b6ffd53c8edb667ea8c09ef5694e
4
+ data.tar.gz: 1433038e40759343a30ff459f17185bb49a24922
5
5
  SHA512:
6
- metadata.gz: 032dd8b2f033415543f5ab4879f7fb5915e5d07c705650c874a248fba2e00e771315a4fc4c30411135be08c498b2a7f673d1244c00965c042437478ee4d7299b
7
- data.tar.gz: 60da9f8b18cff20b6eecfebe56ca39cd7d90607907f188d50d31b13382ca8912dc0d2d06983ded2565852fb226b005ceafc6386b590dd7829faa13e88cd8e8b2
6
+ metadata.gz: 5f390298105e865e836dc5fc3f6a3c16ad7e477da32795588c5bf6ddd3e1cee5bc62f8b78def9e4e857ce0e80eaafde9c8217ee79fdbf059fb2820c291437f96
7
+ data.tar.gz: 3475e2afd9ff41350495a0f55d79dbe6171a12ff52d2eb3c39686406f63e3c0f4243d92b350b65bae38a7efa13e26da760ef13a82e180deae6aeb7c3a10e9a4f
@@ -8,4 +8,7 @@ require "showcase_filter/models/expression"
8
8
 
9
9
 
10
10
  module ShowcaseFilter
11
+ def self.filter(*args, &block)
12
+ ShowcaseFilter::Core.filter(*args, &block)
13
+ end
11
14
  end
@@ -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 = /(\w+)\s*(\+|\-|\&)\s*(\w+)/
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
@@ -1,3 +1,3 @@
1
1
  module ShowcaseFilter
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  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.1
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-05 00:00:00.000000000 Z
12
+ date: 2015-03-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler