clortho 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/clortho.gemspec +6 -6
- data/lib/clortho.rb +8 -8
- data/test/test_clortho.rb +9 -0
- metadata +18 -20
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/clortho.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{clortho}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date = %q{2011-08-
|
11
|
+
s.authors = [%q{Mark Coates}]
|
12
|
+
s.date = %q{2011-08-04}
|
13
13
|
s.description = %q{Clortho makes keyword and full-text search a breeze for MongoMapper users.}
|
14
14
|
s.email = %q{mark.coates@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -31,9 +31,9 @@ Gem::Specification.new do |s|
|
|
31
31
|
"test/test_clortho.rb"
|
32
32
|
]
|
33
33
|
s.homepage = %q{http://github.com/oddlyzen/clortho}
|
34
|
-
s.licenses = [
|
35
|
-
s.require_paths = [
|
36
|
-
s.rubygems_version = %q{1.6
|
34
|
+
s.licenses = [%q{MIT}]
|
35
|
+
s.require_paths = [%q{lib}]
|
36
|
+
s.rubygems_version = %q{1.8.6}
|
37
37
|
s.summary = %q{Clortho: the Key(word) Master adds search to your MongoMapper classes.}
|
38
38
|
|
39
39
|
if s.respond_to? :specification_version then
|
data/lib/clortho.rb
CHANGED
@@ -8,7 +8,9 @@ module MongoMapper
|
|
8
8
|
class_inheritable_accessor :searchable_with_options
|
9
9
|
write_inheritable_attribute :searchable_with_options, []
|
10
10
|
set_callback :create, :before, :inject_default_keywords
|
11
|
+
set_callback :update, :before, :inject_default_keywords
|
11
12
|
extend ClassMethods
|
13
|
+
include InstanceMethods
|
12
14
|
end
|
13
15
|
|
14
16
|
module ExclusionConstants
|
@@ -16,7 +18,7 @@ module MongoMapper
|
|
16
18
|
VERBS = %w(have has had do does did be am is are was were having
|
17
19
|
been can could shall should will would may might must being)
|
18
20
|
# Article adjectives are normally fluff and offer no additional context or meaning
|
19
|
-
ADJECTIVES = %w(a
|
21
|
+
ADJECTIVES = %w(an a the)
|
20
22
|
end
|
21
23
|
|
22
24
|
module ClassMethods
|
@@ -47,14 +49,12 @@ module MongoMapper
|
|
47
49
|
end
|
48
50
|
|
49
51
|
module InstanceMethods
|
50
|
-
|
51
|
-
@defaults_set = false
|
52
|
-
|
52
|
+
|
53
53
|
def inject_default_keywords
|
54
54
|
searchable_with_options.each do |field|
|
55
55
|
if !self.send(field[0]).nil?
|
56
|
-
|
57
|
-
keywords = filter_and_normalize(
|
56
|
+
text = self.send(field[0]).to_s
|
57
|
+
keywords = filter_and_normalize(!field[1][:exclude].nil? ? filter_on_exclusions(field, filter_and_normalize(text)) : text)
|
58
58
|
self.send("#{field[0].to_s}_keywords=".to_sym, keywords) if keywords
|
59
59
|
self.send("#{field[0].to_s}_keywords_array=".to_sym, keywords.split.each{ |kw| kw.downcase }) if keywords
|
60
60
|
end
|
@@ -67,13 +67,13 @@ module MongoMapper
|
|
67
67
|
|
68
68
|
options[:exclude].each do |exclusion|
|
69
69
|
if exclusion.is_a? String
|
70
|
-
keywords.gsub!(exclusion
|
70
|
+
keywords.gsub!(/(\b#{exclusion}\b)/, '')
|
71
71
|
elsif exclusion.is_a? Symbol
|
72
72
|
klass = self.class
|
73
73
|
ex = exclusion.to_s.upcase.to_sym
|
74
74
|
if Clortho::ExclusionConstants::const_get(ex)
|
75
75
|
Clortho::ExclusionConstants::const_get(ex).each do |e|
|
76
|
-
keywords.gsub!(e
|
76
|
+
keywords.gsub!(/(\b#{e}\b)/, '')
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
data/test/test_clortho.rb
CHANGED
@@ -87,6 +87,15 @@ class TestClortho < Test::Unit::TestCase
|
|
87
87
|
assert @colonial.body_keywords !=~ /\-\-/
|
88
88
|
end
|
89
89
|
|
90
|
+
should 're-inject keywords on update' do
|
91
|
+
@fridge.about = 'Everyone will Wang Chung tonight.'
|
92
|
+
@colonial.about = 'The ape does bite a Man!'
|
93
|
+
@fridge.save
|
94
|
+
@colonial.save
|
95
|
+
assert @fridge.about_keywords == 'everyone wang chung tonight'
|
96
|
+
assert @colonial.about_keywords == 'ape bite man'
|
97
|
+
end
|
98
|
+
|
90
99
|
def teardown
|
91
100
|
Post.destroy_all
|
92
101
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clortho
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
13
|
-
default_executable:
|
12
|
+
date: 2011-08-04 00:00:00.000000000Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: shoulda
|
17
|
-
requirement: &
|
16
|
+
requirement: &2169990840 !ruby/object:Gem::Requirement
|
18
17
|
none: false
|
19
18
|
requirements:
|
20
19
|
- - ! '>='
|
@@ -22,10 +21,10 @@ dependencies:
|
|
22
21
|
version: '0'
|
23
22
|
type: :development
|
24
23
|
prerelease: false
|
25
|
-
version_requirements: *
|
24
|
+
version_requirements: *2169990840
|
26
25
|
- !ruby/object:Gem::Dependency
|
27
26
|
name: bundler
|
28
|
-
requirement: &
|
27
|
+
requirement: &2169982740 !ruby/object:Gem::Requirement
|
29
28
|
none: false
|
30
29
|
requirements:
|
31
30
|
- - ~>
|
@@ -33,10 +32,10 @@ dependencies:
|
|
33
32
|
version: 1.0.0
|
34
33
|
type: :development
|
35
34
|
prerelease: false
|
36
|
-
version_requirements: *
|
35
|
+
version_requirements: *2169982740
|
37
36
|
- !ruby/object:Gem::Dependency
|
38
37
|
name: jeweler
|
39
|
-
requirement: &
|
38
|
+
requirement: &2169980080 !ruby/object:Gem::Requirement
|
40
39
|
none: false
|
41
40
|
requirements:
|
42
41
|
- - ~>
|
@@ -44,10 +43,10 @@ dependencies:
|
|
44
43
|
version: 1.6.4
|
45
44
|
type: :development
|
46
45
|
prerelease: false
|
47
|
-
version_requirements: *
|
46
|
+
version_requirements: *2169980080
|
48
47
|
- !ruby/object:Gem::Dependency
|
49
48
|
name: rcov
|
50
|
-
requirement: &
|
49
|
+
requirement: &2169978800 !ruby/object:Gem::Requirement
|
51
50
|
none: false
|
52
51
|
requirements:
|
53
52
|
- - ! '>='
|
@@ -55,10 +54,10 @@ dependencies:
|
|
55
54
|
version: '0'
|
56
55
|
type: :development
|
57
56
|
prerelease: false
|
58
|
-
version_requirements: *
|
57
|
+
version_requirements: *2169978800
|
59
58
|
- !ruby/object:Gem::Dependency
|
60
59
|
name: mongo_mapper
|
61
|
-
requirement: &
|
60
|
+
requirement: &2169976940 !ruby/object:Gem::Requirement
|
62
61
|
none: false
|
63
62
|
requirements:
|
64
63
|
- - ~>
|
@@ -66,10 +65,10 @@ dependencies:
|
|
66
65
|
version: 0.9.0
|
67
66
|
type: :development
|
68
67
|
prerelease: false
|
69
|
-
version_requirements: *
|
68
|
+
version_requirements: *2169976940
|
70
69
|
- !ruby/object:Gem::Dependency
|
71
70
|
name: taggregator
|
72
|
-
requirement: &
|
71
|
+
requirement: &2169974840 !ruby/object:Gem::Requirement
|
73
72
|
none: false
|
74
73
|
requirements:
|
75
74
|
- - ! '>='
|
@@ -77,10 +76,10 @@ dependencies:
|
|
77
76
|
version: '0'
|
78
77
|
type: :development
|
79
78
|
prerelease: false
|
80
|
-
version_requirements: *
|
79
|
+
version_requirements: *2169974840
|
81
80
|
- !ruby/object:Gem::Dependency
|
82
81
|
name: pry
|
83
|
-
requirement: &
|
82
|
+
requirement: &2169969600 !ruby/object:Gem::Requirement
|
84
83
|
none: false
|
85
84
|
requirements:
|
86
85
|
- - ! '>='
|
@@ -88,7 +87,7 @@ dependencies:
|
|
88
87
|
version: '0'
|
89
88
|
type: :development
|
90
89
|
prerelease: false
|
91
|
-
version_requirements: *
|
90
|
+
version_requirements: *2169969600
|
92
91
|
description: Clortho makes keyword and full-text search a breeze for MongoMapper users.
|
93
92
|
email: mark.coates@gmail.com
|
94
93
|
executables: []
|
@@ -109,7 +108,6 @@ files:
|
|
109
108
|
- test/helper.rb
|
110
109
|
- test/models/post.rb
|
111
110
|
- test/test_clortho.rb
|
112
|
-
has_rdoc: true
|
113
111
|
homepage: http://github.com/oddlyzen/clortho
|
114
112
|
licenses:
|
115
113
|
- MIT
|
@@ -125,7 +123,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
123
|
version: '0'
|
126
124
|
segments:
|
127
125
|
- 0
|
128
|
-
hash:
|
126
|
+
hash: -2521455955088639471
|
129
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
128
|
none: false
|
131
129
|
requirements:
|
@@ -134,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
132
|
version: '0'
|
135
133
|
requirements: []
|
136
134
|
rubyforge_project:
|
137
|
-
rubygems_version: 1.6
|
135
|
+
rubygems_version: 1.8.6
|
138
136
|
signing_key:
|
139
137
|
specification_version: 3
|
140
138
|
summary: ! 'Clortho: the Key(word) Master adds search to your MongoMapper classes.'
|