Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Yet another CodeKit for Poor Rubyist

Yet another CodeKit for Poor Rubyist

kanazawa.rb #04 (2012/12/01) の LT資料。$25 がツライ人に向けた Rake & Guard 紹介。

Cb057b585817007ba2a931a81ef9398f?s=128

Tomokazu Kiyohara

December 01, 2012
Tweet

Transcript

  1. Yet another CodeKit for Poor Rubyist 2012.12.01 - Kanazawa.rb #4

    LT
  2. CodeKit http:/ /incident57 .com/codekit/ It’s like steroids for web developers.

    Auto compiler for coffee, less and more.
  3. YES !!

  4. None
  5. None
  6. None
  7. None
  8. Remember !!

  9. We are Developer

  10. We have FREE editor

  11. and We are Rubyist !!

  12. http://www.flickr.com/photos/donkeyhotey/5521102662/

  13. Rake & Guard

  14. Rake & Guard (Compile)

  15. Rake methods task :<task name> => [<depend files>] directory <dir

    path> file <target> => [<depend files>] do |t| <operation> done
  16. Rakefile (1) DIR_SRC = "src"; DIR_DIST = "dist"; directory DIR_DIST

    dist_entries = [ DIR_DIST ]; Dir.glob(DIR_SRC + "/**/*") do |src_entry| # create task (dist_entries.push) end task :make_dist => dist_entries;
  17. Rakefile (1) DIR_SRC = "src"; DIR_DIST = "dist"; directory DIR_DIST

    dist_entries = [ DIR_DIST ]; Dir.glob(DIR_SRC + "/**/*") do |src_entry| # create task (dist_entries.push) end task :make_dist => dist_entries;
  18. Rakefile (1) DIR_SRC = "src"; DIR_DIST = "dist"; directory DIR_DIST

    dist_entries = [ DIR_DIST ]; Dir.glob(DIR_SRC + "/**/*") do |src_entry| # create task (dist_entries.push) end task :make_dist => dist_entries;
  19. Rakefile (1) DIR_SRC = "src"; DIR_DIST = "dist"; directory DIR_DIST

    dist_entries = [ DIR_DIST ]; Dir.glob(DIR_SRC + "/**/*") do |src_entry| # create task (dist_entries.push) end task :make_dist => dist_entries;
  20. Rakefile (1) DIR_SRC = "src"; DIR_DIST = "dist"; directory DIR_DIST

    dist_entries = [ DIR_DIST ]; Dir.glob(DIR_SRC + "/**/*") do |src_entry| # create task (dist_entries.push) end task :make_dist => dist_entries;
  21. Rakefile (1) DIR_SRC = "src"; DIR_DIST = "dist"; directory DIR_DIST

    dist_entries = [ DIR_DIST ]; Dir.glob(DIR_SRC + "/**/*") do |src_entry| # create task (dist_entries.push) end task :make_dist => dist_entries;
  22. 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) then directory dist_entry; else # create FILE task end dist_entries.push(dist_entry);
  23. 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) then directory dist_entry; else # create FILE task end dist_entries.push(dist_entry);
  24. 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) then directory dist_entry; else # create FILE task end dist_entries.push(dist_entry);
  25. Rakefile (3) # create FILE task ext_name = File.extname(src_entry); if

    /\.(coffee)$/i =~ ext_name then dist_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}`; end dist_entry = dist_js; elsif /\.(less)$/i =~ ext_name then # XXX end
  26. Rakefile (3) # create FILE task ext_name = File.extname(src_entry); if

    /\.(coffee)$/i =~ ext_name then dist_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}`; end dist_entry = dist_js; elsif /\.(less)$/i =~ ext_name then # XXX end
  27. Rakefile (3) # create FILE task ext_name = File.extname(src_entry); if

    /\.(coffee)$/i =~ ext_name then dist_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}`; end dist_entry = dist_js; elsif /\.(less)$/i =~ ext_name then # XXX end
  28. Rakefile (3) # create FILE task ext_name = File.extname(src_entry); if

    /\.(coffee)$/i =~ ext_name then dist_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}`; end dist_entry = dist_js; elsif /\.(less)$/i =~ ext_name then # XXX end
  29. Rakefile (3) # create FILE task ext_name = File.extname(src_entry); if

    /\.(coffee)$/i =~ ext_name then dist_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}`; end dist_entry = dist_js; elsif /\.(less)$/i =~ ext_name then # XXX end
  30. Rakefile (3) # create FILE task ext_name = File.extname(src_entry); if

    /\.(coffee)$/i =~ ext_name then dist_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}`; end dist_entry = dist_js; elsif /\.(less)$/i =~ ext_name then # XXX end
  31. Rakefile (3) # create FILE task ext_name = File.extname(src_entry); if

    /\.(coffee)$/i =~ ext_name then dist_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}`; end dist_entry = dist_js; elsif /\.(less)$/i =~ ext_name then # XXX end
  32. Rakefile (3) # create FILE task ext_name = File.extname(src_entry); if

    /\.(coffee)$/i =~ ext_name then dist_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}`; end dist_entry = dist_js; elsif /\.(less)$/i =~ ext_name then # XXX end s
  33. $ rake make_dist

  34. Rake & Guard (Automation)

  35. Guard $ gem install guard-shell

  36. Guard $ gem install guard-shell

  37. Guardfile guard 'shell' do watch(%r{src/**}) {|m| `rake make_dist` } end

  38. Guardfile guard 'shell' do watch(%r{src/**}) {|m| `rake make_dist` } end

  39. $ guard $ vi src/** ˣ Auto Compile !! (rake

    make_dist)
  40. http://www.flickr.com/photos/gottabe/3005858804/

  41. Rake & Guard are Steroids for You !!

  42. And more !

  43. You can Custom!! minify live reload and more ...

  44. Sample https:/ /github.com/kiyohara/kanazawa_rb_04

  45. thank you !! Tomokazu Kiyohara http:/ /facebook.com/tomokazu.kiyohara http:/ /twitter.com/kiyohara