Sha256: ad86efa78bd53e987a0e634339734a7340d1650c6d98b3c23b63c57b25cba2f7

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

require 'fog/core/collection'
require 'fog/artifactory/models/storage/file'

module Fog
  module Storage
    class Artifactory
      class Files < Fog::Collection
        model Fog::Storage::Artifactory::File

        attribute :directory

        def all(options = {})
          requires :directory
          options = options.reject { |_key, value| value.nil? || value.to_s.empty? }
          merge_attributes(options)
          load(service.client.get('/api/search/artifact', name: '.*', repos: directory.key)['results'].map do |artifact|
            path = URI.parse(artifact['uri']).path
            endpoint_path = URI.parse(service.client.endpoint).path
            path.slice!(endpoint_path)
            service.client.get(path)
          end)
        end

        def get(key, _options = {}, &_block)
          requires :directory
          new(service.client.get("/api/storage/#{directory.key}#{key}"))
        end

        def head(key, options = {})
          # TODO: implement
        end

        def new(attributes = {})
          requires :directory
          super({ directory: directory }.merge(attributes))
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fog-artifactory-0.3.0 lib/fog/artifactory/models/storage/files.rb
fog-artifactory-0.2.0 lib/fog/artifactory/models/storage/files.rb
fog-artifactory-0.1.0 lib/fog/artifactory/models/storage/files.rb