Class: Xlogin::RakeTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Xlogin::RakeTask
- Extended by:
- Rake::DSL
- Defined in:
- lib/xlogin/rake_task.rb
Instance Attribute Summary collapse
-
#fail_on_error ⇒ Object
Returns the value of attribute fail_on_error.
-
#lock ⇒ Object
Returns the value of attribute lock.
-
#log ⇒ Object
Returns the value of attribute log.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#silent ⇒ Object
Returns the value of attribute silent.
Class Method Summary collapse
- .all(*patterns, **opts, &block) ⇒ Object
- .generate(*patterns, **opts, &block) ⇒ Object
- .shutdown! ⇒ Object
- .stop? ⇒ Boolean
Instance Method Summary collapse
-
#initialize(name, **opts) {|_self| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
- #name_with_scope(separator = ':') ⇒ Object
- #run(&block) ⇒ Object (also: #start)
Constructor Details
#initialize(name, **opts) {|_self| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
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..silent @fail_on_error = true yield self if block_given? define end |
Instance Attribute Details
#fail_on_error ⇒ Object
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 |
#lock ⇒ Object
Returns the value of attribute lock.
42 43 44 |
# File 'lib/xlogin/rake_task.rb', line 42 def lock @lock end |
#log ⇒ Object
Returns the value of attribute log.
41 42 43 |
# File 'lib/xlogin/rake_task.rb', line 41 def log @log end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
40 41 42 |
# File 'lib/xlogin/rake_task.rb', line 40 def name @name end |
#silent ⇒ Object
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
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 |