Class: Somatics::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Extended by:
TemplatePath
Defined in:
lib/generators/somatics/install/install_generator.rb

Instance Method Summary collapse

Methods included from TemplatePath

source_root

Instance Method Details

#add_routeObject



82
83
84
85
86
87
88
89
# File 'lib/generators/somatics/install/install_generator.rb', line 82

def add_route
  route_config = ""
  route_config << "  namespace :#{options[:namespace]} do \n" if options[:namespace].present?
  route_config << "    root :to => 'home#index'\n"
  route_config << "    match 'home' => 'home#index'\n"
  route_config << "  end\n" if options[:namespace].present?
  route route_config
end

#add_settingsObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/generators/somatics/install/install_generator.rb', line 67

def add_settings
  append_file File.join('db','seeds.rb') do 
    <<-RUBY
    unless Setting.find_by_name('theme')
      s = Setting.new
      s.name = 'theme'
      s.category = 'General'
      s.value = 'default'
      s.field_type = 'string'
      s.save!
    end
    RUBY
  end
end

#baseObject



30
31
32
33
# File 'lib/generators/somatics/install/install_generator.rb', line 30

def base
  template 'controller_admin.rb', File.join('app/controllers/admin', 'admin_controller.rb')
  template 'helper_admin.rb', File.join('app/helpers/admin', 'admin_helper.rb')
end

#default_adminObject



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/generators/somatics/install/install_generator.rb', line 54

def default_admin
  rakefile "somatics.rake" do 
    <<-RUBY
namespace :somatics do
  desc "Create Default Admin User"
  task :create_user => :environment do
    User.find_or_create_by_name(:name => 'Admin', :password => 'somatics', :password_confirmation => 'somatics', :email => '[email protected]')
  end
end
    RUBY
  end
end

#homeObject



35
36
37
38
# File 'lib/generators/somatics/install/install_generator.rb', line 35

def home
  template 'controller_home.rb', File.join('app/controllers/admin', 'home_controller.rb')
  template 'view_index.html.erb', File.join('app/views/admin', 'home', 'index.html.erb')
end

#imagesObject



14
15
16
# File 'lib/generators/somatics/install/install_generator.rb', line 14

def images
  directory "public/images"
end

#javascriptsObject



22
23
24
# File 'lib/generators/somatics/install/install_generator.rb', line 22

def javascripts
  directory "public/javascripts"
end

#layoutsObject



40
41
42
43
# File 'lib/generators/somatics/install/install_generator.rb', line 40

def layouts
  template 'layout_admin.html.erb', File.join('app/views/layouts', "admin.html.erb")
  template 'partial_menu.html.erb', File.join('app/views/admin/shared', "_menu.html.erb"), :skip => true
end

#libsObject



91
92
93
# File 'lib/generators/somatics/install/install_generator.rb', line 91

def libs
  directory "lib"
end

#localesObject



50
51
52
# File 'lib/generators/somatics/install/install_generator.rb', line 50

def locales
  directory "config/locales"
end

#mime_typeObject



45
46
47
48
# File 'lib/generators/somatics/install/install_generator.rb', line 45

def mime_type
  gsub_file File.join('config','initializers', 'mime_types.rb'), "Mime::Type.register 'application/vnd.ms-excel', :xls", ""
  append_file File.join('config','initializers', 'mime_types.rb'), "Mime::Type.register 'application/vnd.ms-excel', :xls"
end

#paper_trailObject



95
96
97
98
# File 'lib/generators/somatics/install/install_generator.rb', line 95

def paper_trail
  template 'partial_versions.html.erb', File.join('app/views/admin/shared', "_versions.html.erb")
  template 'initializer_paper_trail.rb', File.join('config/initializers', "paper_trail.rb")
end

#public_directoryObject



10
11
12
# File 'lib/generators/somatics/install/install_generator.rb', line 10

def public_directory
  directory "public", "public", :recursive => false
end

#stylesheetsObject



18
19
20
# File 'lib/generators/somatics/install/install_generator.rb', line 18

def stylesheets
  directory "public/stylesheets"
end

#themesObject



26
27
28
# File 'lib/generators/somatics/install/install_generator.rb', line 26

def themes
  directory "public/themes"
end