Sha256: 53fc9615832d41e6b89f2c93b8223bf40a72d4865588a074ca6df7f3f2e949e7
Contents?: true
Size: 1.46 KB
Versions: 10
Compression:
Stored size: 1.46 KB
Contents
require 'fileutils' module Generators module Hobo Subsite = classy_module do include Generators::Hobo::InviteOnly include Generators::Hobo::Taglib class_option :make_front_site, :type => :boolean, :desc => "Rename application.dryml to front_site.dryml" check_class_collision :suffix => 'SiteController' def move_and_generate_files if options[:make_front_site] unless can_mv_application_to_front_site? say "Cannot rename application.dryml to #{file_name}_site.dryml" exit 1 end say "Renaming app/views/taglibs/application.dryml to app/views/taglibs/front_site.dryml" \ unless options[:quiet] FileUtils.mv('app/views/taglibs/application.dryml', "app/views/taglibs/front_site.dryml") unless options[:pretend] copy_file "application.dryml", 'app/views/taglibs/application.dryml' end template "controller.rb.erb", File.join('app/controllers', file_name, "#{file_name}_site_controller.rb") end hook_for :test_framework, :as => :controller do | instance, controller_test | instance.invoke controller_test, ["#{instance.name}_site"] end private def subsite_name class_name end def can_mv_application_to_front_site? File.exist?('app/views/taglibs/application.dryml') && !File.exist?('app/views/taglibs/front_site.dryml') end end end end
Version data entries
10 entries across 10 versions & 1 rubygems