Class: BigBand::Integration::Rake::RoutesTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- BigBand::Integration::Rake::RoutesTask
- Defined in:
- lib/big_band/integration/rake.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #define ⇒ Object
-
#initialize(name = :routes) {|_self| ... } ⇒ RoutesTask
constructor
A new instance of RoutesTask.
Constructor Details
#initialize(name = :routes) {|_self| ... } ⇒ RoutesTask
Returns a new instance of RoutesTask.
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
#name ⇒ Object
Returns the value of attribute name.
42 43 44 |
# File 'lib/big_band/integration/rake.rb', line 42 def name @name end |
#source ⇒ Object
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
#define ⇒ Object
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 |