Sha256: 1fd654fba5faa9273afa63efb5df5fba94f30014e337cce85cc439236df36f44

Contents?: true

Size: 1.64 KB

Versions: 5

Compression:

Stored size: 1.64 KB

Contents

# Author::    Nicolas Despres  <nicolas.despres@gmail.com>.
# Copyright:: Copyright (c) 2004, 2005 TTK team. All rights reserved.
# License::   LGPL
# $Id: Fetcher.rb 567 2005-04-13 08:00:06Z polrop $


require 'ttkd'


module TTK

  module Strategies

    class Fetcher < Composite
      include Concrete
      include ServiceManager

      def initialize ( *a, &b )
        @fetcher = nil
        @service = nil
        super
      end

      def uri=(other)
        if other.nil?
          @uri = other
        else
          @uri = URI.parse(other)
        end
      end

      def dir=(other)
        if other.nil?
          @dir = nil
        else
          @dir = Pathname.new(other)
          unless @dir.exist?
            raise(Errno::ENOENT, "`#@dir' - No such file or directory")
          end
        end
      end

      protected
      def prologue
        super
        @dir = @symtbl[:pwd] if @dir.nil?
        fetcher = Services::FetcherServer.new
        start_service(fetcher, @uri, @dir)
        create(@test) do |t|
          t.symtbl[:fetcher_uri] = fetcher.uri
        end
      end

      protected
      def epilogue
        stop_services
        super
      end

      attribute :uri,          'Fetcher server uri',
                               nil,
                               :invisible
      attribute :dir,          'Fetcher server repository directory',
                               nil,
                               :invisible
      attribute :test,         'The test which may use this fetcher',
                               :mandatory, :invisible, :dont_expand

    end # class Fetcher

  end # module Strategies

end # module TTK

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ttk-0.1.576 lib/ttk/strategies/Fetcher.rb
ttk-0.1.580 lib/ttk/strategies/Fetcher.rb
ttk-0.2.0 lib/ttk/strategies/Fetcher.rb
ttk-0.1.579 lib/ttk/strategies/Fetcher.rb
ttk-0.2.1 lib/ttk/strategies/Fetcher.rb