Class: ArtRest::Folder

Inherits:
Resources show all
Includes:
DirEntry
Defined in:
lib/artrest/dir_entry.rb

Overview

Represents an Artifactory Folder Info resource.

Example

folder = ArtRest::Folder.new('http://localhost:8081/artifactory/api/storage/libs-release-local/commons-lang/commons-lang', { ... })

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DirEntry

create_node

Methods inherited from Resources

#each, resources_creator=

Methods inherited from Resource

#base_url, check_options, #content, #content!, #content=, create, inherited, #initialize, mime_type=, resource_attributes, #unparsed_content

Constructor Details

This class inherits a constructor from ArtRest::Resource

Class Method Details

.matches_path(path, options) ⇒ Object

:nodoc:



29
30
31
32
33
# File 'lib/artrest/dir_entry.rb', line 29

def matches_path(path, options) # :nodoc:
    return false unless path =~ %r|^/api/storage/[a-zA-Z0-9_.+-]+/.+$|
        content_hash = JSON.parse(RestClient::Resource.new([options[:base_url], path].join, options[:user], options[:password]).get)
    return content_hash['children']
end

Instance Method Details

#[](suburl, &new_block) ⇒ Object

:nodoc:



54
55
56
57
# File 'lib/artrest/dir_entry.rb', line 54

def [](suburl, &new_block) # :nodoc:
    subresource_content = JSON.parse(RestClient::Resource.new(url, options, &new_block)[suburl].get)
    ArtRest::DirEntry.create_node([url, suburl].join, options, subresource_content, &new_block) 
end

#traverse(&block) ⇒ Object



59
60
61
62
63
64
65
66
# File 'lib/artrest/dir_entry.rb', line 59

def traverse(&block)
    each do |child_entry|
        block.call(child_entry)
        if child_entry.is_a?(ArtRest::Folder) then
            child_entry.each &block
        end
    end
end