Class: AppGenerator
- Inherits:
-
VraptorScaffold::Base
- Object
- Thor::Group
- VraptorScaffold::Base
- AppGenerator
- Defined in:
- lib/vraptor-scaffold/generators/app/app_generator.rb
Constant Summary collapse
- ORMS =
%w( jpa hibernate )
Class Method Summary collapse
Instance Method Summary collapse
- #configure_maven ⇒ Object
- #configure_orm ⇒ Object
- #configure_scaffold_properties ⇒ Object
- #configure_vraptor_packages ⇒ Object
- #create_angular_files ⇒ Object
- #create_bootstrap_files ⇒ Object
- #create_controllers_directory ⇒ Object
- #create_eclipse_files ⇒ Object
- #create_frontend_directory ⇒ Object
- #create_javascripts ⇒ Object
- #create_jquery_files ⇒ Object
- #create_main_java ⇒ Object
- #create_main_resources ⇒ Object
- #create_models_directory ⇒ Object
- #create_repositories_directory ⇒ Object
- #create_root_folder ⇒ Object
- #create_test ⇒ Object
- #create_underscore_files ⇒ Object
- #create_webapp ⇒ Object
-
#initialize(args, opts = []) ⇒ AppGenerator
constructor
A new instance of AppGenerator.
Constructor Details
#initialize(args, opts = []) ⇒ AppGenerator
Returns a new instance of AppGenerator.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 30 def initialize(args, opts=[]) super([args], opts) validate self.destination_root=(project_path) @project_name = project_path.split("/").last @dependency_manager = DependencyManager.new() @javascripts = Configuration::JAVASCRIPTS @stylesheets = Configuration::STYLESHEETS @images = Configuration::IMAGES @img = File.join Configuration::WEB_APP, "img" end |
Class Method Details
.banner ⇒ Object
26 27 28 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 26 def self. "vraptor new #{self.arguments.map(&:usage).join(' ')} [options]" end |
.source_root ⇒ Object
22 23 24 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 22 def self.source_root File.join File.dirname(__FILE__), "templates" end |
Instance Method Details
#configure_maven ⇒ Object
47 48 49 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 47 def configure_maven template("pom.erb", "pom.xml") end |
#configure_orm ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 83 def configure_orm if (orm == "hibernate") copy_file("orm/hibernate.cfg.xml", (File.join Configuration::MAIN_RESOURCES, "hibernate.cfg.xml")) else = File.join Configuration::MAIN_RESOURCES, 'META-INF' empty_directory copy_file("orm/persistence.xml", (File.join , "persistence.xml")) end end |
#configure_scaffold_properties ⇒ Object
101 102 103 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 101 def configure_scaffold_properties template("vraptor-scaffold.erb", Configuration::FILENAME) end |
#configure_vraptor_packages ⇒ Object
51 52 53 54 55 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 51 def configure_vraptor_packages vraptor_util_package = "br.com.caelum.vraptor" @vraptor_packages = [] @vraptor_packages += ["#{vraptor_util_package}.util.#{orm}"] if orm == "jpa" or orm == "hibernate" end |
#create_angular_files ⇒ Object
127 128 129 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 127 def create_angular_files copy_file("angular/angular.js", "#{@javascripts}/angular.js") end |
#create_bootstrap_files ⇒ Object
118 119 120 121 122 123 124 125 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 118 def create_bootstrap_files empty_directory @img copy_file("bootstrap/bootstrap.js", "#{@javascripts}/bootstrap.js") copy_file("bootstrap/bootstrap.css", "#{@stylesheets}/bootstrap.css") copy_file("bootstrap/bootstrap-responsive.css", "#{@stylesheets}/bootstrap-responsive.css") copy_file("bootstrap/glyphicons-halflings-white.png", "#{@img}/glyphicons-halflings-white.png") copy_file("bootstrap/glyphicons-halflings.png", "#{@img}/glyphicons-halflings.png") end |
#create_controllers_directory ⇒ Object
63 64 65 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 63 def create_controllers_directory empty_directory File.join @src, [:controllers_package] end |
#create_eclipse_files ⇒ Object
139 140 141 142 143 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 139 def create_eclipse_files template("eclipse/classpath.erb", ".classpath") template("eclipse/project.erb", ".project") directory("eclipse/settings", ".settings") end |
#create_frontend_directory ⇒ Object
135 136 137 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 135 def create_frontend_directory empty_directory Configuration::FRONTEND end |
#create_javascripts ⇒ Object
97 98 99 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 97 def create_javascripts create_file File.join @javascripts, "application.js" end |
#create_jquery_files ⇒ Object
114 115 116 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 114 def create_jquery_files copy_file("jquery/jquery.min.js", "#{@javascripts}/jquery.min.js") end |
#create_main_java ⇒ Object
57 58 59 60 61 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 57 def create_main_java empty_directory Configuration::MAIN_SRC @src = File.join(Configuration::MAIN_SRC, [:package].gsub(".", File::Separator)) copy_file("heroku/Main.java", "#{Configuration::MAIN_SRC}/Main.java") end |
#create_main_resources ⇒ Object
79 80 81 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 79 def create_main_resources directory("resources", Configuration::MAIN_RESOURCES) end |
#create_models_directory ⇒ Object
67 68 69 70 71 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 67 def create_models_directory models_folder = File.join @src, [:models_package] empty_directory models_folder template("models/Entity.erb", "#{models_folder}/Entity.java") end |
#create_repositories_directory ⇒ Object
73 74 75 76 77 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 73 def create_repositories_directory repositories_folder = File.join @src, [:repositories_package] empty_directory repositories_folder template("orm/Repository-#{orm}.java.tt", "#{repositories_folder}/Repository.java") end |
#create_root_folder ⇒ Object
42 43 44 45 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 42 def create_root_folder empty_directory "." copy_file("heroku/Procfile", "Procfile") end |
#create_test ⇒ Object
105 106 107 108 109 110 111 112 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 105 def create_test empty_directory Configuration::TEST_SRC test_src = File.join(Configuration::TEST_SRC, [:package].gsub(".", File::Separator)) empty_directory File.join test_src, [:controllers_package] empty_directory File.join test_src, [:models_package] empty_directory File.join test_src, [:repositories_package] directory("resources-test", Configuration::TEST_RESOURCES) end |
#create_underscore_files ⇒ Object
131 132 133 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 131 def create_underscore_files copy_file("underscore/underscore.min.js", "#{@javascripts}/underscore.min.js") end |
#create_webapp ⇒ Object
93 94 95 |
# File 'lib/vraptor-scaffold/generators/app/app_generator.rb', line 93 def create_webapp directory("webapp", Configuration::WEB_APP) end |