pose 3.0.0 → 3.1.1
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 +4 -4
- data/README.md +42 -19
- data/Rakefile +37 -5
- data/lib/pose/activerecord_base_additions.rb +7 -6
- data/{app/models → lib}/pose/assignment.rb +6 -1
- data/lib/pose/jobs/install.rb +27 -0
- data/lib/pose/jobs/reindex_all.rb +34 -0
- data/lib/pose/jobs/remove.rb +28 -0
- data/lib/pose/jobs/uninstall.rb +19 -0
- data/lib/pose/jobs/vacuum.rb +23 -0
- data/lib/pose/model_class_additions.rb +32 -14
- data/lib/pose/query.rb +49 -9
- data/lib/pose/search.rb +5 -5
- data/lib/pose/static_api.rb +21 -3
- data/lib/pose/version.rb +1 -1
- data/lib/pose/word.rb +33 -0
- data/lib/pose.rb +11 -5
- data/lib/tasks/pose_tasks.rake +16 -27
- data/spec/{dummy/db/development.sqlite3 → db/pose.sqlite3} +0 -0
- data/spec/factories/posable_one.rb +2 -0
- data/spec/factories/posable_three.rb +8 -0
- data/spec/factories/posable_two.rb +2 -0
- data/spec/factories/user.rb +2 -0
- data/spec/lib/pose/activerecord_base_additions_spec.rb +11 -0
- data/spec/{models → lib/pose}/assignment_spec.rb +5 -5
- data/spec/lib/pose/jobs/reindex_all_spec.rb +31 -0
- data/spec/lib/pose/jobs/remove_spec.rb +20 -0
- data/spec/lib/pose/model_class_additions_spec.rb +150 -0
- data/spec/lib/pose/query_spec.rb +106 -8
- data/spec/lib/pose/search_spec.rb +2 -22
- data/spec/lib/pose/word_spec.rb +68 -0
- data/spec/pose_api_spec.rb +33 -13
- data/spec/spec_helper.rb +4 -32
- data/spec/support/config/database.yml +51 -0
- data/spec/support/config/database.yml.example +16 -0
- data/spec/{dummy/db/migrate → support/migrations}/20130308054001_create_posable_one.rb +0 -0
- data/spec/{dummy/db/migrate → support/migrations}/20130308054142_create_posable_two.rb +0 -0
- data/spec/support/migrations/20130308054143_create_posable_three.rb +9 -0
- data/spec/{dummy/db/migrate → support/migrations}/20130708084009_create_users.rb +0 -0
- data/spec/support/migrations/20130808084009_setup_pose_specs.rb +5 -0
- data/spec/{dummy/app → support}/models/posable_one.rb +1 -1
- data/spec/support/models/posable_three.rb +10 -0
- data/spec/{dummy/app → support}/models/posable_two.rb +1 -1
- data/spec/{dummy/app → support}/models/user.rb +1 -1
- data/spec/support/spec_manager.rb +105 -0
- metadata +70 -101
- data/app/models/pose/word.rb +0 -22
- data/db/migrate/20130308144915_pose_install.rb +0 -18
- data/lib/generators/pose/install/install_generator.rb +0 -56
- data/lib/generators/pose/install/templates/install_migration.rb +0 -24
- data/lib/generators/pose/remove/remove_generator.rb +0 -56
- data/lib/generators/pose/remove/templates/remove_migration.rb +0 -23
- data/lib/generators/pose/upgrade/templates/upgrade_migration.rb +0 -7
- data/lib/generators/pose/upgrade/upgrade_generator.rb +0 -35
- data/lib/pose/engine.rb +0 -5
- data/lib/pose/helpers.rb +0 -89
- data/lib/pose/railtie.rb +0 -19
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/config/application.rb +0 -23
- data/spec/dummy/config/boot.rb +0 -10
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -30
- data/spec/dummy/config/environments/production.rb +0 -81
- data/spec/dummy/config/environments/test.rb +0 -37
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -15
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/config/initializers/session_store.rb +0 -8
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/routes.rb +0 -2
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/db/schema.rb +0 -47
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -309
- data/spec/dummy/log/test.log +0 -88518
- data/spec/dummy/script/rails +0 -6
- data/spec/lib/pose/helpers_spec.rb +0 -147
- data/spec/models/word_spec.rb +0 -42
metadata
CHANGED
@@ -1,111 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Goslar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: ruby-progressbar
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: factory_girl_rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: faker
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: guard-rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rspec-rails
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: sqlite3
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
description: Pose ('Polymorphic Search') allows fulltext search for ActiveRecord objects.
|
@@ -115,72 +115,54 @@ executables: []
|
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
-
|
119
|
-
-
|
120
|
-
-
|
121
|
-
- lib/
|
122
|
-
- lib/generators/pose/install/templates/install_migration.rb
|
123
|
-
- lib/generators/pose/remove/remove_generator.rb
|
124
|
-
- lib/generators/pose/remove/templates/remove_migration.rb
|
125
|
-
- lib/generators/pose/upgrade/templates/upgrade_migration.rb
|
126
|
-
- lib/generators/pose/upgrade/upgrade_generator.rb
|
118
|
+
- MIT-LICENSE
|
119
|
+
- README.md
|
120
|
+
- Rakefile
|
121
|
+
- lib/pose.rb
|
127
122
|
- lib/pose/activerecord_base_additions.rb
|
128
|
-
- lib/pose/
|
129
|
-
- lib/pose/
|
123
|
+
- lib/pose/assignment.rb
|
124
|
+
- lib/pose/jobs/install.rb
|
125
|
+
- lib/pose/jobs/reindex_all.rb
|
126
|
+
- lib/pose/jobs/remove.rb
|
127
|
+
- lib/pose/jobs/uninstall.rb
|
128
|
+
- lib/pose/jobs/vacuum.rb
|
130
129
|
- lib/pose/model_class_additions.rb
|
131
130
|
- lib/pose/query.rb
|
132
|
-
- lib/pose/railtie.rb
|
133
131
|
- lib/pose/search.rb
|
134
132
|
- lib/pose/static_api.rb
|
135
133
|
- lib/pose/version.rb
|
136
|
-
- lib/pose.rb
|
134
|
+
- lib/pose/word.rb
|
137
135
|
- lib/tasks/pose_tasks.rake
|
138
|
-
-
|
139
|
-
- Rakefile
|
140
|
-
- README.md
|
141
|
-
- spec/dummy/app/models/posable_one.rb
|
142
|
-
- spec/dummy/app/models/posable_two.rb
|
143
|
-
- spec/dummy/app/models/user.rb
|
144
|
-
- spec/dummy/config/application.rb
|
145
|
-
- spec/dummy/config/boot.rb
|
146
|
-
- spec/dummy/config/database.yml
|
147
|
-
- spec/dummy/config/environment.rb
|
148
|
-
- spec/dummy/config/environments/development.rb
|
149
|
-
- spec/dummy/config/environments/production.rb
|
150
|
-
- spec/dummy/config/environments/test.rb
|
151
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
152
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
153
|
-
- spec/dummy/config/initializers/inflections.rb
|
154
|
-
- spec/dummy/config/initializers/mime_types.rb
|
155
|
-
- spec/dummy/config/initializers/secret_token.rb
|
156
|
-
- spec/dummy/config/initializers/session_store.rb
|
157
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
158
|
-
- spec/dummy/config/locales/en.yml
|
159
|
-
- spec/dummy/config/routes.rb
|
160
|
-
- spec/dummy/config.ru
|
161
|
-
- spec/dummy/db/development.sqlite3
|
162
|
-
- spec/dummy/db/migrate/20130308054001_create_posable_one.rb
|
163
|
-
- spec/dummy/db/migrate/20130308054142_create_posable_two.rb
|
164
|
-
- spec/dummy/db/migrate/20130708084009_create_users.rb
|
165
|
-
- spec/dummy/db/schema.rb
|
166
|
-
- spec/dummy/db/test.sqlite3
|
167
|
-
- spec/dummy/log/development.log
|
168
|
-
- spec/dummy/log/test.log
|
169
|
-
- spec/dummy/Rakefile
|
170
|
-
- spec/dummy/script/rails
|
136
|
+
- spec/db/pose.sqlite3
|
171
137
|
- spec/factories/assignments.rb
|
172
138
|
- spec/factories/posable_one.rb
|
139
|
+
- spec/factories/posable_three.rb
|
173
140
|
- spec/factories/posable_two.rb
|
174
141
|
- spec/factories/user.rb
|
175
142
|
- spec/factories/words.rb
|
176
|
-
- spec/lib/pose/
|
143
|
+
- spec/lib/pose/activerecord_base_additions_spec.rb
|
144
|
+
- spec/lib/pose/assignment_spec.rb
|
145
|
+
- spec/lib/pose/jobs/reindex_all_spec.rb
|
146
|
+
- spec/lib/pose/jobs/remove_spec.rb
|
147
|
+
- spec/lib/pose/model_class_additions_spec.rb
|
177
148
|
- spec/lib/pose/query_spec.rb
|
178
149
|
- spec/lib/pose/search_spec.rb
|
179
|
-
- spec/
|
180
|
-
- spec/models/word_spec.rb
|
150
|
+
- spec/lib/pose/word_spec.rb
|
181
151
|
- spec/pose_api_spec.rb
|
182
152
|
- spec/spec_helper.rb
|
153
|
+
- spec/support/config/database.yml
|
154
|
+
- spec/support/config/database.yml.example
|
183
155
|
- spec/support/matchers.rb
|
156
|
+
- spec/support/migrations/20130308054001_create_posable_one.rb
|
157
|
+
- spec/support/migrations/20130308054142_create_posable_two.rb
|
158
|
+
- spec/support/migrations/20130308054143_create_posable_three.rb
|
159
|
+
- spec/support/migrations/20130708084009_create_users.rb
|
160
|
+
- spec/support/migrations/20130808084009_setup_pose_specs.rb
|
161
|
+
- spec/support/models/posable_one.rb
|
162
|
+
- spec/support/models/posable_three.rb
|
163
|
+
- spec/support/models/posable_two.rb
|
164
|
+
- spec/support/models/user.rb
|
165
|
+
- spec/support/spec_manager.rb
|
184
166
|
homepage: http://github.com/kevgo/pose
|
185
167
|
licenses: []
|
186
168
|
metadata: {}
|
@@ -198,61 +180,48 @@ require_paths:
|
|
198
180
|
- lib
|
199
181
|
required_ruby_version: !ruby/object:Gem::Requirement
|
200
182
|
requirements:
|
201
|
-
- -
|
183
|
+
- - ">="
|
202
184
|
- !ruby/object:Gem::Version
|
203
185
|
version: '0'
|
204
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
187
|
requirements:
|
206
|
-
- -
|
188
|
+
- - ">="
|
207
189
|
- !ruby/object:Gem::Version
|
208
190
|
version: '0'
|
209
191
|
requirements: []
|
210
192
|
rubyforge_project:
|
211
|
-
rubygems_version: 2.
|
193
|
+
rubygems_version: 2.2.2
|
212
194
|
signing_key:
|
213
195
|
specification_version: 4
|
214
196
|
summary: A polymorphic, storage-system independent search engine for Ruby on Rails.
|
215
197
|
test_files:
|
216
|
-
- spec/
|
217
|
-
- spec/dummy/app/models/posable_two.rb
|
218
|
-
- spec/dummy/app/models/user.rb
|
219
|
-
- spec/dummy/config/application.rb
|
220
|
-
- spec/dummy/config/boot.rb
|
221
|
-
- spec/dummy/config/database.yml
|
222
|
-
- spec/dummy/config/environment.rb
|
223
|
-
- spec/dummy/config/environments/development.rb
|
224
|
-
- spec/dummy/config/environments/production.rb
|
225
|
-
- spec/dummy/config/environments/test.rb
|
226
|
-
- spec/dummy/config/initializers/backtrace_silencers.rb
|
227
|
-
- spec/dummy/config/initializers/filter_parameter_logging.rb
|
228
|
-
- spec/dummy/config/initializers/inflections.rb
|
229
|
-
- spec/dummy/config/initializers/mime_types.rb
|
230
|
-
- spec/dummy/config/initializers/secret_token.rb
|
231
|
-
- spec/dummy/config/initializers/session_store.rb
|
232
|
-
- spec/dummy/config/initializers/wrap_parameters.rb
|
233
|
-
- spec/dummy/config/locales/en.yml
|
234
|
-
- spec/dummy/config/routes.rb
|
235
|
-
- spec/dummy/config.ru
|
236
|
-
- spec/dummy/db/development.sqlite3
|
237
|
-
- spec/dummy/db/migrate/20130308054001_create_posable_one.rb
|
238
|
-
- spec/dummy/db/migrate/20130308054142_create_posable_two.rb
|
239
|
-
- spec/dummy/db/migrate/20130708084009_create_users.rb
|
240
|
-
- spec/dummy/db/schema.rb
|
241
|
-
- spec/dummy/db/test.sqlite3
|
242
|
-
- spec/dummy/log/development.log
|
243
|
-
- spec/dummy/log/test.log
|
244
|
-
- spec/dummy/Rakefile
|
245
|
-
- spec/dummy/script/rails
|
198
|
+
- spec/db/pose.sqlite3
|
246
199
|
- spec/factories/assignments.rb
|
247
200
|
- spec/factories/posable_one.rb
|
201
|
+
- spec/factories/posable_three.rb
|
248
202
|
- spec/factories/posable_two.rb
|
249
203
|
- spec/factories/user.rb
|
250
204
|
- spec/factories/words.rb
|
251
|
-
- spec/lib/pose/
|
205
|
+
- spec/lib/pose/activerecord_base_additions_spec.rb
|
206
|
+
- spec/lib/pose/assignment_spec.rb
|
207
|
+
- spec/lib/pose/jobs/reindex_all_spec.rb
|
208
|
+
- spec/lib/pose/jobs/remove_spec.rb
|
209
|
+
- spec/lib/pose/model_class_additions_spec.rb
|
252
210
|
- spec/lib/pose/query_spec.rb
|
253
211
|
- spec/lib/pose/search_spec.rb
|
254
|
-
- spec/
|
255
|
-
- spec/models/word_spec.rb
|
212
|
+
- spec/lib/pose/word_spec.rb
|
256
213
|
- spec/pose_api_spec.rb
|
257
214
|
- spec/spec_helper.rb
|
215
|
+
- spec/support/config/database.yml
|
216
|
+
- spec/support/config/database.yml.example
|
258
217
|
- spec/support/matchers.rb
|
218
|
+
- spec/support/migrations/20130308054001_create_posable_one.rb
|
219
|
+
- spec/support/migrations/20130308054142_create_posable_two.rb
|
220
|
+
- spec/support/migrations/20130308054143_create_posable_three.rb
|
221
|
+
- spec/support/migrations/20130708084009_create_users.rb
|
222
|
+
- spec/support/migrations/20130808084009_setup_pose_specs.rb
|
223
|
+
- spec/support/models/posable_one.rb
|
224
|
+
- spec/support/models/posable_three.rb
|
225
|
+
- spec/support/models/posable_two.rb
|
226
|
+
- spec/support/models/user.rb
|
227
|
+
- spec/support/spec_manager.rb
|
data/app/models/pose/word.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# A single word in the search index.
|
2
|
-
module Pose
|
3
|
-
class Word < ActiveRecord::Base
|
4
|
-
has_many :assignments, class_name: 'Pose::Assignment', dependent: :destroy
|
5
|
-
|
6
|
-
def self.remove_unused_words progress_bar = nil
|
7
|
-
if Helpers.is_sql_database?
|
8
|
-
# SQL database --> use an optimized query.
|
9
|
-
Word.delete_all(id: Word.select("pose_words.id").
|
10
|
-
joins("LEFT OUTER JOIN pose_assignments ON pose_assignments.word_id = pose_words.id").
|
11
|
-
group("pose_words.id").
|
12
|
-
having("COUNT(pose_assignments.id) = 0"))
|
13
|
-
else
|
14
|
-
# Unknown database --> use the standard Rails API.
|
15
|
-
Word.select(:id).find_each(include: [:assignments], batch_size: 100) do |word|
|
16
|
-
word.delete if word.assignments.size == 0
|
17
|
-
progress_bar.increment if progress_bar
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
class PoseInstall < ActiveRecord::Migration
|
2
|
-
|
3
|
-
def change
|
4
|
-
create_table "pose_assignments" do |t|
|
5
|
-
t.integer "word_id", null: false
|
6
|
-
t.integer "posable_id", null: false
|
7
|
-
t.string "posable_type", limit: 60, null: false
|
8
|
-
end
|
9
|
-
add_index "pose_assignments", :word_id
|
10
|
-
add_index "pose_assignments", :posable_id
|
11
|
-
|
12
|
-
create_table "pose_words" do |t|
|
13
|
-
t.string "text", limit: 80, null: false
|
14
|
-
end
|
15
|
-
add_index "pose_words", :text
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
require 'rails/generators/migration'
|
3
|
-
|
4
|
-
module Pose
|
5
|
-
module Generators
|
6
|
-
|
7
|
-
class InstallGenerator < Rails::Generators::Base
|
8
|
-
include Rails::Generators::Migration
|
9
|
-
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
10
|
-
|
11
|
-
def create_migration_file
|
12
|
-
say ''
|
13
|
-
say ' Creating database migration for the Pose tables.'
|
14
|
-
say ''
|
15
|
-
migration_template 'install_migration.rb', 'db/migrate/install_pose.rb'
|
16
|
-
say ''
|
17
|
-
end
|
18
|
-
|
19
|
-
def installation_instructions
|
20
|
-
say ''
|
21
|
-
say ' All done! You need to do two things now:'
|
22
|
-
say ''
|
23
|
-
say ' 1. Run the database migration'
|
24
|
-
say ''
|
25
|
-
say ' rake db:migrate', Thor::Shell::Color::BOLD
|
26
|
-
say ''
|
27
|
-
say ''
|
28
|
-
say ' 2. Add a posify block to all your models.'
|
29
|
-
say ' Here is an example:'
|
30
|
-
say ''
|
31
|
-
say ' class MyClass < ActiveRecord::Base'
|
32
|
-
say ' ...'
|
33
|
-
say ''
|
34
|
-
say ' posify do', Thor::Shell::Color::BOLD
|
35
|
-
say ' # return searchable text as a string here', Thor::Shell::Color::BOLD
|
36
|
-
say ' end', Thor::Shell::Color::BOLD
|
37
|
-
say ''
|
38
|
-
say ' ...'
|
39
|
-
say ' end'
|
40
|
-
say ''
|
41
|
-
say ''
|
42
|
-
say ' Happy searching! :)'
|
43
|
-
say ''
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
# Helper method for creating the migration.
|
50
|
-
def self.next_migration_number(path)
|
51
|
-
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
class InstallPose < ActiveRecord::Migration
|
2
|
-
|
3
|
-
def self.up
|
4
|
-
create_table "pose_assignments" do |t|
|
5
|
-
t.integer "word_id", null: false
|
6
|
-
t.integer "posable_id", null: false
|
7
|
-
t.string "posable_type", limit: 40, null: false
|
8
|
-
end
|
9
|
-
|
10
|
-
add_index "pose_assignments", :word_id
|
11
|
-
add_index "pose_assignments", :posable_id
|
12
|
-
|
13
|
-
create_table "pose_words" do |t|
|
14
|
-
t.string "text", limit: 80, null: false
|
15
|
-
end
|
16
|
-
|
17
|
-
add_index "pose_words", :text
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.down
|
21
|
-
drop_table 'pose_assignments'
|
22
|
-
drop_table 'pose_words'
|
23
|
-
end
|
24
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
require 'rails/generators/migration'
|
3
|
-
|
4
|
-
module Pose
|
5
|
-
module Generators
|
6
|
-
|
7
|
-
class RemoveGenerator < Rails::Generators::Base
|
8
|
-
include Rails::Generators::Migration
|
9
|
-
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
10
|
-
|
11
|
-
def create_migration_file
|
12
|
-
say ''
|
13
|
-
say ' Creating database migration to remove the Pose tables.'
|
14
|
-
say ''
|
15
|
-
migration_template 'remove_migration.rb', 'db/migrate/remove_pose.rb'
|
16
|
-
say ''
|
17
|
-
end
|
18
|
-
|
19
|
-
def installation_instructions
|
20
|
-
say ''
|
21
|
-
say ' All done! You need to do two things now:'
|
22
|
-
say ''
|
23
|
-
say ' 1. Run the database migration to remove the tables from your database.'
|
24
|
-
say ''
|
25
|
-
say ' rake db:migrate', Thor::Shell::Color::BOLD
|
26
|
-
say ''
|
27
|
-
say ''
|
28
|
-
say ' 2. Remove the posify block from all your models.'
|
29
|
-
say ' Here is how it looks like:'
|
30
|
-
say ''
|
31
|
-
say ' class MyClass < ActiveRecord::Base'
|
32
|
-
say ' ...'
|
33
|
-
say ''
|
34
|
-
say ' posify do', Thor::Shell::Color::BOLD
|
35
|
-
say ' ...', Thor::Shell::Color::BOLD
|
36
|
-
say ' end', Thor::Shell::Color::BOLD
|
37
|
-
say ''
|
38
|
-
say ' ...'
|
39
|
-
say ' end'
|
40
|
-
say ''
|
41
|
-
say ''
|
42
|
-
say ' Have an excellent day! :)'
|
43
|
-
say ''
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
# Helper method for creating the migration.
|
50
|
-
def self.next_migration_number(path)
|
51
|
-
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
class AddPoseTables < ActiveRecord::Migration
|
2
|
-
|
3
|
-
def self.up
|
4
|
-
drop_table 'pose_assignments'
|
5
|
-
drop_table 'pose_words'
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.down
|
9
|
-
create_table "pose_assignments" do |t|
|
10
|
-
t.integer "word_id", null: false
|
11
|
-
t.integer "posable_id", null: false
|
12
|
-
t.string "posable_type", limit: 60, null: false
|
13
|
-
end
|
14
|
-
add_index "pose_assignments", :word_id
|
15
|
-
add_index "pose_assignments", :posable_id
|
16
|
-
|
17
|
-
create_table "pose_words" do |t|
|
18
|
-
t.string "text", limit: 80, null: false
|
19
|
-
end
|
20
|
-
add_index "pose_words", :text
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'rails/generators'
|
2
|
-
require 'rails/generators/migration'
|
3
|
-
|
4
|
-
module Pose
|
5
|
-
module Generators
|
6
|
-
|
7
|
-
class UpgradeGenerator < Rails::Generators::Base
|
8
|
-
include Rails::Generators::Migration
|
9
|
-
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
10
|
-
|
11
|
-
def create_migration_file
|
12
|
-
say ''
|
13
|
-
say ' Creating database migration to upgrade your Pose tables.'
|
14
|
-
say ''
|
15
|
-
migration_template 'upgrade_migration.rb', 'db/migrate/pose_upgrade.rb'
|
16
|
-
say ''
|
17
|
-
end
|
18
|
-
|
19
|
-
def installation_instructions
|
20
|
-
say ' All done! You need to do is run db:migrate!'
|
21
|
-
say ''
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
# Helper method for creating the migration.
|
28
|
-
def self.next_migration_number(path)
|
29
|
-
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
data/lib/pose/engine.rb
DELETED
data/lib/pose/helpers.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
# Internal helper methods for the Pose module.
|
2
|
-
# TODO: remove
|
3
|
-
module Pose
|
4
|
-
module Helpers
|
5
|
-
class <<self
|
6
|
-
|
7
|
-
# Returns all strings that are in new_words, but not in existing_words.
|
8
|
-
# Helper method.
|
9
|
-
#
|
10
|
-
# @param [Array<String>] existing_words The words that are already associated with the object.
|
11
|
-
# @param [Array<String>] new_words The words thet the object should have from now on.
|
12
|
-
#
|
13
|
-
# @return [Array<String>] The words that need to be added to the existing_words array.
|
14
|
-
def get_words_to_add existing_words, new_words
|
15
|
-
new_words - existing_words.map(&:text)
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
# Helper method.
|
20
|
-
# Returns the id of all word objects that are in existing_words, but not in new_words.
|
21
|
-
#
|
22
|
-
# @param [Array<String>] existing_words The words that are already associated with the object.
|
23
|
-
# @param [Array<String>] new_words The words thet the object should have from now on.
|
24
|
-
#
|
25
|
-
# @return [Array<String>] The words that need to be removed from the existing_words array.
|
26
|
-
def get_words_to_remove existing_words, new_words
|
27
|
-
existing_words.map do |existing_word|
|
28
|
-
existing_word unless new_words.include?(existing_word.text)
|
29
|
-
end.compact
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
def is_sql_database?
|
34
|
-
['ActiveRecord::ConnectionAdapters::PostgreSQLAdapter',
|
35
|
-
'ActiveRecord::ConnectionAdapters::SQLite3Adapter'].include? ActiveRecord::Base.connection.class.name
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
# Returns whether the given string is a URL.
|
40
|
-
#
|
41
|
-
# @param [String] word The string to check.
|
42
|
-
#
|
43
|
-
# @return [Boolean]
|
44
|
-
def is_url? word
|
45
|
-
/https?:\/\/(\w)+\.(\w+)/ =~ word
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
# Makes the given input an array.
|
50
|
-
def make_array input
|
51
|
-
[input].flatten
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
# Makes the given input an array.
|
56
|
-
def make_array input
|
57
|
-
[input].flatten
|
58
|
-
end
|
59
|
-
|
60
|
-
|
61
|
-
# Simplifies the given word to a generic search form.
|
62
|
-
#
|
63
|
-
# @param [String] raw_word The word to make searchable.
|
64
|
-
#
|
65
|
-
# @return [String] The stemmed version of the word.
|
66
|
-
def root_word raw_word
|
67
|
-
result = []
|
68
|
-
raw_word_copy = raw_word[0..-1]
|
69
|
-
raw_word_copy.gsub! '%20', ' '
|
70
|
-
raw_word_copy.gsub! /[()*<>'",;\?\-\=&%#]/, ' '
|
71
|
-
raw_word_copy.gsub! /\s+/, ' '
|
72
|
-
raw_word_copy.split(' ').each do |word|
|
73
|
-
if Helpers.is_url?(word)
|
74
|
-
result.concat word.split(/[\.\/\:]/).delete_if(&:blank?)
|
75
|
-
else
|
76
|
-
word.gsub! /[\-\/\._:]/, ' '
|
77
|
-
word.gsub! /\s+/, ' '
|
78
|
-
word.split(' ').each do |w|
|
79
|
-
stemmed_word = w.parameterize.singularize
|
80
|
-
result.concat stemmed_word.split ' '
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
result.uniq
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
data/lib/pose/railtie.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require "rails/railtie"
|
2
|
-
|
3
|
-
module Pose
|
4
|
-
|
5
|
-
class Railtie < Rails::Railtie
|
6
|
-
|
7
|
-
# Add the Pose additions to ActiveRecord::Base once it is loaded.
|
8
|
-
initializer 'Pose.base_additions' do
|
9
|
-
ActiveSupport.on_load :active_record do
|
10
|
-
extend ActiveRecordBaseAdditions
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
# Load the Pose rake tasks.
|
15
|
-
rake_tasks do
|
16
|
-
load "tasks/pose_tasks.rake"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|