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.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name) {|_self| ... } ⇒ RakeTask
constructor
A new instance of RakeTask.
- #name_with_scope ⇒ Object
- #run(&block) ⇒ Object (also: #start)
Constructor Details
#initialize(name) {|_self| ... } ⇒ RakeTask
Returns a new instance of RakeTask.
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..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.
39 40 41 |
# File 'lib/xlogin/rake_task.rb', line 39 def fail_on_error @fail_on_error end |
#lock ⇒ Object
Returns the value of attribute lock.
35 36 37 |
# File 'lib/xlogin/rake_task.rb', line 35 def lock @lock end |
#log ⇒ Object
Returns the value of attribute log.
36 37 38 |
# File 'lib/xlogin/rake_task.rb', line 36 def log @log end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
34 35 36 |
# File 'lib/xlogin/rake_task.rb', line 34 def name @name end |
#silent ⇒ Object
Returns the value of attribute silent.
38 39 40 |
# File 'lib/xlogin/rake_task.rb', line 38 def silent @silent end |
#timeout ⇒ Object
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
29 30 31 |
# File 'lib/xlogin/rake_task.rb', line 29 def stop? !!@stop end |
Instance Method Details
#name_with_scope ⇒ Object
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 |