Class: PostPushCli

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/post_push_cli.rb', line 5

def self.exit_on_failure?
  true
end

Instance Method Details

#statusObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/post_push_cli.rb', line 41

def status
  load_rails_env!

  unless options[:new]
    puts "Finished tasks:"
    puts completed_tasks.join "\n"
  end

  puts unless options[:new] || options[:done]

  unless options[:done]
    puts "Pending tasks:"
    puts runnable_tasks.join "\n"
  end

  puts
end

#workObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/post_push_cli.rb', line 10

def work
  load_rails_env!
  succeeded = []
  failed = []

  runnable_tasks.each do |task|
    puts "Running task #{task}..."
    puts
    job = RakeTaskRunner.exec(task)

    if job.status
      task_complete!(task)
      succeeded << task
      success_message "Successfully ran #{task}"
    else
      error_message "Error in: #{task}"
      failed << task
    end

    puts "-" * 56
    puts
  end

  success_message "#{succeeded.size} tasks succeeded"
  error_message "Errors occured in #{failed.size} tasks:\n#{failed.join("\n")}" if failed.any?
  raise "Some tasks failed" if failed.any?
end