Class: Greenhouse::Commands::Status

Inherits:
Object
  • Object
show all
Includes:
Command
Defined in:
lib/greenhouse/commands/status.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Command

included

Class Method Details

.usageObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/greenhouse/commands/status.rb', line 16

def self.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

#ecosystem_statusObject



52
53
54
55
56
57
58
59
60
61
# File 'lib/greenhouse/commands/status.rb', line 52

def ecosystem_status
  if Projects::send(project_type).empty?
    puts "No #{project_type} in your ecosystem."
    return
  end

  Projects::send(project_type).each do |project|
    Tasks::ProjectStatus.perform(project, with_git?, verbose?, remote?)
  end
end

#projectObject



32
33
34
# File 'lib/greenhouse/commands/status.rb', line 32

def project
  Projects::projects.select { |project| arguments.map(&:key).include?(project.name) }.first
end

#project_statusObject



63
64
65
# File 'lib/greenhouse/commands/status.rb', line 63

def project_status
  Tasks::ProjectStatus.perform(project, with_git?, verbose?, remote?)
end

#project_typeObject



48
49
50
# File 'lib/greenhouse/commands/status.rb', line 48

def project_type
  arguments.map(&:key).include?("--apps") ? 'applications' : (arguments.map(&:key).include?("--gems") ? 'gems' : 'projects')
end

#remote?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/greenhouse/commands/status.rb', line 40

def remote?
  arguments.map(&:key).include?("-r")
end

#runObject



28
29
30
# File 'lib/greenhouse/commands/status.rb', line 28

def run
  project.nil? ? ecosystem_status : project_status
end

#verbose?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/greenhouse/commands/status.rb', line 44

def verbose?
  arguments.map(&:key).include?("-v")
end

#with_git?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/greenhouse/commands/status.rb', line 36

def with_git?
  arguments.map(&:key).include?("-g")
end