Class: Daimyo::Export

Inherits:
Object
  • Object
show all
Defined in:
lib/daimyo/export.rb

Instance Method Summary collapse

Constructor Details

#initializeExport

Returns a new instance of Export.



5
6
7
# File 'lib/daimyo/export.rb', line 5

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

Instance Method Details

#run(project_id, wiki_id = nil) ⇒ Object



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

def run(project_id, wiki_id = nil)
  ids = select_wiki_ids(project_id)
  pb = ProgressBar.create(:format => "%a %b\u{15E7}%i %p%% %t",
                          :progress_mark => ' ',
                          :remainder_mark => "\u{FF65}",
                          :starting_at => 10,
                          :length => 50)
  ids.each do |id|
    wiki = @wiki.export(id).body
    name = wiki.name
    content = wiki.content
    write_file(project_id, id, name, content)
    pb.increment
    sleep 0.1
  end
  pb.finish
end