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 @options 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
85 86 87 88 89 90 91 92 |
# File 'lib/redmine-installer/task.rb', line 85 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 |
Instance Method Details
#check_package ⇒ Object
Package is required for install task and upgrade with source file
67 68 69 70 71 |
# File 'lib/redmine-installer/task.rb', line 67 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 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/redmine-installer/task.rb', line 29 def run @steps.each do |_, step| step.prepare end @steps.each do |_, step| step.print_title step.print_header step.up step. step.ran = true puts end @steps.each do |_, step| step.final end Dir.chdir(redmine_root) do Redmine::Installer::Plugin::RedminePlugin.all.each do |plugin| plugin.final(self) end 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 |