Class: Monoz::Services::RunService
- Inherits:
-
BaseService
- Object
- BaseService
- Monoz::Services::RunService
- Defined in:
- lib/monoz/services/run_service.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
- #call(projects, *command) ⇒ Object
- #errors? ⇒ Boolean
-
#initialize(thor_instance) ⇒ RunService
constructor
A new instance of RunService.
- #success? ⇒ Boolean
- #warnings? ⇒ Boolean
Methods inherited from BaseService
Constructor Details
#initialize(thor_instance) ⇒ RunService
Returns a new instance of RunService.
32 33 34 35 36 37 38 |
# File 'lib/monoz/services/run_service.rb', line 32 def initialize(thor_instance) super(thor_instance) @projects = nil @errors = [] @warnings = [] @command = [] end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
30 31 32 |
# File 'lib/monoz/services/run_service.rb', line 30 def errors @errors end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
30 31 32 |
# File 'lib/monoz/services/run_service.rb', line 30 def warnings @warnings end |
Instance Method Details
#call(projects, *command) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/monoz/services/run_service.rb', line 40 def call(projects, *command) raise ArgumentError, "Missing command" if command.empty? @command = command if projects.is_a?(Monoz::ProjectCollection) @projects = projects.all elsif projects.is_a?(Monoz::Project) @projects = [projects] else raise "Invalid projects" end say "Running ", nil, false say command.join(" "), [:bold], false say " in #{@projects.map { |p| p.name }.to_sentence}:" say "" run_commands say "" if errors? say "" say "Error: The command ", :red say "#{command.join(" ")} ", [:red, :bold] say "failed to run in one or more project directories", [:red] exit(1) end end |
#errors? ⇒ Boolean
73 74 75 |
# File 'lib/monoz/services/run_service.rb', line 73 def errors? @errors.any? end |
#success? ⇒ Boolean
69 70 71 |
# File 'lib/monoz/services/run_service.rb', line 69 def success? !errors? && !warnings? end |
#warnings? ⇒ Boolean
77 78 79 |
# File 'lib/monoz/services/run_service.rb', line 77 def warnings? @warnings.any? end |