Class: Xlogin::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Extended by:
Rake::DSL
Defined in:
lib/xlogin/rake_task.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, **opts) {|_self| ... } ⇒ RakeTask

Returns a new instance of RakeTask.

Yields:

  • (_self)

Yield Parameters:



46
47
48
49
50
51
52
53
54
55
# File 'lib/xlogin/rake_task.rb', line 46

def initialize(name, **opts)
  @name     = name
  @opts     = opts
  @runner   = nil
  @silent ||= Rake.application.options.silent
  @fail_on_error = true

  yield self if block_given?
  define
end

Instance Attribute Details

#fail_on_errorObject

Returns the value of attribute fail_on_error.



44
45
46
# File 'lib/xlogin/rake_task.rb', line 44

def fail_on_error
  @fail_on_error
end

#lockObject

Returns the value of attribute lock.



42
43
44
# File 'lib/xlogin/rake_task.rb', line 42

def lock
  @lock
end

#logObject

Returns the value of attribute log.



41
42
43
# File 'lib/xlogin/rake_task.rb', line 41

def log
  @log
end

#nameObject (readonly)

Returns the value of attribute name.



40
41
42
# File 'lib/xlogin/rake_task.rb', line 40

def name
  @name
end

#silentObject

Returns the value of attribute silent.



43
44
45
# File 'lib/xlogin/rake_task.rb', line 43

def silent
  @silent
end

Class Method Details

.all(*patterns, **opts, &block) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/xlogin/rake_task.rb', line 13

def all(*patterns, **opts, &block)
  description = Rake.application.last_description
  task all: Xlogin.list(*patterns).map{ |e| e[:name] }

  desc description
  generate(*patterns, **opts, &block)
end

.generate(*patterns, **opts, &block) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/xlogin/rake_task.rb', line 21

def generate(*patterns, **opts, &block)
  description = Rake.application.last_description

  hostnames = Xlogin.list(*patterns).map{ |e| e[:name] }
  hostnames.each do |hostname|
    desc "#{description} - #{hostname}" if description
    RakeTask.new(hostname, **opts, &block)
  end
end

.shutdown!Object



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

def shutdown!
  @stop = true
end

.stop?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/xlogin/rake_task.rb', line 35

def stop?
  !!@stop
end

Instance Method Details

#name_with_scope(separator = ':') ⇒ Object



57
58
59
# File 'lib/xlogin/rake_task.rb', line 57

def name_with_scope(separator = ':')
  [*Rake.application.current_scope.to_a.reverse, name].join(separator)
end

#run(&block) ⇒ Object Also known as: start



61
62
63
# File 'lib/xlogin/rake_task.rb', line 61

def run(&block)
  @runner = block
end