Class: Greenhouse::Commands::Purge
- Inherits:
-
Object
- Object
- Greenhouse::Commands::Purge
- Includes:
- Command
- Defined in:
- lib/greenhouse/commands/purge.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Command
Class Method Details
.usage ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/greenhouse/commands/purge.rb', line 11 def usage puts <<USAGE usage: #{::Greenhouse::CLI.command_name} #{command_name} [<project>] #{valid_arguments.to_s} Arguments: #{valid_arguments.to_help} Projects: #{project_arguments.to_help} USAGE end |
Instance Method Details
#clean? ⇒ Boolean
24 25 26 27 28 29 30 |
# File 'lib/greenhouse/commands/purge.rb', line 24 def clean? return false if Projects::projects_file.exists? return false if Projects::ignore_file.exists? return false if Projects::procfile.exists? return false if Projects::projects.any?(&:exists?) true end |
#force? ⇒ Boolean
32 33 34 |
# File 'lib/greenhouse/commands/purge.rb', line 32 def force? arguments.map(&:key).include?("-f") end |
#purge ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/greenhouse/commands/purge.rb', line 57 def purge Projects.projects.each do |project| Tasks::PurgeProject.perform(project, force?) end Tasks::RemoveGreenhouseFiles.perform(force?) if purge_all? end |
#purge_all? ⇒ Boolean
36 37 38 |
# File 'lib/greenhouse/commands/purge.rb', line 36 def purge_all? arguments.map(&:key).include?("-a") end |
#run ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/greenhouse/commands/purge.rb', line 40 def run app = Projects::projects.select { |project| arguments.map(&:key).include?(project.name) }.first if app.nil? if clean? puts "Nothing to do." return end purge else Tasks::PurgeProject.perform(app, force?) end puts "Done".yellow return end |