Class: Dependabot::Workspace::Base

Inherits:
Object
  • Object
show all
Extended by:
T::Generic, T::Helpers, T::Sig
Defined in:
lib/dependabot/workspace/base.rb

Direct Known Subclasses

Git

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Base

Returns a new instance of Base.



22
23
24
25
# File 'lib/dependabot/workspace/base.rb', line 22

def initialize(path)
  @path = path
  @change_attempts = T.let([], T::Array[Dependabot::Workspace::ChangeAttempt])
end

Instance Attribute Details

#change_attemptsObject (readonly)

Returns the value of attribute change_attempts.



16
17
18
# File 'lib/dependabot/workspace/base.rb', line 16

def change_attempts
  @change_attempts
end

#pathObject (readonly)

Returns the value of attribute path.



19
20
21
# File 'lib/dependabot/workspace/base.rb', line 19

def path
  @path
end

Instance Method Details

#change(memo = nil, &_blk) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/dependabot/workspace/base.rb', line 50

def change(memo = nil, &_blk)
  Dir.chdir(path) { yield(path) }
rescue StandardError => e
  capture_failed_change_attempt(memo, e)
  clean # clean up any failed changes
  raise e
end

#changed?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/dependabot/workspace/base.rb', line 28

def changed?
  changes.any?
end

#changesObject



33
34
35
# File 'lib/dependabot/workspace/base.rb', line 33

def changes
  change_attempts.select(&:success?)
end

#failed_change_attemptsObject



38
39
40
# File 'lib/dependabot/workspace/base.rb', line 38

def failed_change_attempts
  change_attempts.select(&:error?)
end

#reset!Object



67
# File 'lib/dependabot/workspace/base.rb', line 67

def reset!; end

#store_change(memo = nil) ⇒ Object



61
# File 'lib/dependabot/workspace/base.rb', line 61

def store_change(memo = nil); end

#to_patchObject



64
# File 'lib/dependabot/workspace/base.rb', line 64

def to_patch; end