Class: Carson::Repository
- Inherits:
-
Object
- Object
- Carson::Repository
- Defined in:
- lib/carson/repository.rb
Instance Attribute Summary collapse
-
#authority ⇒ Object
readonly
Returns the value of attribute authority.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#branch(name) ⇒ Object
Returns a passive branch record for the given branch name.
-
#branches ⇒ Object
Lists local branches as passive branch records.
-
#initialize(path:, authority:, runtime:) ⇒ Repository
constructor
A new instance of Repository.
-
#name ⇒ Object
Human-readable repository name derived from the filesystem path.
-
#status ⇒ Object
Reports the repository’s delivery-centred state for status surfaces.
Constructor Details
#initialize(path:, authority:, runtime:) ⇒ Repository
Returns a new instance of Repository.
6 7 8 9 10 |
# File 'lib/carson/repository.rb', line 6 def initialize( path:, authority:, runtime: ) @path = File.( path ) @authority = @runtime = runtime end |
Instance Attribute Details
#authority ⇒ Object (readonly)
Returns the value of attribute authority.
4 5 6 |
# File 'lib/carson/repository.rb', line 4 def @authority end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/carson/repository.rb', line 4 def path @path end |
Instance Method Details
#branch(name) ⇒ Object
Returns a passive branch record for the given branch name.
18 19 20 |
# File 'lib/carson/repository.rb', line 18 def branch( name ) Branch.new( repository: self, name: name, runtime: runtime ) end |
#branches ⇒ Object
Lists local branches as passive branch records.
23 24 25 26 27 28 29 30 31 |
# File 'lib/carson/repository.rb', line 23 def branches runtime.git_capture!( "for-each-ref", "--format=%(refname:short)", "refs/heads" ) .lines .map( &:strip ) .reject( &:empty? ) .map { |branch_name| branch( branch_name ) } rescue StandardError [] end |
#name ⇒ Object
Human-readable repository name derived from the filesystem path.
13 14 15 |
# File 'lib/carson/repository.rb', line 13 def name File.basename( path ) end |
#status ⇒ Object
Reports the repository’s delivery-centred state for status surfaces.
34 35 36 37 38 39 40 41 |
# File 'lib/carson/repository.rb', line 34 def status { name: name, path: path, authority: , branches: runtime.ledger.active_deliveries( repo_path: path ).map { |delivery| delivery.branch } } end |