class Weeler::Generators::InstallGenerator

Public Class Methods

next_migration_number(path) click to toggle source
# File lib/generators/weeler/install_generator.rb, line 10
def self.next_migration_number(path)
  unless @prev_migration_nr
    @prev_migration_nr =  ActiveRecord::Generators::Base.next_migration_number(path).to_i
  else
    @prev_migration_nr += 1
  end

  @prev_migration_nr.to_s
end

Public Instance Methods

add_weeler_routes() click to toggle source
# File lib/generators/weeler/install_generator.rb, line 49
def add_weeler_routes
  weeler_routes  = "mount_weeler_at \"weeler\" do \n"
  weeler_routes << "    # weeler_resources :example, include_in_weeler_menu: true \n"
  weeler_routes << "    # Also you orderable and imageable concerns \n"
  weeler_routes << "  end"
  route weeler_routes
end
install_controllers() click to toggle source
# File lib/generators/weeler/install_generator.rb, line 44
def install_controllers
  copy_files 'controllers', 'app/controllers'
end
install_initializer() click to toggle source
# File lib/generators/weeler/install_generator.rb, line 22
def install_initializer
  copy_files 'initializers', 'config/initializers'
end
install_javascripts_assets() click to toggle source
# File lib/generators/weeler/install_generator.rb, line 36
def install_javascripts_assets
  copy_files 'assets/javascripts', 'lib/assets/javascripts'
end
install_migrations() click to toggle source
# File lib/generators/weeler/install_generator.rb, line 26
def install_migrations
  get_file_list('migrations').each do |migration|
    migration_template "migrations/#{migration}", "db/migrate/#{migration}"
  end
end
install_stylesheets_assets() click to toggle source
# File lib/generators/weeler/install_generator.rb, line 40
def install_stylesheets_assets
  copy_files 'assets/stylesheets', 'lib/assets/stylesheets'
end
install_views() click to toggle source
# File lib/generators/weeler/install_generator.rb, line 32
def install_views
  copy_files 'views', 'app/views'
end

Private Instance Methods

copy_files(subdir, dest_dir) click to toggle source
# File lib/generators/weeler/install_generator.rb, line 59
def copy_files subdir, dest_dir
  raise ArgumEnterror unless subdir.is_a? String
  raise ArgumEnterror unless dest_dir.is_a? String
  raise ArgumetnError if subdir.blank?
  raise ArgumetnError if dest_dir.blank?

  get_file_list(subdir).each do |image|
    copy_file [subdir, image].join('/'), [dest_dir, image].join('/')
  end
end
get_current_dir() click to toggle source
# File lib/generators/weeler/install_generator.rb, line 80
def get_current_dir
  File.dirname(__FILE__)
end
get_file_list(subdir) click to toggle source
# File lib/generators/weeler/install_generator.rb, line 70
def get_file_list subdir
  raise ArgumentError unless subdir.is_a? String
  raise ArgumetnError if subdir.blank?
  dir = get_current_dir
  search_path = [dir, 'templates', subdir].join('/') + '/'
  file_list = Dir.glob(search_path + '**/*').map { |filename| File.directory?(filename) ? nil : filename.sub(search_path, '') }
  file_list.delete nil
  return file_list
end