mongoid_search 0.1.1 → 0.1.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.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Mongoid Searh
1
+ Mongoid Search
2
2
  ============
3
3
 
4
4
  Mongoid Search is a simple full text search implementation for Mongoid ORM.
@@ -58,9 +58,12 @@ Note that the search is case insensitive, and accept partial searching too:
58
58
  Options
59
59
  -------
60
60
 
61
- :match - :any for match any occurrence, :all to match all ocurrences. Default is :any
61
+ :match:
62
+ :any - match any occurrence
63
+ :all - match all ocurrences
64
+ Default is :any.
62
65
 
63
- search_in :brand, :name, { :tags => :name }, { :match => :all }
66
+ search_in :brand, :name, { :tags => :name }, { :match => :any }
64
67
 
65
68
  Product.search("apple motorola").size
66
69
  => 1
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ begin
8
8
  gem.summary = "Search implementation for Mongoid ORM"
9
9
  gem.description = "Simple full text search implementation."
10
10
  gem.email = "mauricio@papodenerd.net"
11
- gem.homepage = "http://github.com/mauriciozaffari/mongoid_search"
11
+ gem.homepage = "http://www.papodenerd.net/mongoid-search-full-text-search-for-your-mongoid-models/"
12
12
  gem.authors = ["Mauricio Zaffari"]
13
13
  gem.add_dependency("mongoid", ["~> 2.0.0.beta"])
14
14
  gem.add_development_dependency "rspec", ">= 1.2.9"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -9,7 +9,7 @@ module Mongoid::Search
9
9
  # Set a field or a number of fields as sources for search
10
10
  def search_in(*args)
11
11
  options = args.last.is_a?(Hash) && (args.last.keys.first == :match) ? args.pop : {}
12
- self.match = options[:match] || :any
12
+ self.match = [:any, :all].include?(options[:match]) ? options[:match] : :any
13
13
  self.search_fields = args
14
14
 
15
15
  field :_keywords, :type => Array
@@ -19,7 +19,7 @@ module Mongoid::Search
19
19
  end
20
20
 
21
21
  def search(query)
22
- self.send("#{self.match.to_s}_in", :_keywords => KeywordsExtractor.extract(query).map { |q| /#{q}/i })
22
+ self.send("#{self.match.to_s}_in", :_keywords => KeywordsExtractor.extract(query).map { |q| /#{q}/ })
23
23
  end
24
24
  end
25
25
 
@@ -27,7 +27,11 @@ module Mongoid::Search
27
27
 
28
28
  def set_keywords
29
29
  self._keywords = self.search_fields.map do |field|
30
- field.is_a?(Hash) ? self.send(field.keys.first).map(&field.values.first).map { |t| KeywordsExtractor.extract t } : KeywordsExtractor.extract(self.send(field))
30
+ if field.is_a?(Hash)
31
+ field.keys.map { |key| self.send(key).map(&field[key]).map { |t| KeywordsExtractor.extract t } }
32
+ else
33
+ KeywordsExtractor.extract(self.send(field))
34
+ end
31
35
  end.flatten.compact.uniq
32
36
  end
33
37
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mongoid_search}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mauricio Zaffari"]
@@ -36,7 +36,7 @@ Gem::Specification.new do |s|
36
36
  "spec/spec.opts",
37
37
  "spec/spec_helper.rb"
38
38
  ]
39
- s.homepage = %q{http://github.com/mauriciozaffari/mongoid_search}
39
+ s.homepage = %q{http://www.papodenerd.net/mongoid-search-full-text-search-for-your-mongoid-models/}
40
40
  s.rdoc_options = ["--charset=UTF-8"]
41
41
  s.require_paths = ["lib"]
42
42
  s.rubygems_version = %q{1.3.7}
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Mauricio Zaffari
@@ -77,7 +77,7 @@ files:
77
77
  - spec/spec.opts
78
78
  - spec/spec_helper.rb
79
79
  has_rdoc: true
80
- homepage: http://github.com/mauriciozaffari/mongoid_search
80
+ homepage: http://www.papodenerd.net/mongoid-search-full-text-search-for-your-mongoid-models/
81
81
  licenses: []
82
82
 
83
83
  post_install_message: