Module: Rakext::Tasks

Defined in:
lib/rakext.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/rakext.rb', line 7

def self.included(base)
  base.class_eval do
    extend self
    @prefix = ( p = name.gsub('::', ':')
                p.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
                p.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
                p.downcase!
                "#{p}:" )
  end
end

Instance Method Details

#desc(description) ⇒ Object



27
28
29
# File 'lib/rakext.rb', line 27

def desc(description)
  Rake.application.last_description = description
end

#method_added(meth) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/rakext.rb', line 18

def method_added(meth)
  return unless public_instance_methods.include?(meth) || public_instance_methods.include?(meth.to_sym)
  args = Rakext.get_args
  m    = method(meth.to_sym)
  Rake::Task.define_task("#{@prefix}#{meth}") do
    args.is_a?(Hash) ? m.call(args) : m.call(*args)
  end
end

#prefix(p = nil) ⇒ Object



31
32
33
# File 'lib/rakext.rb', line 31

def prefix(p=nil)
  p.nil? ? @prefix : @prefix = p
end