Class: Spandx::Core::Git
- Inherits:
-
Object
- Object
- Spandx::Core::Git
- Defined in:
- lib/spandx/core/git.rb
Instance Attribute Summary collapse
-
#default_branch ⇒ Object
readonly
Returns the value of attribute default_branch.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url:, default_branch: 'main') ⇒ Git
constructor
A new instance of Git.
- #read(path) ⇒ Object
- #update! ⇒ Object
Constructor Details
#initialize(url:, default_branch: 'main') ⇒ Git
Returns a new instance of Git.
8 9 10 11 12 |
# File 'lib/spandx/core/git.rb', line 8 def initialize(url:, default_branch: 'main') @url = url @default_branch = default_branch @root = path_for(url) end |
Instance Attribute Details
#default_branch ⇒ Object (readonly)
Returns the value of attribute default_branch.
6 7 8 |
# File 'lib/spandx/core/git.rb', line 6 def default_branch @default_branch end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
6 7 8 |
# File 'lib/spandx/core/git.rb', line 6 def root @root end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
6 7 8 |
# File 'lib/spandx/core/git.rb', line 6 def url @url end |
Instance Method Details
#read(path) ⇒ Object
14 15 16 17 |
# File 'lib/spandx/core/git.rb', line 14 def read(path) full_path = root.join(path) full_path.read if full_path.exist? end |
#update! ⇒ Object
19 20 21 |
# File 'lib/spandx/core/git.rb', line 19 def update! dotgit? ? pull! : clone! end |