GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Description: Piston is a utility that eases vendor branch management. This repository is a complete reimplementation of Piston to provide different backends, depending on the repositories and working copies you pistonize from.
Homepage: http://piston.rubyforge.org/
Clone URL: git://github.com/francois/piston.git
francois (author)
Thu Sep 25 10:33:48 -0700 2008
commit  40209b1d6ae95fe67b918f660e8e93b09f8e1a82
tree    fe6a09f06911c3d6a5bb80e04c43f91c97eae41e
parent  2c71de586dd65552239a87711a0b46720de3804b
piston / lib / piston / repository.rb
100644 58 lines (43 sloc) 1.068 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
require "piston/revision"
 
module Piston
  class Repository
    class UnhandledUrl < RuntimeError; end
 
    class << self
      def logger
        @@logger ||= Log4r::Logger["handler"]
      end
 
      def guess(url)
        logger.info {"Guessing the repository type of #{url.inspect}"}
        
        handler = handlers.detect do |handler|
          logger.debug {"Asking #{handler}"}
          handler.understands_url?(url)
        end
        
        raise UnhandledUrl unless handler
        
        handler.new(url)
      end
 
      @@handlers = Array.new
      def add_handler(handler)
        @@handlers << handler
      end
 
      def handlers
        @@handlers
      end
    end
 
    attr_reader :url
 
    def initialize(url)
      @url = url
    end
 
    def logger
      self.class.logger
    end
 
    def at(revision)
      raise SubclassResponsibilityError, "Piston::Repository#at should be implemented by a subclass."
    end
 
    def to_s
      "Piston::Repository(#{@url})"
    end
    
    def ==(other)
      url == other.url
    end
  end
end