kanazawa.rb #04 (2012/12/01) の LT資料。$25 がツライ人に向けた Rake & Guard 紹介。
Yet another CodeKitfor Poor Rubyist2012.12.01 - Kanazawa.rb #4 LT
View Slide
CodeKithttp://incident57.com/codekit/It’s like steroids for web developers.Auto compiler for coffee, less and more.
YES !!
Remember !!
We are Developer
We have FREE editor
andWe are Rubyist !!
http://www.flickr.com/photos/donkeyhotey/5521102662/
Rake & Guard
Rake & Guard(Compile)
Rake methodstask : => []directory file => [] do |t|done
Rakefile (1)DIR_SRC = "src";DIR_DIST = "dist";directory DIR_DISTdist_entries = [ DIR_DIST ];Dir.glob(DIR_SRC + "/**/*") do |src_entry|# create task (dist_entries.push)endtask :make_dist => dist_entries;
Rakefile (2)# create task (dist_entries.push)dist_entry = src_entry.sub(/^#{DIR_SRC}/, "#{DIR_DIST}");dist_dirname = File.dirname(dist_entry);if File.directory?(src_entry) thendirectory dist_entry;else# create FILE taskenddist_entries.push(dist_entry);
Rakefile (3)# create FILE taskext_name = File.extname(src_entry);if /\.(coffee)$/i =~ ext_name thendist_js = Pathname(dist_entry).sub_ext(".js").to_s;file dist_js => [src_entry, dist_dirname] do |t|`coffee -p -c #{src_entry} > #{dist_js}`;enddist_entry = dist_js;elsif /\.(less)$/i =~ ext_name then# XXXend
Rakefile (3)# create FILE taskext_name = File.extname(src_entry);if /\.(coffee)$/i =~ ext_name thendist_js = Pathname(dist_entry).sub_ext(".js").to_s;file dist_js => [src_entry, dist_dirname] do |t|`coffee -p -c #{src_entry} > #{dist_js}`;enddist_entry = dist_js;elsif /\.(less)$/i =~ ext_name then# XXXends
$ rake make_dist
Rake & Guard(Automation)
Guard$ gem install guard-shell
Guardfileguard 'shell' dowatch(%r{src/**}) {|m| `rake make_dist` }end
$ guard$ vi src/**ˣAuto Compile !!(rake make_dist)
http://www.flickr.com/photos/gottabe/3005858804/
Rake & GuardareSteroids for You !!
And more !
You can Custom!!minifylive reloadand more ...
Samplehttps://github.com/kiyohara/kanazawa_rb_04
thank you !!Tomokazu Kiyoharahttp://facebook.com/tomokazu.kiyoharahttp://twitter.com/kiyohara