Class: Spandx::Core::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/spandx/core/git.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_branchObject (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

#rootObject (readonly)

Returns the value of attribute root.



6
7
8
# File 'lib/spandx/core/git.rb', line 6

def root
  @root
end

#urlObject (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