Sha256: f4012a82b8d2a1bf00de8aab8ef4343956d8883d671adf09108c7fc8add2b4db
Contents?: true
Size: 1.89 KB
Versions: 2
Compression:
Stored size: 1.89 KB
Contents
class ControllerGenerator < Merb::GeneratorBase attr_reader :controller_class_name, :controller_file_name, :controller_base_path, :controller_modules, :full_controller_const def initialize(args, runtime_args = {}) @base = File.dirname(__FILE__) super name = args.shift @controller_file_name = name.snake_case.gsub("::", "/") # Need to setup the directories unless @controller_file_name == File.basename(@controller_file_name) @controller_base_path = controller_file_name.split("/")[0..-2].join("/") end @controller_modules = @controller_file_name.to_const_string.split("::")[0..-2] @controller_class_name = @controller_file_name.to_const_string.split("::").last @full_controller_const = ((@controller_modules.dup || []) << @controller_class_name).join("::") end def manifest record do |m| @m = m # Create the controller directory m.directory File.join("app/controllers", controller_base_path) if controller_base_path # Create the helpers directory m.directory File.join("app/helpers", controller_base_path) if controller_base_path @assigns = { :controller_modules => controller_modules, :controller_class_name => controller_class_name, :controller_file_name => controller_file_name, :controller_base_path => controller_base_path, :full_controller_const => full_controller_const } copy_dirs copy_files m.dependency "merb_controller_test", [@controller_class_name], @assigns end end protected def banner <<-EOS.split("\n").map{|x| x.strip}.join("\n") Creates a basic Merb controller. USAGE: #{spec.name} my_controller EOS end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
merb-gen-0.9.3 | merb_generators/controller/controller_generator.rb |
merb-gen-0.9.2 | merb_generators/controller/controller_generator.rb |