Class: Mattock::TaskLib

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
CascadingDefinition
Defined in:
lib/mattock/tasklib.rb

Constant Summary

Constant Summary

Constants included from Configurable

Configurable::RequiredField

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from CascadingDefinition

#confirm_configuration, #default_configuration, #define, #resolve_configuration

Methods included from Configurable

#check_required, #copy_settings_to, #nil_fields, #required_fields, #setting, #settings, #setup_defaults, #unset?

Methods included from Configurable::ClassMethods

#copy_settings, #default_values, #included, #missing_required_fields_on, #nested, #nil_fields, #required_fields, #set_defaults_on, #setting, #settings

Constructor Details

- (TaskLib) initialize(*toolkits)

A new instance of TaskLib



15
16
17
18
# File 'lib/mattock/tasklib.rb', line 15

def initialize(*toolkits)
  @tasks = []
  super
end

Instance Attribute Details

- (Object) namespace_name=(value) (writeonly)

Sets the attribute namespace_name

Parameters:

  • value

    the value to set the attribute namespace_name to.



8
9
10
# File 'lib/mattock/tasklib.rb', line 8

def namespace_name=(value)
  @namespace_name = value
end

- (Object) tasks (readonly)

Returns the value of attribute tasks



13
14
15
# File 'lib/mattock/tasklib.rb', line 13

def tasks
  @tasks
end

Class Method Details

+ (Object) default_namespace(name)



9
10
11
# File 'lib/mattock/tasklib.rb', line 9

def self.default_namespace(name)
  setting(:namespace_name, name)
end

Instance Method Details

- (Object) [](taskname)



52
53
54
# File 'lib/mattock/tasklib.rb', line 52

def [](taskname)
  in_namespace(taskname).first
end

- (Object) default_namespace



48
49
50
# File 'lib/mattock/tasklib.rb', line 48

def default_namespace
  nil
end

- (Object) in_namespace(*tasknames)



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mattock/tasklib.rb', line 26

def in_namespace(*tasknames)
  if tasknames.empty?
    if block_given?
      if @namespace_name.nil?
        yield
      else
        namespace @namespace_name do
          yield
        end
      end
    end
  else
    tasknames.map do |taskname|
      [@namespace_name, taskname].compact.join(":")
    end
  end
end

- (Object) root_task



44
45
46
# File 'lib/mattock/tasklib.rb', line 44

def root_task
  @namespace_name || :default
end

- (Object) task(*args)



20
21
22
23
24
# File 'lib/mattock/tasklib.rb', line 20

def task(*args)
  a_task = super
  @tasks << a_task
  return a_task
end