searcher 6.0.0 → 6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/searcher/class_methods.rb +2 -1
- data/lib/searcher/version.rb +1 -1
- data/searcher.sqlite3 +0 -0
- data/spec/fixtures/models.rb +2 -2
- data/spec/searcher_spec.rb +13 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a2a2e49c71167e77975cb9257b38b4bed0dadf82e807af937d383b17af9d2e9
|
4
|
+
data.tar.gz: 0535bf5523f6cda44e921c3bc4ff91d47f029ee96329e8fac0254bdb0a3fbd75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02e3b791010304f4064afc60f6c45ebf8de34fbe781f2aec7dbc5036a1db0fcf5467c7a317cac71a43cffb297f48c10068a9ef8d41ce4b9b5ade1e6b5ebcb5a9
|
7
|
+
data.tar.gz: 1feb1bbe773873cf9245a1dca4ce377732d7c8013654909ce8f3f3e25311c74b608bda74617c37d47d06ea15ef1e1c0ef7c736d8c9613c9f89657f7801b14bbe
|
data/Gemfile.lock
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'searcher/config'
|
2
|
+
require 'shellwords'
|
2
3
|
|
3
4
|
module Searcher
|
4
5
|
module ClassMethods
|
@@ -22,7 +23,7 @@ module Searcher
|
|
22
23
|
def search(query)
|
23
24
|
klass = self
|
24
25
|
|
25
|
-
result =
|
26
|
+
result = Shellwords.split(query).inject(klass) do |kls, piece|
|
26
27
|
next kls unless piece.include?(':')
|
27
28
|
|
28
29
|
name, q = piece.split(':')
|
data/lib/searcher/version.rb
CHANGED
data/searcher.sqlite3
CHANGED
Binary file
|
data/spec/fixtures/models.rb
CHANGED
@@ -9,7 +9,7 @@ end
|
|
9
9
|
class Ticket < ActiveRecord::Base
|
10
10
|
has_and_belongs_to_many :tags
|
11
11
|
belongs_to :state
|
12
|
-
|
12
|
+
|
13
13
|
searcher do
|
14
14
|
label :tag, :from => :tags, :field => "name"
|
15
15
|
label :state, :from => :state, :field => "name"
|
@@ -23,6 +23,6 @@ end
|
|
23
23
|
# Ticket with a description, tag and state.
|
24
24
|
ticket = Ticket.create(:description => "Hello world! You are awesome.")
|
25
25
|
ticket.tags << Tag.create(:name => "bug")
|
26
|
+
ticket.tags << Tag.create(:name => "visual regression")
|
26
27
|
ticket.state = State.create(:name => "Open")
|
27
28
|
ticket.save!
|
28
|
-
|
data/spec/searcher_spec.rb
CHANGED
@@ -5,10 +5,20 @@ describe Searcher do
|
|
5
5
|
let(:first_result) { subject.first }
|
6
6
|
|
7
7
|
context "habtm label search" do
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
context "one word value" do
|
9
|
+
subject { Ticket.search("tag:bug") }
|
10
|
+
it "finds a ticket" do
|
11
|
+
expect(first_result.description).to eq("Hello world! You are awesome.")
|
12
|
+
end
|
11
13
|
end
|
14
|
+
|
15
|
+
context "multiple word value" do
|
16
|
+
subject { Ticket.search(%q{tag:"visual regression"}) }
|
17
|
+
it "finds a ticket" do
|
18
|
+
expect(first_result.description).to eq("Hello world! You are awesome.")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
12
22
|
end
|
13
23
|
|
14
24
|
context "belongs_to label search" do
|