Module: RedmineInstaller::Utils
- Included in:
- Command, Command::BaseFormatter, Configuration, Configuration::Base, Database, Database::Base, Easycheck, PackageConfig, Task, TaskModule
- Defined in:
- lib/redmine-installer/utils.rb
Constant Summary collapse
- PROGRESSBAR_FORMAT =
':elapsed [:bar] :percent'
Instance Method Summary collapse
- #class_name ⇒ Object
-
#create_dir(dir) ⇒ Object
Try create a dir When mkdir raise an error (permission problem) method ask user if wants exist or try again.
- #env_user ⇒ Object
- #error(message) ⇒ Object
- #logger ⇒ Object
- #ok(title) ⇒ Object
- #pastel ⇒ Object
- #print_title(title) ⇒ Object
- #prompt ⇒ Object
- #run_command(cmd, title = nil) ⇒ Object
Instance Method Details
#class_name ⇒ Object
6 7 8 |
# File 'lib/redmine-installer/utils.rb', line 6 def class_name self.class.name.split('::').last end |
#create_dir(dir) ⇒ Object
Try create a dir When mkdir raise an error (permission problem) method ask user if wants exist or try again
41 42 43 44 45 46 47 48 49 |
# File 'lib/redmine-installer/utils.rb', line 41 def create_dir(dir) FileUtils.mkdir_p(dir) rescue if prompt.yes?("Dir #{dir} doesn't exist and can't be created. Try again?", default: true) create_dir(dir) else error('Dir creating was aborted by user.') end end |
#env_user ⇒ Object
35 36 37 |
# File 'lib/redmine-installer/utils.rb', line 35 def env_user ENV['USER'] || ENV['USERNAME'] end |
#error(message) ⇒ Object
56 57 58 |
# File 'lib/redmine-installer/utils.rb', line 56 def error() raise RedmineInstaller::Error, end |
#logger ⇒ Object
10 11 12 |
# File 'lib/redmine-installer/utils.rb', line 10 def logger RedmineInstaller.logger end |
#ok(title) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/redmine-installer/utils.rb', line 26 def ok(title) print "#{title} ... " yield puts pastel.green('OK') rescue => e puts pastel.red('FAIL') raise end |
#pastel ⇒ Object
18 19 20 |
# File 'lib/redmine-installer/utils.rb', line 18 def pastel RedmineInstaller.pastel end |
#print_title(title) ⇒ Object
51 52 53 54 |
# File 'lib/redmine-installer/utils.rb', line 51 def print_title(title) puts puts pastel.white.on_black(title) end |
#prompt ⇒ Object
14 15 16 |
# File 'lib/redmine-installer/utils.rb', line 14 def prompt RedmineInstaller.prompt end |
#run_command(cmd, title = nil) ⇒ Object
22 23 24 |
# File 'lib/redmine-installer/utils.rb', line 22 def run_command(cmd, title=nil) RedmineInstaller::Command.new(cmd, title: title).run end |