Class: Bl::File

Inherits:
Command show all
Defined in:
lib/bl/file.rb

Instance Method Summary collapse

Methods included from Printer

print_response, printable_issues

Methods included from Formatting

colorize_priority, colorize_status, colorize_type

Methods included from Requestable

client, formatter, request

Constructor Details

#initializeFile

Returns a new instance of File.



3
4
5
6
7
# File 'lib/bl/file.rb', line 3

def initialize(*)
  @config = Bl::Config.instance
  @url = "projects/#{@config[:project_key]}"
  super
end

Instance Method Details

#get(*ids) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/bl/file.rb', line 16

def get(*ids)
  ids.each do |id|
    res = request(:get, "#{@url}/files/#{id}")
    f = ::File.new(res.body.filename, 'w')
    f.write(res.body.content)
    f.close
    puts "file #{id} #{res.body.filename} downloaded."
  end
end

#list(path = '') ⇒ Object



10
11
12
13
# File 'lib/bl/file.rb', line 10

def list(path = '')
  res = request(:get, "#{@url}/files/metadata/#{path}")
  print_response(res)
end