Coffee Script で書いて、jsファイルにするまで

個人的にJavaScriptを書くのに、ネイティブだとアレやコレやで、非常に面倒。
なので、CoffeeScriptで書いて、コンパイルしてJSファイルにする。

参考1 https://github.com/amacou/guard-coffeedripper
参考2 http://blog.netswitch.jp/2011/05/10/development-with-guard-coffeescript
参考3 http://memo.sappari.org/coffeescript/coffee-command

Gemfile

gem 'guard'
gem 'guard-coffeescript'
gem 'rb-fsevent'          if /darwin/i =~ RUBY_PLATFORM
gem 'growl'               if /darwin/i =~ RUBY_PLATFORM
gem 'win32console'        if /win32/i =~ RUBY_PLATFORM
gem 'guard-coffeedripper' # if /win32/i =~ RUBY_PLATFORM
gem 'ruby_gntp'           if /win32/i =~ RUBY_PLATFORM
gem 'growl_notify'        if /darwin/i =~ RUBY_PLATFORM
$ bundle install

この後、coffeedripper.rbのcoffee-driper.yamlのパスをRevel用に変更(config → conf)

Guardfile

guard 'coffeedripper', :output => 'app/assets/coffee/', :input => 'app/assets/beans/' do
  watch(%r{^app/assets/beans/(.+)\.bean$}) {|m| "#{m[1]}.bean"}
end

# 残念ながら、ワシの環境(Mac)じゃ動かんかった
# guard 'coffeescript', :input => 'app/assets/coffee/', :output => 'public/js/'

んで、ターミナルから実行。

$ guard

もう一つターミナル開いて

$ cofee -o public/js/ -w app/assets/coffee/

注意:フォルダは予め用意する。coffeeコマンドは、cofeescriptをインストールする必要あり。
参考4 http://9ensan.com/blog/programming/javascript/mac-coffeescript-install/

Train

Assets Management Package for web app in Go. The main purpose of it is to introduce some good practices already existed in Ruby on Rails' Assets Pipeline.
https://github.com/shaoshing/train
時間が有る時に・・・