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
commit  1c649fa32c3214e49c2263b94585e6d396cec0dd
tree    26b7679658bb6268b735723a9d09670592eb4d29
parent  ce4e3684bae50773af74563daa5bd61134afec32
piston / piston-core / lib / piston_core / repository.rb
100644 54 lines (41 sloc) 1.055 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
require "piston_core/revision"
 
module PistonCore
  class Repository
    class UnhandledUrl < RuntimeError; end
 
    class << self
      def logger
        @@logger
      end
 
      def logger=(logger)
        @@logger = logger
        PistonCore::Revision.logger = @@logger
      end
 
      def guess(url)
        logger.debug {"Guessing the repository type of #{url.inspect}"}
 
        handler = self.handlers.detect do |handler|
          handler.understands_url?(url)
        end
 
        raise UnhandledUrl, "No internal handlers found for #{url.inspect}. Do you want to help ?" if handler.nil?
        handler.new(url)
      end
 
      @@handlers = Array.new
      def handlers
        @@handlers
      end
    end
 
    attr_reader :url
 
    def initialize(url)
      @url = url
    end
 
    def logger
      self.class.logger
    end
 
    def at(revision)
      logger.debug {"Targeting #{self} at #{revision.inspect}"}
      PistonCore::Revision.new(self, revision)
    end
 
    def to_s
      "PistonCore::Repository(#{@url})"
    end
  end
end