heroku-vraptor-scaffold 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (148) hide show
  1. data/.gitignore +10 -0
  2. data/.travis.yml +6 -0
  3. data/CHANGELOG.rdoc +188 -0
  4. data/Gemfile +2 -0
  5. data/Gemfile.lock +30 -0
  6. data/LICENSE +22 -0
  7. data/README.md +23 -0
  8. data/README.textile +51 -0
  9. data/Rakefile +20 -0
  10. data/bin/heroku-vraptor +8 -0
  11. data/heroku-vraptor-scaffold.gemspec +28 -0
  12. data/index.sample.html +169 -0
  13. data/lib/vraptor-scaffold.rb +14 -0
  14. data/lib/vraptor-scaffold/configuration.rb +54 -0
  15. data/lib/vraptor-scaffold/execution.rb +22 -0
  16. data/lib/vraptor-scaffold/generators/app/app_generator.rb +161 -0
  17. data/lib/vraptor-scaffold/generators/app/dependency.rb +15 -0
  18. data/lib/vraptor-scaffold/generators/app/dependency_manager.rb +32 -0
  19. data/lib/vraptor-scaffold/generators/app/templates/angular/angular.js +14327 -0
  20. data/lib/vraptor-scaffold/generators/app/templates/bootstrap/bootstrap-responsive.css +9 -0
  21. data/lib/vraptor-scaffold/generators/app/templates/bootstrap/bootstrap.css +9 -0
  22. data/lib/vraptor-scaffold/generators/app/templates/bootstrap/bootstrap.js +6 -0
  23. data/lib/vraptor-scaffold/generators/app/templates/bootstrap/glyphicons-halflings-white.png +0 -0
  24. data/lib/vraptor-scaffold/generators/app/templates/bootstrap/glyphicons-halflings.png +0 -0
  25. data/lib/vraptor-scaffold/generators/app/templates/eclipse/classpath.erb +18 -0
  26. data/lib/vraptor-scaffold/generators/app/templates/eclipse/project.erb +36 -0
  27. data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings/org.eclipse.jdt.core.prefs +8 -0
  28. data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings/org.eclipse.wst.common.component.tt +10 -0
  29. data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings/org.eclipse.wst.common.project.facet.core.xml +10 -0
  30. data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings/org.eclipse.wst.jsdt.ui.superType.container +1 -0
  31. data/lib/vraptor-scaffold/generators/app/templates/eclipse/settings/org.eclipse.wst.jsdt.ui.superType.name +1 -0
  32. data/lib/vraptor-scaffold/generators/app/templates/heroku/Main.java +21 -0
  33. data/lib/vraptor-scaffold/generators/app/templates/heroku/Procfile +1 -0
  34. data/lib/vraptor-scaffold/generators/app/templates/jquery/jquery.min.js +4 -0
  35. data/lib/vraptor-scaffold/generators/app/templates/models/Entity.erb +46 -0
  36. data/lib/vraptor-scaffold/generators/app/templates/orm/Repository-hibernate.java.tt +50 -0
  37. data/lib/vraptor-scaffold/generators/app/templates/orm/Repository-jpa.java.tt +48 -0
  38. data/lib/vraptor-scaffold/generators/app/templates/orm/Repository-objectify.java.tt +41 -0
  39. data/lib/vraptor-scaffold/generators/app/templates/orm/hibernate.cfg.xml +7 -0
  40. data/lib/vraptor-scaffold/generators/app/templates/orm/persistence.xml +10 -0
  41. data/lib/vraptor-scaffold/generators/app/templates/pom.erb +110 -0
  42. data/lib/vraptor-scaffold/generators/app/templates/resources-test/.empty_directory +0 -0
  43. data/lib/vraptor-scaffold/generators/app/templates/resources/hibernate.properties +16 -0
  44. data/lib/vraptor-scaffold/generators/app/templates/resources/log4j.properties +4 -0
  45. data/lib/vraptor-scaffold/generators/app/templates/resources/messages.properties +0 -0
  46. data/lib/vraptor-scaffold/generators/app/templates/underscore/underscore.min.js +32 -0
  47. data/lib/vraptor-scaffold/generators/app/templates/vraptor-scaffold.erb +5 -0
  48. data/lib/vraptor-scaffold/generators/app/templates/webapp/WEB-INF/web.xml.tt +33 -0
  49. data/lib/vraptor-scaffold/generators/app/templates/webapp/images/.empty_directory +0 -0
  50. data/lib/vraptor-scaffold/generators/app/templates/webapp/index.html +24 -0
  51. data/lib/vraptor-scaffold/generators/app/templates/webapp/javascripts/utils.js +7 -0
  52. data/lib/vraptor-scaffold/generators/base.rb +16 -0
  53. data/lib/vraptor-scaffold/generators/scaffold/attribute.rb +51 -0
  54. data/lib/vraptor-scaffold/generators/scaffold/base_scaffold.rb +54 -0
  55. data/lib/vraptor-scaffold/generators/scaffold/client_generator/client_generator.rb +41 -0
  56. data/lib/vraptor-scaffold/generators/scaffold/client_generator/templates/controller.erb +75 -0
  57. data/lib/vraptor-scaffold/generators/scaffold/client_generator/templates/details.erb +16 -0
  58. data/lib/vraptor-scaffold/generators/scaffold/client_generator/templates/form.erb +39 -0
  59. data/lib/vraptor-scaffold/generators/scaffold/client_generator/templates/list.erb +40 -0
  60. data/lib/vraptor-scaffold/generators/scaffold/controller_generator/controller_generator.rb +20 -0
  61. data/lib/vraptor-scaffold/generators/scaffold/controller_generator/templates/controller.erb +77 -0
  62. data/lib/vraptor-scaffold/generators/scaffold/controller_generator/templates/controller_test.erb +12 -0
  63. data/lib/vraptor-scaffold/generators/scaffold/model_generator/model_generator.rb +26 -0
  64. data/lib/vraptor-scaffold/generators/scaffold/model_generator/templates/model.erb +32 -0
  65. data/lib/vraptor-scaffold/generators/scaffold/model_generator/templates/model_test.erb +13 -0
  66. data/lib/vraptor-scaffold/generators/scaffold/repository_generator/repository_generator.rb +32 -0
  67. data/lib/vraptor-scaffold/generators/scaffold/repository_generator/templates/repository.erb +22 -0
  68. data/lib/vraptor-scaffold/generators/scaffold/repository_generator/templates/repository_impl.erb +16 -0
  69. data/lib/vraptor-scaffold/generators/scaffold/repository_generator/templates/repository_test.erb +13 -0
  70. data/lib/vraptor-scaffold/generators/scaffold/scaffold_generator.rb +35 -0
  71. data/lib/vraptor-scaffold/runner.rb +9 -0
  72. data/lib/vraptor-scaffold/runner/commands_help.rb +13 -0
  73. data/lib/vraptor-scaffold/runner/generator.rb +15 -0
  74. data/lib/vraptor-scaffold/runner/help.rb +12 -0
  75. data/lib/vraptor-scaffold/runner/scaffold.rb +16 -0
  76. data/lib/vraptor-scaffold/version.rb +3 -0
  77. data/maven/repo/br/com/caelum/vraptor-gae/1.0/vraptor-gae-1.0.jar +0 -0
  78. data/spec/resources/vraptor-scaffold-objectify.properties +7 -0
  79. data/spec/resources/vraptor-scaffold.properties +7 -0
  80. data/spec/spec.opts +4 -0
  81. data/spec/spec_helper.rb +31 -0
  82. data/spec/vraptor-scaffold/configuration_spec.rb +146 -0
  83. data/spec/vraptor-scaffold/execution_spec.rb +51 -0
  84. data/spec/vraptor-scaffold/generators/app/app_generator_spec.rb +557 -0
  85. data/spec/vraptor-scaffold/generators/app/dependency_manager_spec.rb +34 -0
  86. data/spec/vraptor-scaffold/generators/app/dependency_spec.rb +14 -0
  87. data/spec/vraptor-scaffold/generators/app/freemarker_template_engine_spec.rb +80 -0
  88. data/spec/vraptor-scaffold/generators/app/jsp_template_engine_spec.rb +77 -0
  89. data/spec/vraptor-scaffold/generators/app/templates/Entity.java +45 -0
  90. data/spec/vraptor-scaffold/generators/app/templates/FreemarkerPathResolver.java +21 -0
  91. data/spec/vraptor-scaffold/generators/app/templates/ObjectifyFactory.java +30 -0
  92. data/spec/vraptor-scaffold/generators/app/templates/RepositoryJPA.java +48 -0
  93. data/spec/vraptor-scaffold/generators/app/templates/RepositoryObjectify.java +41 -0
  94. data/spec/vraptor-scaffold/generators/app/templates/build.gradle +60 -0
  95. data/spec/vraptor-scaffold/generators/app/templates/build.properties +18 -0
  96. data/spec/vraptor-scaffold/generators/app/templates/build.xml +146 -0
  97. data/spec/vraptor-scaffold/generators/app/templates/classpath-gae +18 -0
  98. data/spec/vraptor-scaffold/generators/app/templates/decorators-jsp.xml +7 -0
  99. data/spec/vraptor-scaffold/generators/app/templates/decorators.xml +7 -0
  100. data/spec/vraptor-scaffold/generators/app/templates/freemarker-web.xml +60 -0
  101. data/spec/vraptor-scaffold/generators/app/templates/gae-jsp-web.xml +45 -0
  102. data/spec/vraptor-scaffold/generators/app/templates/ivy-gae.xml +45 -0
  103. data/spec/vraptor-scaffold/generators/app/templates/ivy.xml +40 -0
  104. data/spec/vraptor-scaffold/generators/app/templates/jsp-web.xml +45 -0
  105. data/spec/vraptor-scaffold/generators/app/templates/pom-heroku.xml +182 -0
  106. data/spec/vraptor-scaffold/generators/app/templates/pom.xml +157 -0
  107. data/spec/vraptor-scaffold/generators/app/templates/project-gae +47 -0
  108. data/spec/vraptor-scaffold/generators/app/templates/vraptor-scaffold.properties +7 -0
  109. data/spec/vraptor-scaffold/generators/plugin/expected_configs/build.gradle +62 -0
  110. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_build.gradle +62 -0
  111. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_ivy.xml +41 -0
  112. data/spec/vraptor-scaffold/generators/plugin/expected_configs/default_org_pom.xml +152 -0
  113. data/spec/vraptor-scaffold/generators/plugin/expected_configs/ivy.xml +42 -0
  114. data/spec/vraptor-scaffold/generators/plugin/expected_configs/pom.xml +182 -0
  115. data/spec/vraptor-scaffold/generators/scaffold/attribute_spec.rb +186 -0
  116. data/spec/vraptor-scaffold/generators/scaffold/base_scaffold_spec.rb +73 -0
  117. data/spec/vraptor-scaffold/generators/scaffold/client_controller_generator/controller_generator_spec.rb +62 -0
  118. data/spec/vraptor-scaffold/generators/scaffold/client_controller_generator/templates/ProductController.java +95 -0
  119. data/spec/vraptor-scaffold/generators/scaffold/controller_generator/controller_generator_spec.rb +62 -0
  120. data/spec/vraptor-scaffold/generators/scaffold/controller_generator/templates/ProductController.java +95 -0
  121. data/spec/vraptor-scaffold/generators/scaffold/freemarker_generator/freemarker_generator_spec.rb +81 -0
  122. data/spec/vraptor-scaffold/generators/scaffold/freemarker_generator/templates/form.ftl +28 -0
  123. data/spec/vraptor-scaffold/generators/scaffold/jsp_generator/jsp_generator_spec.rb +81 -0
  124. data/spec/vraptor-scaffold/generators/scaffold/jsp_generator/templates/form.jsp +61 -0
  125. data/spec/vraptor-scaffold/generators/scaffold/model_generator/model_generator_spec.rb +54 -0
  126. data/spec/vraptor-scaffold/generators/scaffold/model_generator/objectify_model_generator_spec.rb +40 -0
  127. data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/ObjectifyFactory.java +33 -0
  128. data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/Objectify_Product.java +38 -0
  129. data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/Product.java +25 -0
  130. data/spec/vraptor-scaffold/generators/scaffold/model_generator/templates/hibernate.cfg.xml +8 -0
  131. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/objectify_repository_generator_spec.rb +33 -0
  132. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/repository_generator_spec.rb +68 -0
  133. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ClientRepository.java +22 -0
  134. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ClientRepositoryImpl.java +16 -0
  135. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/Objectify_ProductRepository.java +22 -0
  136. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/Objectify_ProductRepositoryImpl.java +16 -0
  137. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ProductRepository.java +22 -0
  138. data/spec/vraptor-scaffold/generators/scaffold/repository_generator/templates/ProductRepositoryImpl.java +16 -0
  139. data/spec/vraptor-scaffold/generators/scaffold/scaffold_generator_spec.rb +79 -0
  140. data/spec/vraptor-scaffold/http_request_spec.rb +40 -0
  141. data/spec/vraptor-scaffold/runner/commands_help_spec.rb +12 -0
  142. data/spec/vraptor-scaffold/runner/configure_spec.rb +12 -0
  143. data/spec/vraptor-scaffold/runner/generator_spec.rb +31 -0
  144. data/spec/vraptor-scaffold/runner/help_spec.rb +29 -0
  145. data/spec/vraptor-scaffold/runner/scaffold_spec.rb +35 -0
  146. data/spec/vraptor-scaffold/runner/start_spec.rb +51 -0
  147. data/spec/vraptor-scaffold_spec.rb +4 -0
  148. metadata +261 -0
@@ -0,0 +1,16 @@
1
+ hibernate.connection.driver_class=org.hsqldb.jdbcDriver
2
+ hibernate.connection.url=jdbc:hsqldb:file:tmp/devdb
3
+ hibernate.hbm2ddl.auto=update
4
+ hibernate.query.substitutions=true=1, false=0
5
+ hibernate.show_sql=true
6
+ hibernate.format_sql=true
7
+
8
+ #DATASOURCE POOL CONFIGURATIONS
9
+ hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider
10
+ maxPoolSize=20
11
+ minPoolSize=3
12
+ initialPoolSize=3
13
+ timeout=25200
14
+ acquireIncrement=5
15
+ preferredTestQuery=select 1
16
+ idleConnectionTestPeriod=100
@@ -0,0 +1,4 @@
1
+ log4j.appender.console=org.apache.log4j.ConsoleAppender
2
+ log4j.appender.console.layout=org.apache.log4j.PatternLayout
3
+ log4j.appender.console.layout.ConversionPattern=%d{yy-MM-dd HH:mm:ss,SSS} [%p] %c - %m%n
4
+ log4j.rootLogger=info, console
@@ -0,0 +1,32 @@
1
+ // Underscore.js 1.3.3
2
+ // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
3
+ // Underscore is freely distributable under the MIT license.
4
+ // Portions of Underscore are inspired or borrowed from Prototype,
5
+ // Oliver Steele's Functional, and John Resig's Micro-Templating.
6
+ // For all details and documentation:
7
+ // http://documentcloud.github.com/underscore
8
+ (function(){function r(a,c,d){if(a===c)return 0!==a||1/a==1/c;if(null==a||null==c)return a===c;a._chain&&(a=a._wrapped);c._chain&&(c=c._wrapped);if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return!1;switch(e){case "[object String]":return a==""+c;case "[object Number]":return a!=+a?c!=+c:0==a?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
9
+ c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if("object"!=typeof a||"object"!=typeof c)return!1;for(var f=d.length;f--;)if(d[f]==a)return!0;d.push(a);var f=0,g=!0;if("[object Array]"==e){if(f=a.length,g=f==c.length)for(;f--&&(g=f in a==f in c&&r(a[f],c[f],d)););}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return!1;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&r(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,h)&&!f--)break;
10
+ g=!f}}d.pop();return g}var s=this,I=s._,o={},k=Array.prototype,p=Object.prototype,i=k.slice,J=k.unshift,l=p.toString,K=p.hasOwnProperty,y=k.forEach,z=k.map,A=k.reduce,B=k.reduceRight,C=k.filter,D=k.every,E=k.some,q=k.indexOf,F=k.lastIndexOf,p=Array.isArray,L=Object.keys,t=Function.prototype.bind,b=function(a){return new m(a)};"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=b),exports._=b):s._=b;b.VERSION="1.3.3";var j=b.each=b.forEach=function(a,
11
+ c,d){if(a!=null)if(y&&a.forEach===y)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===o)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===o)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(z&&a.map===z)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(A&&
12
+ a.reduce===A){e&&(c=b.bind(c,e));return f?a.reduce(c,d):a.reduce(c)}j(a,function(a,b,i){if(f)d=c.call(e,d,a,b,i);else{d=a;f=true}});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(B&&a.reduceRight===B){e&&(c=b.bind(c,e));return f?a.reduceRight(c,d):a.reduceRight(c)}var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=function(a,
13
+ c,b){var e;G(a,function(a,g,h){if(c.call(b,a,g,h)){e=a;return true}});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(C&&a.filter===C)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(D&&a.every===D)return a.every(c,b);j(a,function(a,g,h){if(!(e=e&&c.call(b,
14
+ a,g,h)))return o});return!!e};var G=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(E&&a.some===E)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return o});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;if(q&&a.indexOf===q)return a.indexOf(c)!=-1;return b=G(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
15
+ function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&
16
+ (e={value:a,computed:b})});return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){d=Math.floor(Math.random()*(f+1));b[f]=b[d];b[d]=a});return b};b.sortBy=function(a,c,d){var e=b.isFunction(c)?c:function(a){return a[c]};return b.pluck(b.map(a,function(a,b,c){return{value:a,criteria:e.call(d,a,b,c)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c===void 0?1:d===void 0?-1:c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};
17
+ j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:b.isArray(a)||b.isArguments(a)?i.call(a):a.toArray&&b.isFunction(a.toArray)?a.toArray():b.values(a)};b.size=function(a){return b.isArray(a)?a.length:b.keys(a).length};b.first=b.head=b.take=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,
18
+ 0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,
19
+ e=[];a.length<3&&(c=true);b.reduce(d,function(d,g,h){if(c?b.last(d)!==g||!d.length:!b.include(d,g)){d.push(g);e.push(a[h])}return d},[]);return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1),true);return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=
20
+ i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,d){if(a==null)return-1;var e;if(d){d=b.sortedIndex(a,c);return a[d]===c?d:-1}if(q&&a.indexOf===q)return a.indexOf(c);d=0;for(e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(F&&a.lastIndexOf===F)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){if(arguments.length<=
21
+ 1){b=a||0;a=0}for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;){g[f++]=a;a=a+d}return g};var H=function(){};b.bind=function(a,c){var d,e;if(a.bind===t&&t)return t.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));H.prototype=a.prototype;var b=new H,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=
22
+ i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(null,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i,j=b.debounce(function(){h=
23
+ g=false},c);return function(){d=this;e=arguments;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);j()},c));g?h=true:i=a.apply(d,e);j();g=true;return i}};b.debounce=function(a,b,d){var e;return function(){var f=this,g=arguments;d&&!e&&a.apply(f,g);clearTimeout(e);e=setTimeout(function(){e=null;d||a.apply(f,g)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));
24
+ return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=L||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&
25
+ c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.pick=function(a){var c={};j(b.flatten(i.call(arguments,1)),function(b){b in a&&(c[b]=a[b])});return c};b.defaults=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return r(a,b,[])};b.isEmpty=
26
+ function(a){if(a==null)return true;if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=p||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};b.isArguments=function(a){return l.call(a)=="[object Arguments]"};b.isArguments(arguments)||(b.isArguments=function(a){return!(!a||!b.has(a,"callee"))});b.isFunction=function(a){return l.call(a)=="[object Function]"};
27
+ b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isFinite=function(a){return b.isNumber(a)&&isFinite(a)};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,
28
+ b){return K.call(a,b)};b.noConflict=function(){s._=I;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")};b.result=function(a,c){if(a==null)return null;var d=a[c];return b.isFunction(d)?d.call(a):d};b.mixin=function(a){j(b.functions(a),function(c){M(c,b[c]=a[c])})};var N=0;b.uniqueId=
29
+ function(a){var b=N++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var u=/.^/,n={"\\":"\\","'":"'",r:"\r",n:"\n",t:"\t",u2028:"\u2028",u2029:"\u2029"},v;for(v in n)n[n[v]]=v;var O=/\\|'|\r|\n|\t|\u2028|\u2029/g,P=/\\(\\|'|r|n|t|u2028|u2029)/g,w=function(a){return a.replace(P,function(a,b){return n[b]})};b.template=function(a,c,d){d=b.defaults(d||{},b.templateSettings);a="__p+='"+a.replace(O,function(a){return"\\"+n[a]}).replace(d.escape||
30
+ u,function(a,b){return"'+\n_.escape("+w(b)+")+\n'"}).replace(d.interpolate||u,function(a,b){return"'+\n("+w(b)+")+\n'"}).replace(d.evaluate||u,function(a,b){return"';\n"+w(b)+"\n;__p+='"})+"';\n";d.variable||(a="with(obj||{}){\n"+a+"}\n");var a="var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n"+a+"return __p;\n",e=new Function(d.variable||"obj","_",a);if(c)return e(c,b);c=function(a){return e.call(this,a,b)};c.source="function("+(d.variable||"obj")+"){\n"+a+"}";return c};
31
+ b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var x=function(a,c){return c?b(a).chain():a},M=function(a,c){m.prototype[a]=function(){var a=i.call(arguments);J.call(a,this._wrapped);return x(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return x(d,
32
+ this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return x(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);
@@ -0,0 +1,5 @@
1
+ package: <%= options[:package] %>
2
+ orm: <%= orm %>
3
+ models_package: <%= options[:models_package] %>
4
+ controllers_package: <%= options[:controllers_package] %>
5
+ repositories_package: <%= options[:repositories_package] %>
@@ -0,0 +1,33 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
3
+ xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
4
+ id="WebApp_ID" version="2.5">
5
+
6
+ <display-name><%= @project_name %></display-name>
7
+
8
+ <context-param>
9
+ <param-name>br.com.caelum.vraptor.packages</param-name>
10
+ <param-value><%= @vraptor_packages * "," %></param-value>
11
+ </context-param>
12
+
13
+ <context-param>
14
+ <param-name>br.com.caelum.vraptor.provider</param-name>
15
+ <param-value>com.github.filipesperandio.vraptor.hypermedia.HypermediaProvider</param-value>
16
+ </context-param>
17
+
18
+ <context-param>
19
+ <param-name>br.com.caelum.vraptor.encoding</param-name>
20
+ <param-value>UTF-8</param-value>
21
+ </context-param>
22
+
23
+ <filter>
24
+ <filter-name>vraptor</filter-name>
25
+ <filter-class>br.com.caelum.vraptor.VRaptor</filter-class>
26
+ </filter>
27
+
28
+ <filter-mapping>
29
+ <filter-name>vraptor</filter-name>
30
+ <url-pattern>/*</url-pattern>
31
+ </filter-mapping>
32
+
33
+ </web-app>
@@ -0,0 +1,24 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+
3
+ <html NGAPP>
4
+ <head>
5
+ <title></title>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
7
+ <script type="text/javascript" src="/javascripts/jquery.min.js"></script>
8
+ <script type="text/javascript" src="/javascripts/underscore.min.js"></script>
9
+ <script type="text/javascript" src="/javascripts/angular.js"></script>
10
+ <script type="text/javascript" src="/javascripts/bootstrap.js"></script>
11
+ <script type="text/javascript" src="/javascripts/CONTROLLER"></script>
12
+ <script type="text/javascript" src="/javascripts/application.js"></script>
13
+ <script type="text/javascript" src="/javascripts/utils.js"></script>
14
+ <link rel="stylesheet" type="text/css" href="/stylesheets/bootstrap.css" />
15
+ </head>
16
+ <body>
17
+ <div>
18
+ <br />
19
+ <div class="span12">
20
+ <div ng-view></div>
21
+ </div>
22
+ </div>
23
+ </body>
24
+ </html>
@@ -0,0 +1,7 @@
1
+ var Request = function(action, resource) {
2
+ var self = action;
3
+ delete resource.links;
4
+ self.data = resource;
5
+ return self;
6
+ };
7
+
@@ -0,0 +1,16 @@
1
+ module VraptorScaffold
2
+ class Base < Thor::Group
3
+ include Thor::Actions
4
+ end
5
+ end
6
+
7
+ require File.dirname(__FILE__) + '/app/app_generator'
8
+ require File.dirname(__FILE__) + '/app/dependency'
9
+ require File.dirname(__FILE__) + '/app/dependency_manager'
10
+ require File.dirname(__FILE__) + '/scaffold/attribute'
11
+ require File.dirname(__FILE__) + '/scaffold/scaffold_generator'
12
+ require File.dirname(__FILE__) + '/scaffold/base_scaffold'
13
+ require File.dirname(__FILE__) + '/scaffold/model_generator/model_generator'
14
+ require File.dirname(__FILE__) + '/scaffold/repository_generator/repository_generator'
15
+ require File.dirname(__FILE__) + '/scaffold/controller_generator/controller_generator'
16
+ require File.dirname(__FILE__) + '/scaffold/client_generator/client_generator'
@@ -0,0 +1,51 @@
1
+ class Attribute
2
+ attr_accessor :name, :type
3
+
4
+ def initialize(name, type)
5
+ @name = name.underscore.camelize(:lower)
6
+ @type = type.downcase
7
+ validate
8
+ end
9
+
10
+ def html_input
11
+ input = "text"
12
+ input = "checkbox" if boolean?
13
+ input = "textarea" if text?
14
+ input
15
+ end
16
+
17
+ def html_label
18
+ @name.underscore.humanize
19
+ end
20
+
21
+ def java_type
22
+ java = type.capitalize
23
+ java = "boolean" if boolean?
24
+ java = "String" if text?
25
+ java
26
+ end
27
+
28
+ def self.valid_types
29
+ %w(boolean double float short integer long string text)
30
+ end
31
+
32
+ def boolean?
33
+ @type.eql? "boolean"
34
+ end
35
+
36
+ def text?
37
+ @type.eql? "text"
38
+ end
39
+
40
+ def getter_prefix
41
+ return "is" if boolean?
42
+ "get"
43
+ end
44
+
45
+ def validate
46
+ unless Attribute.valid_types.include?(@type)
47
+ puts "Attribute #{@type} is not supported. The supported attributes types are: #{Attribute.valid_types.join(", ")}"
48
+ Kernel::exit
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,54 @@
1
+ class BaseScaffold < VraptorScaffold::Base
2
+
3
+ def initialize(model, attributes={})
4
+ super
5
+ @model = model
6
+ @attributes = attributes
7
+ end
8
+
9
+ def model_parameter_name
10
+ @model.camelize(:lower)
11
+ end
12
+
13
+ def class_name
14
+ @model.camelize
15
+ end
16
+
17
+ def model_list_name
18
+ model_parameter_name.pluralize
19
+ end
20
+
21
+ def test_class_name
22
+ "#{class_name}Test"
23
+ end
24
+
25
+ def repository_interface_name
26
+ "#{class_name}Repository"
27
+ end
28
+
29
+ def repository_impl_name
30
+ "#{repository_interface_name}Impl"
31
+ end
32
+
33
+ def repository_test_class_name
34
+ "#{repository_impl_name}Test"
35
+ end
36
+
37
+ def controller_class_name
38
+ "#{class_name}Controller"
39
+ end
40
+
41
+ def controller_test_class_name
42
+ "#{controller_class_name}Test"
43
+ end
44
+
45
+ def base_path
46
+ model_parameter_name.pluralize
47
+ end
48
+
49
+ protected
50
+ def define_source_paths
51
+ source_paths << File.expand_path(template_path) if File.exists?(template_path)
52
+ source_paths << source_root
53
+ end
54
+ end
@@ -0,0 +1,41 @@
1
+ class ClientGenerator < BaseScaffold
2
+
3
+ def build
4
+ define_source_paths
5
+ @template_dir = "#{Configuration::FRONTEND}/#{model_parameter_name}/"
6
+ empty_directory @template_dir
7
+ create_js("controller", "#{controller_class_name}")
8
+ generate_html("list")
9
+ generate_html("details")
10
+ generate_html("form")
11
+ update_index
12
+ end
13
+
14
+ def create_js(template_name, file_name=template_name)
15
+ template("#{template_name}.erb", "#{Configuration::JAVASCRIPTS}/#{file_name}.js")
16
+ end
17
+
18
+ def generate_html(template_name)
19
+ template("#{template_name}.erb", "#{@template_dir}/#{template_name}.html")
20
+ end
21
+
22
+ def update_index
23
+ file = "#{Configuration::WEB_APP}/index.html"
24
+ index_content = File.read(file)
25
+ updated_content = index_content.gsub("NGAPP", "ng-app=\"#{class_name}Module\"")
26
+ updated_content = updated_content.gsub("CONTROLLER", "#{controller_class_name}.js")
27
+ File.open(file, "w") { |file| file.puts updated_content }
28
+ end
29
+
30
+ def template_path
31
+ "src/templates/client"
32
+ end
33
+
34
+ def source_root
35
+ File.join File.dirname(__FILE__), "templates"
36
+ end
37
+
38
+ def path
39
+ "/#{base_path}"
40
+ end
41
+ end
@@ -0,0 +1,75 @@
1
+ angular.module('<%= class_name %>Module', []).
2
+ config(['$routeProvider', function($routeProvider) {
3
+ $routeProvider.
4
+ when('/<%= model_list_name %>', { templateUrl: '/templates/<%= model_parameter_name %>/list.html', controller: <%= class_name %>IndexController }).
5
+ when('/<%= model_list_name %>/new', {templateUrl: '/templates/<%= model_parameter_name %>/form.html', controller: <%= class_name %>CreationController}).
6
+ when('/<%= model_list_name %>/:resourceId/edit', {templateUrl: '/templates/<%= model_parameter_name %>/form.html', controller: <%= class_name %>EditController}).
7
+ when('/<%= model_list_name %>/:resourceId', {templateUrl: '/templates/<%= model_parameter_name %>/details.html', controller: <%= class_name %>DetailsController}).
8
+ otherwise({redirectTo: '/<%= model_list_name %>'});
9
+ }]);
10
+
11
+
12
+ var <%= controller_class_name %> = function($scope, $http, $location) {
13
+ var indexPath = '/<%= base_path %>';
14
+
15
+ $scope.destroy = function(resource) {
16
+ if (confirm("Are you sure?")) {
17
+ $http(resource.links.destroy).success(function() {
18
+ $scope.<%= model_list_name %> = _.reject($scope.<%= model_list_name %>, function(element) {
19
+ return element.id === resource.id;
20
+ });
21
+ }).error($scope.error);
22
+ }
23
+ };
24
+
25
+ $scope.error = function() {
26
+ alert("Operation failed!");
27
+ };
28
+
29
+ $scope.load = function() {
30
+ $http.get(indexPath).success(function(data) {
31
+ $scope.<%= model_list_name %> = data;
32
+ });
33
+ };
34
+
35
+ $scope.get = function(resourceId) {
36
+ $http.get(indexPath + '/' + resourceId).success(function(data) {
37
+ $scope.<%= model_parameter_name %> = data;
38
+ });
39
+ };
40
+
41
+ $scope.create = function(resource) {
42
+ $http.post(indexPath, resource).success(function() {
43
+ $location.path(indexPath);
44
+ }).error($scope.error);
45
+ };
46
+
47
+ $scope.update = function(resource) {
48
+ var request = new Request(resource.links.update, resource);
49
+ $http(request).success(function() {
50
+ $location.path(indexPath);
51
+ }).error($scope.error);
52
+ };
53
+
54
+ return $scope;
55
+ };
56
+
57
+ var <%= class_name %>IndexController = function($scope, $http, $location) {
58
+ var self = new <%= controller_class_name %>($scope, $http, $location);
59
+ self.load();
60
+ };
61
+
62
+ var <%= class_name %>EditController = function($scope, $http, $routeParams, $location) {
63
+ var self = new <%= controller_class_name %>($scope, $http, $location);
64
+ self.get($routeParams.resourceId);
65
+ };
66
+
67
+ var <%= class_name %>CreationController = function($scope, $http, $location) {
68
+ var self = new <%= controller_class_name %>($scope, $http, $location);
69
+ };
70
+
71
+ var <%= class_name %>DetailsController = function($scope, $http, $routeParams, $location) {
72
+ var self = new <%= controller_class_name %>($scope, $http, $location);
73
+ self.get($routeParams.resourceId);
74
+ };
75
+
@@ -0,0 +1,16 @@
1
+ <div class="row">
2
+ <div class="span6">
3
+ <div class="well">
4
+ <% @attributes.each do |att| -%>
5
+ <p>
6
+ <b><%= att.name.camelize %>:</b> {{<%= model_parameter_name %>.<%= att.name %>}}
7
+ </p>
8
+ <br />
9
+ <% end -%>
10
+
11
+ <a class="btn" href="#/<%= model_list_name %>">Back</a>
12
+ <a class="btn btn-info" href="#{{<%= model_parameter_name %>.links.location.url}}">Edit</a>
13
+ </div>
14
+ </div>
15
+ </div>
16
+
@@ -0,0 +1,39 @@
1
+ <div class="row">
2
+ <div class="span6">
3
+ <div class="well">
4
+ <form class="form-horizontal" id="<%= model_parameter_name %>Form">
5
+ <fieldset>
6
+ <legend><%= model_parameter_name %></legend>
7
+
8
+ <% @attributes.each do |att| -%>
9
+ <div class="control-group">
10
+ <label class="control-label"
11
+ for="<%= model_parameter_name %>.<%= att.name %>"> <%= att.name.camelize %> </label>
12
+ <div class="controls">
13
+ <input type="text" name="<%= model_parameter_name %>.<%= att.name %>"
14
+ id="<%= model_parameter_name %>.<%= att.name %>"
15
+ ng-model="<%= model_parameter_name %>.<%= att.name %>" />
16
+ </div>
17
+ </div>
18
+ <% end -%>
19
+
20
+ <div class="form-actions">
21
+ <div class="pull-right">
22
+ <button class="btn btn-primary"
23
+ ng-click="create(<%= model_parameter_name %>)"
24
+ ng-hide="<%= model_parameter_name %>.id">Create</button>
25
+ <button class="btn btn-primary"
26
+ ng-click="update(<%= model_parameter_name %>)"
27
+ ng-show="<%= model_parameter_name %>.id">Update</button>
28
+ <a href="#/<%= model_list_name %>" class="btn">Cancel</a>
29
+ </div>
30
+ </div>
31
+
32
+ </fieldset>
33
+ </form>
34
+ </div>
35
+ </div>
36
+ <div class="span6"></div>
37
+ </div>
38
+
39
+
@@ -0,0 +1,40 @@
1
+ <div>
2
+
3
+ <div class="row">
4
+ <div class="span12">
5
+ <div class="well">
6
+ <div class="row-fluid">
7
+ <div class="span8">
8
+ <h1><%= model_list_name %></h1>
9
+ </div>
10
+ <div class="span4">
11
+ <a href="#/<%= model_list_name %>/new" class="btn btn-primary">New <%= class_name %></a>
12
+ </div>
13
+ </div>
14
+ </div>
15
+ </div>
16
+ </div>
17
+
18
+ <div class="row" ng-repeat="<%= model_parameter_name %> in <%= model_list_name %>">
19
+ <div class="span12">
20
+ <div class="well">
21
+ <div class="row-fluid">
22
+ <div class="span8">
23
+ <% @attributes.each do |att| -%>
24
+ <%= att.name.camelize %>: {{<%= model_parameter_name %>.<%= att.name %>}}
25
+ <br />
26
+ <% end -%>
27
+ </div>
28
+ <div class="span4 controls admin">
29
+ <a class="btn btn-info" href="#{{<%= model_parameter_name %>.links.location.url}}">show</a>
30
+ <a class="btn btn-info" href="#{{<%= model_parameter_name %>.links.location.url}}/edit">edit</a>
31
+ <a class="btn btn-inverse" ng-click="destroy(<%= model_parameter_name %>)">destroy</a>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ </div>
37
+
38
+ </div>
39
+
40
+