Sha256: 285814c6e8fb9ccd1692286f7add2835629660a80cbeeb1a65711f325574ab98

Contents?: true

Size: 955 Bytes

Versions: 8

Compression:

Stored size: 955 Bytes

Contents

# frozen_string_literal: true

require 'fog/core/collection'
require 'fog/aliyun/models/storage/directory'

module Fog
  module Storage
    class Aliyun
      class Directories < Fog::Collection
        model Fog::Storage::Aliyun::Directory

        def all
          containers = service.get_containers
          return nil if containers.nil?
          data = []
          i = 0
          containers.each do |entry|
            key = entry['Prefix'][0]
            key[-1] = ''
            data[i] = { key: key }
            i += 1
          end

          load(data)
        end

        def get(key, options = {})
          if !key.nil? && key != '' && key != '.'
            dir = key + '/'
            ret = service.head_object(dir, options)
            new(key: key) if ret.data[:status] == 200
          else
            new(key: '')
          end
        rescue Fog::Storage::Aliyun::NotFound
          nil
        end
      end
    end
  end
end

Version data entries

8 entries across 6 versions & 2 rubygems

Version Path
fog-aliyun-0.3.5 lib/fog/aliyun/models/storage/directories.rb
fog-aliyun-0.3.4 lib/fog/aliyun/models/storage/directories.rb
fog-aliyun-0.3.3 lib/fog/aliyun/models/storage/directories.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/storage/directories.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/storage/directories.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-aliyun-0.3.2/lib/fog/aliyun/models/storage/directories.rb
fog-aliyun-0.3.2 lib/fog/aliyun/models/storage/directories.rb
fog-aliyun-0.3.1 lib/fog/aliyun/models/storage/directories.rb