Class: CodeStats::Tasks

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/code_stats/tasks.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Tasks

Returns a new instance of Tasks.


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/code_stats/tasks.rb', line 10

def initialize(options = {})
  self.options = options
  root_dir = __DIR_REL__(caller.find{|c| c=~/Rakefile/})

  options[:directories] ||= 'lib'
  options[:directories] = Array(options[:directories])
  options[:directories].map! do |dir|
    File.expand_path(File.join(root_dir, dir))
  end
  self.building_block = building_block
  define
end

Instance Attribute Details

#building_blockObject

Returns the value of attribute building_block


8
9
10
# File 'lib/code_stats/tasks.rb', line 8

def building_block
  @building_block
end

#optionsObject

Returns the value of attribute options


8
9
10
# File 'lib/code_stats/tasks.rb', line 8

def options
  @options
end

Instance Method Details

#defineObject


27
28
29
30
31
32
# File 'lib/code_stats/tasks.rb', line 27

def define
  desc "Code stats - lines of code"
  task :code_stats do
    Printer.new(stats.run).print
  end
end

#statsObject


23
24
25
# File 'lib/code_stats/tasks.rb', line 23

def stats
  @stats ||= CodeStats.new(options)
end