Class: Medivo::Generators::LabsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/medivo/labs/labs_generator.rb

Instance Method Summary collapse

Instance Method Details

#lab_controller_sampleObject



13
14
15
16
# File 'lib/generators/medivo/labs/labs_generator.rb', line 13

def lab_controller_sample
  FileUtils.mkdir_p('app/controllers')
  copy_file "labs_controller.rb", "app/controllers/labs_controller.rb"
end

#lab_resource_fileObject



8
9
10
11
# File 'lib/generators/medivo/labs/labs_generator.rb', line 8

def lab_resource_file
  FileUtils.mkdir_p('config/medivo')
  copy_file "lab_resource.yml", "config/medivo/lab_resource.yml"
end

#lab_search_view_sampleObject



18
19
20
21
# File 'lib/generators/medivo/labs/labs_generator.rb', line 18

def lab_search_view_sample
  FileUtils.mkdir_p('app/views/labs')
  copy_file "search.html.haml", "app/views/labs/search.html.haml"
end

#routesObject



23
24
25
26
27
28
29
30
# File 'lib/generators/medivo/labs/labs_generator.rb', line 23

def routes
  medivo_engine_routes = 'mount Medivo::Engine => "/medivo", :as => "medivo"'
  lab_search_route = 'match "/labs/search" => "labs#search", :via => :get, :as=> :search_labs'
  line = "application.routes.draw do"
  gsub_file 'config/routes.rb', /(#{Regexp.escape(line)})/mi do |match|
    "#{match}\n  #{medivo_engine_routes}\n  #{lab_search_route}"
  end
end