forked from caelum/vraptor-scaffold
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a85b154
commit a227481
Showing
4 changed files
with
72 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,5 @@ | ||
require File.dirname(__FILE__) + '/vraptor-scaffold/load_paths' | ||
|
||
module VraptorScaffold | ||
def self.execute(args) | ||
action = args.shift | ||
print_help(AppGenerator) if help? action | ||
run_app_generator(args.shift, args) if action == "new" | ||
run_scaffold_generator(args) if action == "scaffold" | ||
end | ||
|
||
def self.run_app_generator(project_path, args) | ||
print_help(AppGenerator) if help? project_path | ||
AppGenerator.new(project_path, args).invoke_all | ||
end | ||
end | ||
|
||
def self.run_scaffold_generator(args) | ||
print_help(ScaffoldGenerator) if help? args.first | ||
unless File.exist?("src") | ||
puts "To run vraptor scaffold please go to the project root folder." | ||
Kernel::exit | ||
end | ||
ScaffoldGenerator.new(args).invoke_all | ||
end | ||
|
||
def self.print_help(generator) | ||
generator.start(["-h"]) | ||
Kernel::exit | ||
end | ||
|
||
def self.help?(command) | ||
[nil, "-h", "--help"].include?(command) | ||
end | ||
end | ||
require File.dirname(__FILE__) + '/vraptor-scaffold/execution.rb' | ||
require File.dirname(__FILE__) + '/vraptor-scaffold/load_paths' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
module VraptorScaffold | ||
|
||
module Runner | ||
|
||
class Help | ||
|
||
def run(args) | ||
AppGenerator.start(["-h"]) | ||
end | ||
|
||
def self.help?(arg) | ||
[nil, "-h", "--help"].include?(arg) | ||
end | ||
|
||
end | ||
|
||
class Scaffold | ||
def run(args) | ||
if VraptorScaffold::Runner::Help.help? args.first | ||
ScaffoldGenerator.start(["-h"]) | ||
elsif File.exist?("src") | ||
ScaffoldGenerator.new(args).invoke_all | ||
else | ||
puts "To run vraptor scaffold please go to the project root folder." | ||
end | ||
end | ||
end | ||
|
||
class Generator | ||
def run(args) | ||
project_path = args.shift | ||
if VraptorScaffold::Runner::Help.help? project_path | ||
AppGenerator.start(["-h"]) | ||
else | ||
AppGenerator.new(project_path, args).invoke_all | ||
end | ||
end | ||
end | ||
|
||
class CommandsHelp | ||
def run(args) | ||
puts "Available runners for vraptor are:" | ||
puts VraptorScaffold::COMMANDS.inspect | ||
end | ||
end | ||
end | ||
|
||
class Execution | ||
|
||
def run(args) | ||
action = args.shift | ||
runner_for(action).new.run(args) | ||
end | ||
|
||
def runner_for(action) | ||
VraptorScaffold::COMMANDS.fetch(action, Runner::CommandsHelp) | ||
end | ||
|
||
end | ||
|
||
COMMANDS = {"--help" => Runner::Help, | ||
"-h" => Runner::Help, | ||
"scaffold" => Runner::Scaffold, | ||
"new" => Runner::Generator | ||
} | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module VraptorScaffold | ||
VERSION = "1.2.0" | ||
VERSION = "1.2.1" | ||
end |