Class: BigBand::Integration::Rake::RoutesTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/big_band/integration/rake.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :routes) {|_self| ... } ⇒ RoutesTask

Returns a new instance of RoutesTask.

Yields:

  • (_self)

Yield Parameters:



44
45
46
47
48
49
# File 'lib/big_band/integration/rake.rb', line 44

def initialize(name = :routes)
  @name = name
  @source = BigBand::Integration::GLOBBER
  yield self if block_given?
  define
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



42
43
44
# File 'lib/big_band/integration/rake.rb', line 42

def name
  @name
end

#sourceObject

Returns the value of attribute source.



42
43
44
# File 'lib/big_band/integration/rake.rb', line 42

def source
  @source
end

Instance Method Details

#defineObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/big_band/integration/rake.rb', line 51

def define
  desc "Lists routes defined in #{source}"
  task(name) do
    list = []
    width = 0
    BigBand::Integration.each_route(source) do |verb, route|
      docstring = ""
      docstring << route.file if route.file?
      docstring << ":" << route.line if route.line
      if route.docstring
        docstring << " " unless docstring.empty?
        docstring << route.docstring
      end
      signature = "#{verb.downcase}(#{route.path.inspect})"
      list << [signature, docstring]
      width = [signature.size, width].max
    end
    list.each do |signature, docstring|
      line = "#{signature.ljust width}   # #{docstring}"
      line = line[0..99] + "" if line.size > 100
      puts line
    end
  end
end