Class: Carson::Repository
- Inherits:
-
Object
- Object
- Carson::Repository
- Defined in:
- lib/carson/repository.rb
Instance Attribute Summary collapse
-
#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:, 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:, runtime:) ⇒ Repository
Returns a new instance of Repository.
6 7 8 9 |
# File 'lib/carson/repository.rb', line 6 def initialize( path:, runtime: ) @path = File.( path ) @runtime = runtime end |
Instance Attribute Details
#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.
17 18 19 |
# File 'lib/carson/repository.rb', line 17 def branch( name ) Branch.new( repository: self, name: name, runtime: runtime ) end |
#branches ⇒ Object
Lists local branches as passive branch records.
22 23 24 25 26 27 28 29 30 |
# File 'lib/carson/repository.rb', line 22 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.
12 13 14 |
# File 'lib/carson/repository.rb', line 12 def name File.basename( path ) end |
#status ⇒ Object
Reports the repository’s delivery-centred state for status surfaces.
33 34 35 36 37 38 39 |
# File 'lib/carson/repository.rb', line 33 def status { name: name, path: path, branches: runtime.ledger.active_deliveries( repo_path: path ).map { |delivery| delivery.branch } } end |