Class: Cody::CLI::List
- Inherits:
-
Object
show all
- Extended by:
- Memoist
- Includes:
- AwsServices
- Defined in:
- lib/cody/cli/list.rb
Instance Method Summary
collapse
#cfn, #codebuild
#are_you_sure?, #find_stack, #inferred_project_name, #inferred_stack_name, #normalize_stack_name, #project_name_convention, #stack_exists?
Constructor Details
#initialize(options) ⇒ List
Returns a new instance of List.
8
9
10
|
# File 'lib/cody/cli/list.rb', line 8
def initialize(options)
@options = options
end
|
Instance Method Details
#list_projects ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/cody/cli/list.rb', line 46
def list_projects
projects = []
next_token = :start
while next_token
options = {sort_by: "NAME"}
if next_token && next_token != :start
options[:next_token] = next_token
end
resp = codebuild.list_projects(options)
next_token = resp.next_token
projects += resp.projects
end
if @options[:select]
regexp = Regexp.new(@options[:select])
projects.select! { |p| p =~ regexp }
end
projects
end
|
#projects ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'lib/cody/cli/list.rb', line 36
def projects
projects = list_projects.map { |p| Cody::List::Project.new(p) }
if @options[:sort_by]
projects.sort_by { |p| p.send(@options[:sort_by]) }
else
projects end
end
|
#run ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/cody/cli/list.rb', line 12
def run
if projects.size > 15
$stderr.puts "Number of projects: #{projects.size}"
$stderr.puts "Can take a while for a large number of projects..."
end
presenter = CliFormat::Presenter.new(@options)
presenter. = ["Name", "Status", "Time"]
projects.each do |project|
row = [project.name, project.build_status, project.end_time]
presenter.rows << row if show?(project.build_status)
end
presenter.show
end
|
#show?(build_status) ⇒ Boolean
27
28
29
30
31
32
33
34
|
# File 'lib/cody/cli/list.rb', line 27
def show?(build_status)
status = @options[:status].upcase if @options[:status]
if status
build_status == status
else
true
end
end
|