Sha256: f71ce1fb35725b5efdcb48359cddd50557e794dd954f46f59209f89cf7ef022b
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
require 'thor' module Padrino module Generators class Controller < Thor::Group # Define the source template root def self.source_root; File.expand_path(File.dirname(__FILE__)); end def self.banner; "padrino-gen controller [name]"; end # Include related modules include Thor::Actions include Padrino::Generators::Actions include Padrino::Generators::Components::Actions desc "Description:\n\n\tpadrino-gen controller generates a new Padrino controller" argument :name, :desc => "The name of your padrino controller" class_option :root, :aliases => '-r', :default => nil, :type => :string # Copies over the base sinatra starting project def create_controller if in_app_root?(options[:root]) @app_name = fetch_app_name(options[:root]) template "templates/controller.rb.tt", File.join(options[:root] || '.', "app/controllers/#{name}.rb") template "templates/helper.rb.tt", File.join(options[:root] || '.', "app/helpers/#{name}_helper.rb") include_component_module_for(:test, options[:root]) generate_controller_test(name, options[:root] || '.') else say "You are not at the root of a Padrino application! (config/boot.rb not found)" and return unless in_app_root? end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
padrino-gen-0.1.2 | lib/generators/controller.rb |