Class: Rake::CoffeeTask

Inherits:
TaskLib
  • Object
show all
Defined in:
lib/rake_coffee.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ CoffeeTask

Returns a new instance of CoffeeTask.

Yields:

  • (_self)

Yield Parameters:



13
14
15
16
17
18
19
20
# File 'lib/rake_coffee.rb', line 13

def initialize
  @test_cmd          = "mocha"
  @test_coverage_cmd = "istanbul cover _mocha"
  @lint_opts         = ""
  @compile_opts      = "--bare"
  yield self if block_given?
  define
end

Instance Attribute Details

#compile_optsObject

Returns the value of attribute compile_opts.



10
11
12
# File 'lib/rake_coffee.rb', line 10

def compile_opts
  @compile_opts
end

#lint_optsObject

Returns the value of attribute lint_opts.



10
11
12
# File 'lib/rake_coffee.rb', line 10

def lint_opts
  @lint_opts
end

#test_cmdObject

Returns the value of attribute test_cmd.



10
11
12
# File 'lib/rake_coffee.rb', line 10

def test_cmd
  @test_cmd
end

#test_coverage_cmdObject

Returns the value of attribute test_coverage_cmd.



10
11
12
# File 'lib/rake_coffee.rb', line 10

def test_coverage_cmd
  @test_coverage_cmd
end

Instance Method Details

#defineObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rake_coffee.rb', line 22

def define
  task :default => :test

  coffee_files = ::Rake::FileList["**/*.coffee"]
  js_files     = coffee_files.ext("js")

  desc "compile CoffeeScript files"
  task :compile => js_files

  rule ".js" => ".coffee" do |t|
    sh "coffeelint #{lint_opts} #{t.source}"
    sh "coffee --compile #{compile_opts} #{t.source}"
  end

  desc "run unit test"
  task :test => :compile do
    sh test_cmd
  end

  desc "push to a shared repository"
  task :push => :test do
    sh "git push"
  end

  desc "run unit test with coverage report"
  task :cov => :compile do
    sh test_coverage_cmd
  end
end