Class: Appmake::Appmake
- Inherits:
-
Thor
- Object
- Thor
- Appmake::Appmake
- Includes:
- Thor::Actions
- Defined in:
- lib/appmake.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.source_root ⇒ Object
9 10 11 |
# File 'lib/appmake.rb', line 9 def self.source_root File.dirname(File.dirname(__FILE__)) end |
Instance Method Details
#compile(name) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/appmake.rb', line 70 def compile(name) if name == "css" Dir.glob "css/*.scss" do |f| name = f.split("/").last if name[0] == name[0].upcase new_name = name.gsub "scss", "css" run "bundle exec sass css/#{name} public/css/#{new_name}" end end elsif name == "js" Dir.glob "js/*.js" do |f| name = f.split("/").last if name[0] == name[0].upcase run "./node_modules/.bin/webmake js/#{name} public/js/#{name}" end end elsif name == "tpl" run "./node_modules/.bin/dot-module -d tpl/ -o js/templates.js" elsif name == "coffee" Dir.glob "coffee/*.coffee" do |f| name = f.split("/").last new_name = name.gsub "coffee", "js" run "./node_modules/.bin/coffee -c coffee/#{name}" run "mv coffee/#{new_name} js/#{new_name}" if name[0] == name[0].upcase run "./node_modules/.bin/webmake js/#{new_name} public/js/#{new_name}" end end end end |
#init ⇒ Object
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 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/appmake.rb', line 19 def init template "templates/package.json.tt", "package.json" template "templates/README.md.tt", "README.md" empty_directory "css" template "templates/css/App.scss.tt", "css/App.scss" template "templates/css/body.scss.tt", "css/body.scss" empty_directory "js" template "templates/js/App.js.tt", "js/App.js" empty_directory "tpl" template "templates/tpl/welcome.html.tt", "tpl/welcome.html" empty_directory "public" template "templates/public/index.html.tt", "public/index.html" empty_directory "public/css" empty_directory "public/js" empty_directory "public/img" if .coffee? empty_directory "coffee" end if .jquery? install "jquery" end if .underscore? install "underscore" end if .backbone? install "backbone" end if .bootstrap? install "bootstrap" end run "npm install" compile "css" compile "tpl" compile "coffee" compile "js" end |
#install(name) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/appmake.rb', line 132 def install(name) if name == "jquery" empty_directory "public" empty_directory "public/js" run "curl http://code.jquery.com/jquery-1.9.0.min.js -o public/js/jquery.min.js" elsif name == "underscore" empty_directory "public" empty_directory "public/js" run "curl http://underscorejs.org/underscore-min.js -o public/underscore.min.js" elsif name == "backbone" empty_directory "public" empty_directory "public/js" run "curl -silent http://backbonejs.org/backbone-min.js -o public/backbone.min.js" elsif name == "bootstrap" empty_directory "public" empty_directory "public/css" empty_directory "public/img" empty_directory "public/js" run "curl -silent http://twitter.github.com/bootstrap/assets/bootstrap.zip -o public/bootstrap.zip" run "unzip public/bootstrap.zip -d public" run "mv public/bootstrap/js/bootstrap.min.js public/js/" run "mv public/bootstrap/css/bootstrap.min.css public/css/" run "mv public/bootstrap/css/bootstrap-responsive.min.css public/css/" run "mv public/bootstrap/img/* public/img/" run "rm -rf public/bootstrap" run "rm public/bootstrap.zip" else abort "error: cannot install #{name}" end end |
#watch ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/appmake.rb', line 102 def watch css = Listen.to "css", :filter => /\.scss$/ css.change do compile "css" end css.start(false) if Dir.exists? "coffee" coffee = Listen.to "coffee", :filter => /\.coffee$/ coffee.change do compile "coffee" end coffee.start(false) end tpl = Listen.to "tpl", :filter => /\.html$/ tpl.change do compile "tpl" end tpl.start(false) js = Listen.to "js", :filter => /\.js$/ js.change do compile "js" end js.start(true) end |