module Parade::Commands
Commands
is a module that contains commands to be used through the bin/parade utility. This module defines a number of helper methods to define generator and static content output formats.
Public Class Methods
@param [String,Symbol] type the type of command (e.g. statics or generators) @param [String] name the name which the command can be accessed @param [Object#description,Object#generate] command the command itself, which
adheres to the two methods {#description} and {#generate}
# File lib/parade/commands/commands.rb, line 44 def self.commands(type,name,command=nil) command_set = send(type) if command command_set[name] = command else command_set[name] end end
@return [Hash] an empty command hash with the default, when a command is
not found, to return the Unknown command.
# File lib/parade/commands/commands.rb, line 22 def self.commands_with_unknown_default command_hash = {} command_hash.default = Unknown.new command_hash end
@param [String,Symbol] type the typw of command (e.g. statics or generators) @param [String] name the name of the command to be found of the specified type @param [Hash] options a Hash of options that help instruct the execution
process.
# File lib/parade/commands/commands.rb, line 71 def self.execute(type,name,options) puts "Generating #{type} #{name} with #{options}" send(type,name).generate(options) end
Find or create a generator command. Creates a static output entry if the command is provided.
# File lib/parade/commands/commands.rb, line 61 def self.generator(name,command=nil) commands :generators, name, command end
@return [Hash] a hash that contains all the avaliable generator commands
# File lib/parade/commands/commands.rb, line 34 def self.generators @generators ||= commands_with_unknown_default end
Find or create a static output command. Creates a static output entry if the command is provided.
# File lib/parade/commands/commands.rb, line 55 def self.static(name,command=nil) commands :statics, name, command end
@return [Hash] a hash that contains all the avaliable static output commands
# File lib/parade/commands/commands.rb, line 29 def self.statics @statics ||= commands_with_unknown_default end