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. Yet another CodeKit
    for Poor Rubyist
    2012.12.01 - Kanazawa.rb #4 LT

    View Slide

  2. CodeKit
    http:/
    /incident57
    .com/codekit/
    It’s like steroids for web developers.
    Auto compiler for coffee, less and more.

    View Slide

  3. YES !!

    View Slide

  4. View Slide

  5. View Slide

  6. View Slide

  7. View Slide

  8. Remember !!

    View Slide

  9. We are Developer

    View Slide

  10. We have FREE editor

    View Slide

  11. and
    We are Rubyist !!

    View Slide

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

    View Slide

  13. Rake & Guard

    View Slide

  14. Rake & Guard
    (Compile)

    View Slide

  15. Rake methods
    task : => []
    directory
    file => [] do |t|

    done

    View Slide

  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;

    View Slide

  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;

    View Slide

  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;

    View Slide

  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;

    View Slide

  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;

    View Slide

  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;

    View Slide

  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);

    View Slide

  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);

    View Slide

  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);

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  33. $ rake make_dist

    View Slide

  34. Rake & Guard
    (Automation)

    View Slide

  35. Guard
    $ gem install guard-shell

    View Slide

  36. Guard
    $ gem install guard-shell

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  41. Rake & Guard
    are
    Steroids for You !!

    View Slide

  42. And more !

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide