Class: Bl::Commands::File

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

Instance Method Summary collapse

Methods included from Printer

print_response, printable_issues

Methods included from Requestable

client, formatter, request

Constructor Details

#initializeFile

Returns a new instance of File.



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

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

Instance Method Details

#get(*ids) ⇒ Object



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

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



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

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