Class: JaxGenerator
- Inherits:
-
Object
- Object
- JaxGenerator
- Defined in:
- lib/jax/generators/commands.rb
Constant Summary collapse
- COMMANDS =
{ "generate" => "Generate new code", "destroy" => "Undo code generated with \"generate\"", "plugin" => "Install a plugin", "package" => "Package the app for production" }
- ALIASES =
{ "g" => "generate" }
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
Class Method Summary collapse
-
.start ⇒ Object
this gets called by script/jax from within a jax app.
Instance Method Summary collapse
- #command ⇒ Object
- #command_list ⇒ Object
- #description_for(command) ⇒ Object
- #destroy ⇒ Object
- #generate ⇒ Object
-
#initialize(args) ⇒ JaxGenerator
constructor
A new instance of JaxGenerator.
- #invalid(command) ⇒ Object
- #package ⇒ Object
- #plugin ⇒ Object
- #show_usage ⇒ Object
Constructor Details
#initialize(args) ⇒ JaxGenerator
Returns a new instance of JaxGenerator.
150 151 152 153 154 155 156 157 158 159 |
# File 'lib/jax/generators/commands.rb', line 150 def initialize(args) @args = args show_usage and return unless command if respond_to? command then send command else invalid command end rescue ArgumentError puts $!. end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
140 141 142 |
# File 'lib/jax/generators/commands.rb', line 140 def args @args end |
Class Method Details
.start ⇒ Object
this gets called by script/jax from within a jax app
215 216 217 |
# File 'lib/jax/generators/commands.rb', line 215 def start new ARGV end |
Instance Method Details
#command ⇒ Object
177 178 179 180 181 182 |
# File 'lib/jax/generators/commands.rb', line 177 def command @command ||= begin command = args.shift command = ALIASES[command] || command end end |
#command_list ⇒ Object
201 202 203 |
# File 'lib/jax/generators/commands.rb', line 201 def command_list COMMANDS.keys.collect { |command| "#{command.ljust(13)}#{description_for command}"} end |
#description_for(command) ⇒ Object
205 206 207 208 209 210 211 |
# File 'lib/jax/generators/commands.rb', line 205 def description_for(command) if i = ALIASES.values.index(command) COMMANDS[command] + " (shortcut alias: \"#{ALIASES.keys[i]}\")" else COMMANDS[command] end end |
#destroy ⇒ Object
169 170 171 |
# File 'lib/jax/generators/commands.rb', line 169 def destroy JaxGeneratorInvoker.start(ARGV, :behavior => :revoke) end |
#generate ⇒ Object
165 166 167 |
# File 'lib/jax/generators/commands.rb', line 165 def generate JaxGeneratorInvoker.start end |
#invalid(command) ⇒ Object
184 185 186 187 188 |
# File 'lib/jax/generators/commands.rb', line 184 def invalid(command) puts "Invalid command." puts show_usage end |
#package ⇒ Object
161 162 163 |
# File 'lib/jax/generators/commands.rb', line 161 def package Jax::Generators::Packager::PackageGenerator.start end |
#plugin ⇒ Object
173 174 175 |
# File 'lib/jax/generators/commands.rb', line 173 def plugin Jax::Generators::Plugin::PluginManager.start end |
#show_usage ⇒ Object
190 191 192 193 194 195 196 197 198 199 |
# File 'lib/jax/generators/commands.rb', line 190 def show_usage puts <<-end_banner Usage: jax COMMAND [ARGS] The following commands are available: #{command_list.join("\n ")} All commands can be run with -h for more information. end_banner end |