Class: Bl::File

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

Constant Summary

Constants inherited from Command

Command::ACTIVITY_TYPES, Command::CATEGORY_FIELDS, Command::FILE_FIELDS, Command::GIT_REPO_FIELDS, Command::ISSUES_PARAMS, Command::ISSUE_BASE_ATTRIBUTES, Command::ISSUE_FIELDS, Command::MILESTONE_FIELDS, Command::MILESTONE_PARAMS, Command::PROJECT_FIELDS, Command::PROJECT_PARAMS, Command::ROLES, Command::SPACE_DISK_USAGE, Command::SPACE_DISK_USAGE_DETAILS_FIELDS, Command::SPACE_FIELDS, Command::SPACE_NOTIFICATION_FIELDS, Command::TYPE_COLORS, Command::USER_FIELDS, Command::USER_PARAMS, Command::WATCHINGS_PARAMS, Command::WEBHOOK_FIELDS, Command::WEBHOOK_PARAMS, Command::WIKI_FIELDS

Instance Method Summary collapse

Methods included from Formatting

colorize_priority, colorize_status, colorize_type

Methods included from Requestable

client, formatter

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 = client.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 = client.get("#{@url}/files/metadata/#{path}")
  print_response(res)
end