Sha256: 3c8c42a59627c7ac8d7ee813cc79178fc4b2f00105d6d117536c091e988d93c1
Contents?: true
Size: 1.73 KB
Versions: 8
Compression:
Stored size: 1.73 KB
Contents
require 'fileutils' require 'thor/parser/option' # we want the option :make_front_site required even if it is boolean # Thor does not allow it, so we patch it class Thor class Option def validate!; end end end module Generators module Hobo Subsite = classy_module do include Generators::Hobo::InviteOnly include Generators::Hobo::Taglib class_option :make_front_site, :type => :boolean, :required => true, :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] unless options[:pretend] FileUtils.mv('app/views/taglibs/application.dryml', "app/views/taglibs/front_site.dryml") copy_file "application.dryml", 'app/views/taglibs/application.dryml' end 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
8 entries across 8 versions & 1 rubygems