Class: BunBun::CLI::StorageCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/bunbun/cli/storage_command.rb

Instance Attribute Summary collapse

Attributes inherited from Command

#options

Instance Method Summary collapse

Methods inherited from Command

argument_count, argument_names, option, #option_parser, options

Instance Attribute Details

#storage_access_keyObject

Returns the value of attribute storage_access_key.



6
7
8
# File 'lib/bunbun/cli/storage_command.rb', line 6

def storage_access_key
  @storage_access_key
end

#storage_hostObject

Returns the value of attribute storage_host.



5
6
7
# File 'lib/bunbun/cli/storage_command.rb', line 5

def storage_host
  @storage_host
end

#storage_zoneObject

Returns the value of attribute storage_zone.



4
5
6
# File 'lib/bunbun/cli/storage_command.rb', line 4

def storage_zone
  @storage_zone
end

Instance Method Details

#call(path) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bunbun/cli/storage_command.rb', line 8

def call(path)
  unless path =~ /\A\/([\w\-]+)\//
    raise BunBun::CLI::Error, 'path must start with a zone name'
  end

  self.storage_zone = $1

  self.storage_host = options[:host] || 'storage.bunnycdn.com'

  self.storage_access_key = get_access_key(storage_host, storage_zone)

  @client = BunBun::Client.new(host: storage_host, access_key: storage_access_key)
end