Class: Lumbar::Tasks
- Inherits:
-
Thor
- Object
- Thor
- Lumbar::Tasks
- Includes:
- Thor::Actions
- Defined in:
- lib/lumbar/tasks.rb
Direct Known Subclasses
Constant Summary collapse
- APP_JS_TEMPLATE =
<<-EOS // You can push your own app_scripts here, example: // app_scripts.push('app/lib/my_plugin'); function app_main(DEBUG) { if (app_scripts.length > 0) { head.js.apply(head, app_scripts); } head.ready(function(){ // Initialize your application here. // new App(); // Then: Backbone.history.start(); }); }; E
- APP_SCRIPTS_TEMPLATE =
<<-EOS // auto-generated... Add your scripts in app_main.js var app_scripts = []; <% app_scripts.each do |script| %> app_scripts.push('<%= script %>');<% end %> EOS
- INDEX_HTML_TEMPLATE =
<<-EOS <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title><%= app_name %></title> <!-- Created by Matt McCray on <%= Time.now %> --> <script src="app/lib/head.js"></script> <script> var DEBUG = (window.location.href.indexOf('file:') == 0), app_main_src = 'app/app_main.js'+ (DEBUG ? '?'+((new Date).getTime()) : ''); head.js("app/lib/<%= app_libs.join '.js", "app/lib/' %>.js", "app/app_scripts.js", app_main_src, function(){ app_main(DEBUG); }); </script> </head> <body> <header></header> <nav></nav> <article> <section></section> </article> <aside></aside> <footer></footer> </body> </html> EOS
- CONTROLLER_TEMPLATE =
<<-EOS var <%= className %> = Backbone.Controller.extend({ routes: { '': 'index' }, index: function() { } }); EOS
- MODEL_TEMPLATE =
<<-EOS var <%= className %> = Backbone.Model.extend({ }); var <%= className %>Collection = Backbone.Collection.extend({ model: <%= className %> }); EOS
- VIEW_TEMPLATE =
<<-EOS var <%= className %> = Backbone.View.extend({ events: { }, initialize: function() { _.bindAll(this, "render"); }, render: function() { } }); EOS
- RAKEFILE_TEMPLATE =
<<-EOS # Your thor tasks here... require 'lumbar/tasks' EOS
- JS_LIBS =
{ 'jquery' => 'http://code.jquery.com/jquery-1.4.4.min.js', 'backbone' => 'http://documentcloud.github.com/backbone/backbone-min.js', 'underscore' => 'http://documentcloud.github.com/underscore/underscore-min.js', 'head' => 'https://github.com/headjs/headjs/raw/master/dist/head.min.js' }
Instance Method Summary collapse
Instance Method Details
#new(type = nil, name = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/lumbar/tasks.rb', line 13 def new(type=nil, name=nil) type = type.nil? ? 'help' : type.downcase if name.nil? and type != 'help' unless type == 'project' or in_app? say "You need to be in a project directory to run this command." exit 0 end name = ask "#{type.capitalize} name:" end case type when 'project' say "Creating project #{name}:" create_project name when 'controller' say "Creating controller #{name}:" build_controller name when 'model' say "Creating model #{name}:" build_model name when 'view' say "Creating view #{name}:" build_view name else say <<-EOS Usage: lumbar new TYPE NAME Types: - project - controller - model (creates a collection too) - view EOS end say "Done." end |
#serve ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/lumbar/tasks.rb', line 71 def serve require 'webrick' say "Launching server at 127.0.0.1:#{.port}" server = WEBrick::HTTPServer.new( :Port => .port, :FancyIndexing => true, :DocumentRoot => '.', :MimeTypes => { 'js' => 'text/plain', 'coffee' => 'text/plain', 'css' => 'text/plain', 'less' => 'text/plain', 'thor' => 'text/plain', 'html' => 'text/html' } ) trap('INT') { server.stop } server.start end |
#update(type = 'scripts') ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/lumbar/tasks.rb', line 57 def update(type='scripts') #TODO: Support type=libs -- pull latest libraries if in_app? say "Updating app_scripts:" update_scripts else say "You need to be in a project directory to run this command." exit 0 end end |