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) {|_self| ... } ⇒ RakeTask

Returns a new instance of RakeTask.

Yields:

  • (_self)

Yield Parameters:



41
42
43
44
45
46
47
48
49
50
# File 'lib/xlogin/rake_task.rb', line 41

def initialize(name)
  @name     = name
  @runner   = nil
  @timeout  = 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.



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

def fail_on_error
  @fail_on_error
end

#lockObject

Returns the value of attribute lock.



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

def lock
  @lock
end

#logObject

Returns the value of attribute log.



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

def log
  @log
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#silentObject

Returns the value of attribute silent.



38
39
40
# File 'lib/xlogin/rake_task.rb', line 38

def silent
  @silent
end

#timeoutObject

Returns the value of attribute timeout.



37
38
39
# File 'lib/xlogin/rake_task.rb', line 37

def timeout
  @timeout
end

Class Method Details

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



14
15
16
17
18
19
20
21
22
23
# File 'lib/xlogin/rake_task.rb', line 14

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

  task 'all' => hostnames unless opts[:all] == false
  hostnames.each do |hostname|
    desc "#{description} - #{hostname}" if opts[:desc] == true
    RakeTask.new(hostname, &block)
  end
end

.shutdown!Object



25
26
27
# File 'lib/xlogin/rake_task.rb', line 25

def shutdown!
  @stop = true
end

.stop?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/xlogin/rake_task.rb', line 29

def stop?
  !!@stop
end

Instance Method Details

#name_with_scopeObject



52
53
54
# File 'lib/xlogin/rake_task.rb', line 52

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

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



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

def run(&block)
  @runner = block
end