Class: RedmineInstaller::Command
- Includes:
- Utils
- Defined in:
- lib/redmine-installer/command.rb
Defined Under Namespace
Classes: BaseFormatter, FullFormatter, SilentFormatter
Constant Summary
Constants included from Utils
Instance Attribute Summary collapse
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
-
#formatter ⇒ Object
readonly
Returns the value of attribute formatter.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(cmd, title: nil) ⇒ Command
constructor
A new instance of Command.
- #run ⇒ Object
- #run! ⇒ Object
Methods included from Utils
#class_name, #create_dir, #env_user, #error, #logger, #ok, #pastel, #print_title, #prompt, #run_command
Constructor Details
#initialize(cmd, title: nil) ⇒ Command
Returns a new instance of Command.
9 10 11 12 13 |
# File 'lib/redmine-installer/command.rb', line 9 def initialize(cmd, title: nil) @cmd = cmd @title = title || cmd @formatter = $SILENT_MODE ? SilentFormatter.new : FullFormatter.new end |
Instance Attribute Details
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
7 8 9 |
# File 'lib/redmine-installer/command.rb', line 7 def cmd @cmd end |
#formatter ⇒ Object (readonly)
Returns the value of attribute formatter.
7 8 9 |
# File 'lib/redmine-installer/command.rb', line 7 def formatter @formatter end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
7 8 9 |
# File 'lib/redmine-installer/command.rb', line 7 def title @title end |
Instance Method Details
#run ⇒ Object
15 16 17 18 19 |
# File 'lib/redmine-installer/command.rb', line 15 def run Bundler.with_unbundled_env do run! end end |
#run! ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/redmine-installer/command.rb', line 21 def run! success = false logger.std("--> #{cmd}") formatter.print_title(title) status = Open3.popen2e(cmd) do |input, output, wait_thr| input.close output.each_line do |line| logger.std(line) formatter.print_line(line) end wait_thr.value end success = status.success? rescue => e success = false ensure formatter.print_end(success) end |