Class: Piston::Repository
- Inherits:
-
Object
- Object
- Piston::Repository
show all
- Defined in:
- lib/piston/repository.rb
Defined Under Namespace
Classes: UnhandledUrl
Constant Summary
collapse
- @@handlers =
Array.new
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Repository.
37
38
39
|
# File 'lib/piston/repository.rb', line 37
def initialize(url)
@url = url
end
|
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
35
36
37
|
# File 'lib/piston/repository.rb', line 35
def url
@url
end
|
Class Method Details
.add_handler(handler) ⇒ Object
26
27
28
|
# File 'lib/piston/repository.rb', line 26
def add_handler(handler)
@@handlers << handler
end
|
.guess(url) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/piston/repository.rb', line 12
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 ⇒ Object
30
31
32
|
# File 'lib/piston/repository.rb', line 30
def handlers
@@handlers
end
|
.logger ⇒ Object
8
9
10
|
# File 'lib/piston/repository.rb', line 8
def logger
@@logger ||= Log4r::Logger["handler"]
end
|
Instance Method Details
#==(other) ⇒ Object
57
58
59
|
# File 'lib/piston/repository.rb', line 57
def ==(other)
url == other.url
end
|
#at(revision) ⇒ Object
45
46
47
|
# File 'lib/piston/repository.rb', line 45
def at(revision)
raise SubclassResponsibilityError, "Piston::Repository#at should be implemented by a subclass."
end
|
#inspect ⇒ Object
53
54
55
|
# File 'lib/piston/repository.rb', line 53
def inspect
"Piston::Repository(#{@url})"
end
|
#logger ⇒ Object
41
42
43
|
# File 'lib/piston/repository.rb', line 41
def logger
self.class.logger
end
|
#to_s ⇒ Object
49
50
51
|
# File 'lib/piston/repository.rb', line 49
def to_s
@url
end
|