Sha256: 25f9e8ec33ee82a8d9d0d252b6c8b687038c5c95a4259a1d290e53a25f328e10

Contents?: true

Size: 1.07 KB

Versions: 16

Compression:

Stored size: 1.07 KB

Contents

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

module Fog
  module Google
    class Storage

      class Directories < Fog::Collection

        model Fog::Google::Storage::Directory

        def all
         data = connection.get_service.body['Buckets']
         load(data)
        end

        def get(key, options = {})
          remap_attributes(options, {
            :delimiter  => 'delimiter',
            :marker     => 'marker',
            :max_keys   => 'max-keys',
            :prefix     => 'prefix'
          })
          data = connection.get_bucket(key, options).body
          directory = new(:key => data['Name'])
          options = {}
          for k, v in data
            if ['CommonPrefixes', 'Delimiter', 'IsTruncated', 'Marker', 'MaxKeys', 'Prefix'].include?(k)
              options[k] = v
            end
          end
          directory.files.merge_attributes(options)
          directory.files.load(data['Contents'])
          directory
        rescue Excon::Errors::NotFound
          nil
        end

      end

    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
fog-0.8.2 lib/fog/storage/models/google/directories.rb
fog-0.8.1 lib/fog/storage/models/google/directories.rb
fog-0.8.0 lib/fog/storage/models/google/directories.rb
fog-0.7.2 lib/fog/storage/models/google/directories.rb
fog-0.7.1 lib/fog/storage/models/google/directories.rb
fog-0.7.0 lib/fog/storage/models/google/directories.rb
fog-0.6.0 lib/fog/storage/models/google/directories.rb
fog-0.5.3 lib/fog/storage/models/google/directories.rb
fog-0.5.2 lib/fog/storage/models/google/directories.rb
fog-0.5.1 lib/fog/storage/models/google/directories.rb
fog-0.5.0 lib/fog/storage/models/google/directories.rb
phpfog-fog-0.4.1.3 lib/fog/storage/models/google/directories.rb
phpfog-fog-0.4.1.2 lib/fog/storage/models/google/directories.rb
phpfog-fog-0.4.1.1 lib/fog/storage/models/google/directories.rb
phpfog-fog-0.4.1 lib/fog/storage/models/google/directories.rb
fog-0.4.1 lib/fog/storage/models/google/directories.rb