Class: ElectricMonk::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/electric_monk.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_path:, reporter: Reporter.instance) ⇒ CLI

Returns a new instance of CLI.



11
12
13
14
# File 'lib/electric_monk.rb', line 11

def initialize(config_path:, reporter: Reporter.instance)
  @reporter = reporter
  @config = Config.new(config_path)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/electric_monk.rb', line 8

def config
  @config
end

#reporterObject (readonly)

Returns the value of attribute reporter.



9
10
11
# File 'lib/electric_monk.rb', line 9

def reporter
  @reporter
end

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/electric_monk.rb', line 16

def run
  config.projects.each do |project|
    reporter.start(project.name)

    unless project.exists?
      reporter.update_progress("Cloning #{project.name}")
      project.clone_project
    end

    if project.valid?
      reporter.fail(project.failures)
    else
      reporter.succeed(project.name)
    end
  end
end