Class: Darcs::Repository
- Inherits:
-
Object
- Object
- Darcs::Repository
- Defined in:
- lib/darcs/repository.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
-
.find ⇒ Object
Finds the repository we are in.
-
.repository?(path) ⇒ Boolean
Determines whether the specified path is a repository.
Instance Method Summary collapse
-
#binary?(name) ⇒ Boolean
Determines whether this file a binary file according to the patterns found in _darcs/prefs/binaries.
-
#boring?(name) ⇒ Boolean
Determines whether this file a boring file according to the patterns found in _darcs/prefs/boring.
-
#initialize(path) ⇒ Repository
constructor
A new instance of Repository.
- #inventory_file ⇒ Object
- #patches ⇒ Object
- #write_patch(patch_info) ⇒ Object
Constructor Details
#initialize(path) ⇒ Repository
Returns a new instance of Repository.
10 11 12 13 |
# File 'lib/darcs/repository.rb', line 10 def initialize(path) @path = path @prefs_regexps = {} end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/darcs/repository.rb', line 8 def path @path end |
Class Method Details
.find ⇒ Object
Finds the repository we are in. Returns nil if we are not in a repository
17 18 19 20 21 22 23 24 |
# File 'lib/darcs/repository.rb', line 17 def self.find path = Dir.getwd while !repository?(path) return nil if File.dirname(path) == path path = File.dirname(path) end self.new(path) end |
.repository?(path) ⇒ Boolean
Determines whether the specified path is a repository
27 28 29 30 |
# File 'lib/darcs/repository.rb', line 27 def self.repository?(path) FileTest.directory?(File.join(path, '_darcs', 'patches')) && FileTest.exists?(File.join(path, '_darcs', 'inventory')) end |
Instance Method Details
#binary?(name) ⇒ Boolean
Determines whether this file a binary file according to the patterns found in _darcs/prefs/binaries.
49 50 51 |
# File 'lib/darcs/repository.rb', line 49 def binary?(name) prefs_regexp_file_matches(name, 'binaries') end |
#boring?(name) ⇒ Boolean
Determines whether this file a boring file according to the patterns found in _darcs/prefs/boring.
55 56 57 |
# File 'lib/darcs/repository.rb', line 55 def boring?(name) prefs_regexp_file_matches(name, 'boring') end |
#inventory_file ⇒ Object
43 44 45 |
# File 'lib/darcs/repository.rb', line 43 def inventory_file File.join(path, '_darcs', 'inventory') end |