Class: Greenhouse::Commands::Bundle

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Command

included

Class Method Details

.usageObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/greenhouse/commands/bundle.rb', line 10

def usage
  puts <<USAGE
usage: #{::Greenhouse::CLI.command_name} #{command_name} <#{valid_arguments.map(&:key).join(", ")}> [<project>]

Arguments:
#{valid_arguments.to_help}

Projects:
#{project_arguments.to_help}
USAGE
end

Instance Method Details

#bundle_all(cmd) ⇒ Object



23
24
25
26
27
# File 'lib/greenhouse/commands/bundle.rb', line 23

def bundle_all(cmd)
  Projects::projects.each do |project|
    Tasks::BundleProject.perform(project, cmd)
  end
end

#bundle_project(project, cmd) ⇒ Object



29
30
31
# File 'lib/greenhouse/commands/bundle.rb', line 29

def bundle_project(project, cmd)
  Tasks::BundleProject.perform(project, cmd)
end

#runObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/greenhouse/commands/bundle.rb', line 33

def run
  cmd = arguments.select { |arg| valid_arguments.map(&:key).include?(arg.key) }.first
  if cmd.nil?
    puts "Please specify a bundle command."
    usage
    return
  end

  project = Projects::projects.select { |project| arguments.map(&:key).include?(project.name) }.first
  project.nil? ? bundle_all(cmd) : bundle_project(project, cmd)
end