Class: Redmine::Installer::Task
- Inherits:
-
Object
- Object
- Redmine::Installer::Task
- Defined in:
- lib/redmine-installer/task.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
-
#options ⇒ Object
Returns the value of attribute options.
-
#redmine_root ⇒ Object
Returns the value of attribute redmine_root.
-
#settings ⇒ Object
Returns the value of attribute settings.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
-
#tmp_redmine_root ⇒ Object
Returns the value of attribute tmp_redmine_root.
Class Method Summary collapse
-
.inherited(child) ⇒ Object
Creating methods for recognition type of task.
- .step ⇒ Object
Instance Method Summary collapse
-
#check_package ⇒ Object
Package is required for install task and upgrade with source file.
-
#initialize(options = {}) ⇒ Task
constructor
A new instance of Task.
- #run ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Task
Returns a new instance of Task.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/redmine-installer/task.rb', line 15 def initialize(={}) self. = self.settings = {} self.env = [:env] # Initialize steps for task @steps = {} index = 1 self.class::STEPS.each do |step| @steps[index] = step.new(index, self) index += 1 end end |
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
11 12 13 |
# File 'lib/redmine-installer/task.rb', line 11 def env @env end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/redmine-installer/task.rb', line 9 def end |
#redmine_root ⇒ Object
Returns the value of attribute redmine_root.
7 8 9 |
# File 'lib/redmine-installer/task.rb', line 7 def redmine_root @redmine_root end |
#settings ⇒ Object
Returns the value of attribute settings.
10 11 12 |
# File 'lib/redmine-installer/task.rb', line 10 def settings @settings end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
13 14 15 |
# File 'lib/redmine-installer/task.rb', line 13 def steps @steps end |
#tmp_redmine_root ⇒ Object
Returns the value of attribute tmp_redmine_root.
8 9 10 |
# File 'lib/redmine-installer/task.rb', line 8 def tmp_redmine_root @tmp_redmine_root end |
Class Method Details
.inherited(child) ⇒ Object
Creating methods for recognition type of task
Examples:
class Install < Task
end
Install.new.install? #=> true
75 76 77 78 79 80 81 82 |
# File 'lib/redmine-installer/task.rb', line 75 def self.inherited(child) method_name = "#{child.class_name.downcase}?".to_sym define_method(method_name) { false } child.send(:define_method, method_name) { true } super end |
.step ⇒ Object
63 64 65 |
# File 'lib/redmine-installer/task.rb', line 63 def self.step Redmine::Installer::Step end |
Instance Method Details
#check_package ⇒ Object
Package is required for install task and upgrade with source file
57 58 59 60 61 |
# File 'lib/redmine-installer/task.rb', line 57 def check_package if package.nil? raise Redmine::Installer::Error, I18n.translate(:error_argument_package_is_missing) end end |
#run ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/redmine-installer/task.rb', line 29 def run @steps.each do |id, step| step.print_title step.print_header step.up step. step.ran = true puts # new line end @steps.each do |id, step| step.final_step end rescue Redmine::Installer::Error => e # Rescue from error comes from installer # run steps again for cleaning @steps.values.reverse.each do |step| next unless step.ran step.down end $stderr.puts(ANSI.red, e., ANSI.clear) $stderr.flush exit(1) end |