Sha256: caee2ca0312c0169784cd8b359ae1cd1fb33385f96bc0152be23429d248f8b5d

Contents?: true

Size: 1.03 KB

Versions: 9

Compression:

Stored size: 1.03 KB

Contents

require "aptly_cli/version"
require "aptly_load"
require "httmultiparty"

module AptlyCli
  class AptlyFile
  
    include HTTMultiParty
    attr_accessor :file_uri, :package, :local_file_path

    # Load aptly-cli.conf and establish base_uri
    config = AptlyCli::AptlyLoad.new.configure_with("/etc/aptly-cli.conf")
    base_uri "http://#{config[:server]}:#{config[:port]}/api"

    def initialize(file_uri=nil, package=nil, local_file_path=nil)
    end

    def file_dir()
      uri = "/files"
      self.class.get uri
    end

    def file_get(file_uri)
      if file_uri == "/"
        uri = "/files"
      else
        uri = "/files/" + file_uri
      end
      
      self.class.get uri 
    end

    def file_delete(file_uri)
      uri = "/files" + file_uri
      self.class.delete uri 
    end

    def file_post(post_options = {})
      api_file_uri = "/files" + post_options[:file_uri].to_s
      self.class.post(api_file_uri, :query => { :package => post_options[:package], :file => File.new(post_options[:local_file])} )
    end
    
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
aptly_cli-0.1.9 lib/aptly_file.rb
aptly_cli-0.1.8 lib/aptly_file.rb
aptly_cli-0.1.7 lib/aptly_file.rb
aptly_cli-0.1.6 lib/aptly_file.rb
aptly_cli-0.1.5 lib/aptly_file.rb
aptly_cli-0.1.4 lib/aptly_file.rb
aptly_cli-0.1.3 lib/aptly_file.rb
aptly_cli-0.1.2 lib/aptly_file.rb
aptly_cli-0.1.1 lib/aptly_file.rb