Sha256: 4ca61db8118d68a2b61bc46f14728bbb8f3481a8a6e35c7063641c4dcfbf3f59
Contents?: true
Size: 1.72 KB
Versions: 3
Compression:
Stored size: 1.72 KB
Contents
require 'thor' module Padrino module Generators class Controller < Thor::Group # Add this generator to our padrino-gen Padrino::Generators.add_generator(:controller, self) # 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" argument :fields, :desc => "The fields for the controller", :type => :array, :default => [] 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]) @actions = controller_actions(fields) inject_into_file app_root_path("config/urls.rb"), controller_routes(name,fields), :after => "urls do\n" template "templates/controller.rb.tt", app_root_path("app/controllers", "#{name}.rb") template "templates/helper.rb.tt", app_root_path("app/helpers", "#{name}_helper.rb") empty_directory app_root_path("app/views/#{name}") 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
padrino-gen-0.2.9 | lib/padrino-gen/generators/controller.rb |
padrino-gen-0.2.6 | lib/padrino-gen/generators/controller.rb |
padrino-gen-0.2.5 | lib/padrino-gen/generators/controller.rb |