Class: MSpec::Opal::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
Rake::DSL
Defined in:
opal/lib/mspec/opal/rake_task.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, &task_block) ⇒ RakeTask

Returns a new instance of RakeTask



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'opal/lib/mspec/opal/rake_task.rb', line 35

def initialize(name, &task_block)
  namespace name do
    desc 'Run MSpec::Opal code examples' unless ::Rake.application.last_comment
    task :default do
      puts 'Starting MSpec Runner...'
      runner = Runner.new(&task_block)
      runner.run
    end

    desc 'Build specs to build/specs.js and build/specs.min.js'
    task :build do
      path = './build/specs.js'
      min_path = './build/specs.min.js'
      Environment.new.build_specs(path)
      min = ::Opal::Builder::Util.uglify File.read(path)
      File.open(min_path, 'w') { |f| f << min_path }
    end
  end

  task name => "#{name}:default"
end