Sha256: f6a604f9c725d976c77fcf55c266701301a5745bbfd43900ef69c2d4c7daf39f

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 KB

Contents

require 'enumerator'
require 'fileutils'
require 'open-uri'
require 'openssl'
require 'ostruct'
require 'httpclient'
require 'tmpdir'
require 'facets/hash/rekey'
require 'facets/kernel/ask'

require 'proutils/icli/uploadutils'

module ICli

  COOKIEJAR  = File::join(Dir.tmpdir, 'icli', 'cookie.dat')

  def self.factory(name)
    ["proutils/icli/#{name.downcase}.rb"].each{ |x| require x }  # only did it this way to shut rdoc up!
    ICli::const_get(name.capitalize)
  end

  # Base class for all hosts.

  class AbstractHost

    # URI = http:// + domain name
    # TODO Deal with https, and possible other protocols too.
    attr :uri

    # Many sites will require logging in so these are available by
    # for use even if they arn't used.
    attr :username
    attr :password

    # Domain name of host. Must be overriden by adapter.
    def domain
      raise "Missing Domain"
    end

    # New RubyForge tasks.
    def initialize(options)
      options = options.dup.rekey

      @dryrun  = options[:dryrun]
      @trace   = options[:trace]

      #@domain   = options[:domain] || default_domain
      @uri   = URI.parse("http://" + domain)

      @username = options[:username]
      @password = options[:password]

      mkdir_p(File.dirname(COOKIEJAR))
      @cookie_jar = COOKIEJAR

      options
    end

    private

      def dryrun?
        @dryrun
      end

      def trace?
        @trace
      end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
proutils-0.3.0 lib/proutils/icli/abstract_host.rb
proutils-0.3.1 lib/proutils/icli/abstract_host.rb