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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba490a89c4b38fc4f2f5130b6a273056b6092449
4
- data.tar.gz: a09857552f1f8eaec1cf5afdeb6a7fac3081e18b
3
+ metadata.gz: 79f5155eaa165a82a31966e6e91707e29bd20dcc
4
+ data.tar.gz: 810cfb3d2c8439a5eb7f71a1c9ef2891afddbca2
5
5
  SHA512:
6
- metadata.gz: c62c6a8f503abfe0fea9257d567cd383ec95ab88a5a03acd6181073512639f25ca725623defa87ba88d708fcff7b3a70b75667e64a020bfac13382c4e55c3653
7
- data.tar.gz: a2eaffd000b0e2373f426fc75c6329e4b0ff5530240010f9b601dd1468959221e3836fb0f9810356bd2e5c8909408cdf16c07d14e624fb4fa0562960d26cd471
6
+ metadata.gz: 17578ae1e51eddd285d9640afbada12506aaeb507874f509e8e2fd5e7475d4880345639818d1fae28222c59c1bccd120a425df43c316469d33213fccb0dbcc60
7
+ data.tar.gz: 6a41e1746b6da50ffad55d2c0e0a811344d4b8270cb1daee65785d32d913540a843b8b27086834c3882d0ca4701a76efd3990b990654b07e457d8270736de2fa
@@ -1,3 +1,3 @@
1
1
  module SearchRails
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
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 ''
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: search_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - micahnico22