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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4eb69651c6c8a4237406d4bd25f47fcfa10d59679ed5b0e07a71ffbc742f20cf
4
- data.tar.gz: 8733222ec9ade3fb808cb0e9a7dae0059fba5a0ba7da22437188fb7042a6cb7c
3
+ metadata.gz: 1a2a2e49c71167e77975cb9257b38b4bed0dadf82e807af937d383b17af9d2e9
4
+ data.tar.gz: 0535bf5523f6cda44e921c3bc4ff91d47f029ee96329e8fac0254bdb0a3fbd75
5
5
  SHA512:
6
- metadata.gz: 6cd72fc4ff1e9423740822169365aaeaae03003dd11b182295f84676dc3ada69f22c0913b2373decd029c20c746347954ae19fc3e9c91d562c4157c037212a68
7
- data.tar.gz: 8e3743a5c5f3d759b6d132fcaf847c0f643de2ded548a06974ffb1a0bf6a08a845f872f0bf6d2288fca0ade0ff4234fe5288137c2ba540862a75533d2bc1d2dc
6
+ metadata.gz: 02e3b791010304f4064afc60f6c45ebf8de34fbe781f2aec7dbc5036a1db0fcf5467c7a317cac71a43cffb297f48c10068a9ef8d41ce4b9b5ade1e6b5ebcb5a9
7
+ data.tar.gz: 1feb1bbe773873cf9245a1dca4ce377732d7c8013654909ce8f3f3e25311c74b608bda74617c37d47d06ea15ef1e1c0ef7c736d8c9613c9f89657f7801b14bbe
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- searcher (0.0.7)
4
+ searcher (6.0.0)
5
5
  activerecord (~> 6.0)
6
6
 
7
7
  GEM
@@ -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 = query.split(' ').inject(klass) do |kls, piece|
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(':')
@@ -1,3 +1,3 @@
1
1
  module Searcher
2
- VERSION = "6.0.0"
2
+ VERSION = "6.0.1"
3
3
  end
Binary file
@@ -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
-
@@ -5,10 +5,20 @@ describe Searcher do
5
5
  let(:first_result) { subject.first }
6
6
 
7
7
  context "habtm label search" do
8
- subject { Ticket.search("tag:bug") }
9
- it "finds a ticket" do
10
- expect(first_result.description).to eq("Hello world! You are awesome.")
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0
4
+ version: 6.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bigg