search_rails 1.0.4 → 1.0.5
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/lib/search_rails/version.rb +1 -1
- data/lib/search_rails.rb +34 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79f5155eaa165a82a31966e6e91707e29bd20dcc
|
4
|
+
data.tar.gz: 810cfb3d2c8439a5eb7f71a1c9ef2891afddbca2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17578ae1e51eddd285d9640afbada12506aaeb507874f509e8e2fd5e7475d4880345639818d1fae28222c59c1bccd120a425df43c316469d33213fccb0dbcc60
|
7
|
+
data.tar.gz: 6a41e1746b6da50ffad55d2c0e0a811344d4b8270cb1daee65785d32d913540a843b8b27086834c3882d0ca4701a76efd3990b990654b07e457d8270736de2fa
|
data/lib/search_rails/version.rb
CHANGED
data/lib/search_rails.rb
CHANGED
@@ -16,6 +16,9 @@ module SearchRails
|
|
16
16
|
Dir.chdir(root + '/app/controllers')
|
17
17
|
File.new "searches_controller.rb", "w"
|
18
18
|
puts "Created ".green.bold + '/app/controllers/searches_controller.rb'.bold
|
19
|
+
Dir.chdir(root + '/app/models')
|
20
|
+
File.new "search.rb", "w"
|
21
|
+
puts 'Created '.green.bold + 'app/models/search.rb'.bold
|
19
22
|
Dir.chdir(root + '/db')
|
20
23
|
if File.exists?('/migrate')
|
21
24
|
else
|
@@ -160,6 +163,35 @@ module SearchRails
|
|
160
163
|
Dir.chdir(root)
|
161
164
|
end
|
162
165
|
|
166
|
+
def write_search_model
|
167
|
+
require "fileutils"
|
168
|
+
root = Dir.pwd
|
169
|
+
Dir.chdir(root + '/app/models')
|
170
|
+
File.open("search.rb", "w") do |line|
|
171
|
+
line.puts 'class Search < ActiveRecord::Base'
|
172
|
+
line.puts 'end'
|
173
|
+
end
|
174
|
+
Dir.chdir(root)
|
175
|
+
end
|
176
|
+
|
177
|
+
def update_routes
|
178
|
+
require "fileutils"
|
179
|
+
root = Dir.pwd
|
180
|
+
Dir.chdir(root + '/config')
|
181
|
+
first_line = IO.readlines("routes.rb")[0]
|
182
|
+
other_lines = IO.readlines("routes.rb")[1..1000000000]
|
183
|
+
File.open('routes.rb', 'w') do |line|
|
184
|
+
line.puts first_line
|
185
|
+
line.puts 'resources :searches do'
|
186
|
+
line.puts ' member do'
|
187
|
+
line.puts " get 'clear'"
|
188
|
+
line.puts ' end'
|
189
|
+
line.puts 'end'
|
190
|
+
line.puts other_lines
|
191
|
+
end
|
192
|
+
Dir.chdir(root)
|
193
|
+
end
|
194
|
+
|
163
195
|
def run
|
164
196
|
require 'colorize'
|
165
197
|
|
@@ -176,7 +208,9 @@ module SearchRails
|
|
176
208
|
SearchInstall.new.create_files
|
177
209
|
SearchInstall.new.write_search_controller
|
178
210
|
SearchInstall.new.write_application_controller
|
211
|
+
SearchInstall.new.write_search_model
|
179
212
|
SearchInstall.new.write_migration
|
213
|
+
SearchInstall.new.update_routes
|
180
214
|
SearchInstall.new.write_search_module(object, attributes)
|
181
215
|
puts 'Done'.bold
|
182
216
|
puts ''
|