Class: Daimyo::List

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/daimyo/list.rb

Instance Method Summary collapse

Methods included from Helper

#diff_print_header

Constructor Details

#initializeList

Returns a new instance of List.



7
8
9
# File 'lib/daimyo/list.rb', line 7

def initialize
  @wiki ||= Daimyo::Client.new
end

Instance Method Details

#output_table(wikis) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/daimyo/list.rb', line 26

def output_table(wikis)
  table = Terminal::Table.new(:headings => ['ID',
                                            'Name',
                                            'Created',
                                            'Updated'],
                              :rows => wikis)
  puts table
end

#run(project_id) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/daimyo/list.rb', line 11

def run(project_id)
  wikis = []
  res = @wiki.list(project_id)
  res.body.each do |w|
    wiki = []
    wiki << w.id
    wiki << w.name
    wiki << w.created
    wiki <<  w.updated
    wikis << wiki
  end

  output_table(wikis)
end