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 紹介。

Tomokazu Kiyohara

December 01, 2012
Tweet

More Decks by Tomokazu Kiyohara

Other Decks in Technology

Transcript

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

    path> file <target> => [<depend files>] do |t| <operation> done
  2. 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;
  3. 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;
  4. 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;
  5. 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;
  6. 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;
  7. 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;
  8. 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);
  9. 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);
  10. 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);
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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
  18. 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