Sha256: ae467ac133efdf5533182c056f51572b9f80785219032ccafcf4e3fdf85d67e0
Contents?: true
Size: 1.82 KB
Versions: 2
Compression:
Stored size: 1.82 KB
Contents
class PartControllerGenerator < 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/parts", 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 end end protected def banner <<-EOS.split("\n").map{|x| x.strip}.join("\n") Creates a basic Merb Part controller. USAGE: #{spec.name} my_part_controller EOS end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
merb-gen-0.9.2 | merb_generators/part_controller/part_controller_generator.rb |
merb-gen-0.9.3 | merb_generators/part_controller/part_controller_generator.rb |