Class: Laser::Rake::LaserTask

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/laser/rake/task.rb

Defined Under Namespace

Classes: Settings

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(task_name) {|@settings| ... } ⇒ LaserTask

Returns a new instance of LaserTask

Yields:

  • (@settings)


20
21
22
23
24
25
26
27
# File 'lib/laser/rake/task.rb', line 20

def initialize(task_name)
  @settings = Settings.new
  yield @settings if block_given?
  @settings.using = [:all] if @settings.using.empty?
  task task_name do
    run
  end
end

Instance Attribute Details

#settingsObject

Returns the value of attribute settings



18
19
20
# File 'lib/laser/rake/task.rb', line 18

def settings
  @settings
end

Instance Method Details

#runObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/laser/rake/task.rb', line 29

def run
  require 'laser'
  files = []
  if @settings.libs.any?
    @settings.libs.each do |lib|
      Dir["#{lib}/**/*.rb"].each do |file|
        files << file
      end
    end
  end
  runner = Laser::Runner.new(self.settings.options.split(/\s/) + files)
  runner.using = self.settings.using
  runner.fix = self.settings.fix
  runner.run
end