Class: Veye::Project::InfoPretty

Inherits:
BasePretty show all
Defined in:
lib/veye/views/project/info_pretty.rb

Instance Method Summary collapse

Methods inherited from BasePretty

#after, #before

Instance Method Details

#format(results) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/veye/views/project/info_pretty.rb', line 7

def format(results)
  return if results.nil?
  results = [results] if results.is_a? Hash

  results.each_with_index do |result, index|
    #BUG: API returns raw mongoID value as id when fetching a list of projects
    if result['id'].is_a?(Hash)
      result['id'] = result['id'].values.first 
    end
    
    project_name = "#{result['name']}".color(:green).bright
    printf("%3d - %s\n", index + 1, project_name)
    printf("\t%-15s: %s\n", "Project id", "#{result['id']}".bright)
    printf("\t%-15s: %s\n", "Project type", result['project_type'])
    printf("\t%-15s: %s\n", "Public", result['public'])
    printf("\t%-15s: %s\n", "Period", result['period'])
    printf("\t%-15s: %s\n", "Source", result['source'])
    printf("\t%-15s: %s\n", "Dependencies", result['dep_number'].to_s.bright)
    printf("\t%-15s: %s\n", "Outdated", result['out_number'].to_s.color(:red))
    printf("\t%-15s: %s\n", "Created", result['created_at'])

  end
end