Class: Carson::Delivery

Inherits:
Object
  • Object
show all
Defined in:
lib/carson/delivery.rb

Constant Summary collapse

ACTIVE_STATES =
%w[preparing gated queued integrating escalated].freeze
BLOCKED_STATES =
%w[gated escalated].freeze
READY_STATES =
%w[queued].freeze
TERMINAL_STATES =
%w[integrated failed superseded].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo_path:, branch:, head:, worktree_path:, status:, pull_request_number:, pull_request_url:, cause:, summary:, created_at:, updated_at:, integrated_at:, superseded_at:, revisions: [], repository: nil, pull_request_state: nil, pull_request_draft: nil, pull_request_merged_at: nil, merge_proof: nil) ⇒ Delivery

Returns a new instance of Delivery.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/carson/delivery.rb', line 14

def initialize(
	repo_path:, branch:, head:, worktree_path:, status:,
	pull_request_number:, pull_request_url:, cause:, summary:,
	created_at:, updated_at:, integrated_at:, superseded_at:,
	revisions: [], repository: nil,
	pull_request_state: nil, pull_request_draft: nil, pull_request_merged_at: nil,
	merge_proof: nil
)
	@repo_path = repo_path
	@repository = repository
	@branch = branch
	@head = head
	@worktree_path = worktree_path
	@status = status
	@pull_request_number = pull_request_number
	@pull_request_url = pull_request_url
	@revisions = revisions
	@cause = cause
	@summary = summary
	@created_at = created_at
	@updated_at = updated_at
	@integrated_at = integrated_at
	@superseded_at = superseded_at
	@pull_request_state = pull_request_state
	@pull_request_draft = pull_request_draft
	@pull_request_merged_at = pull_request_merged_at
	@merge_proof = merge_proof
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def branch
  @branch
end

#causeObject (readonly)

Returns the value of attribute cause.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def cause
  @cause
end

#created_atObject (readonly)

Returns the value of attribute created_at.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def created_at
  @created_at
end

#headObject (readonly)

Returns the value of attribute head.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def head
  @head
end

#integrated_atObject (readonly)

Returns the value of attribute integrated_at.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def integrated_at
  @integrated_at
end

#merge_proofObject (readonly)

Returns the value of attribute merge_proof.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def merge_proof
  @merge_proof
end

#pull_request_draftObject (readonly)

Returns the value of attribute pull_request_draft.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def pull_request_draft
  @pull_request_draft
end

#pull_request_merged_atObject (readonly)

Returns the value of attribute pull_request_merged_at.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def pull_request_merged_at
  @pull_request_merged_at
end

#pull_request_numberObject (readonly)

Returns the value of attribute pull_request_number.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def pull_request_number
  @pull_request_number
end

#pull_request_stateObject (readonly)

Returns the value of attribute pull_request_state.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def pull_request_state
  @pull_request_state
end

#pull_request_urlObject (readonly)

Returns the value of attribute pull_request_url.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def pull_request_url
  @pull_request_url
end

#repo_pathObject (readonly)

Returns the value of attribute repo_path.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def repo_path
  @repo_path
end

#repositoryObject (readonly)

Returns the value of attribute repository.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def repository
  @repository
end

#revisionsObject (readonly)

Returns the value of attribute revisions.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def revisions
  @revisions
end

#statusObject (readonly)

Returns the value of attribute status.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def status
  @status
end

#summaryObject (readonly)

Returns the value of attribute summary.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def summary
  @summary
end

#superseded_atObject (readonly)

Returns the value of attribute superseded_at.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def superseded_at
  @superseded_at
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def updated_at
  @updated_at
end

#worktree_pathObject (readonly)

Returns the value of attribute worktree_path.



9
10
11
# File 'lib/carson/delivery.rb', line 9

def worktree_path
  @worktree_path
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/carson/delivery.rb', line 51

def active?
	ACTIVE_STATES.include?( status )
end

#blocked?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/carson/delivery.rb', line 55

def blocked?
	BLOCKED_STATES.include?( status )
end

#failed?Boolean

Returns:

  • (Boolean)


67
68
69
# File 'lib/carson/delivery.rb', line 67

def failed?
	status == "failed"
end

#integrated?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/carson/delivery.rb', line 63

def integrated?
	status == "integrated"
end

#keyObject



43
44
45
# File 'lib/carson/delivery.rb', line 43

def key
	"#{repo_path}:#{branch}:#{head}"
end

#ready?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/carson/delivery.rb', line 59

def ready?
	READY_STATES.include?( status )
end

#revision_countObject



47
48
49
# File 'lib/carson/delivery.rb', line 47

def revision_count
	revisions.length
end

#superseded?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/carson/delivery.rb', line 71

def superseded?
	status == "superseded"
end

#terminal?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/carson/delivery.rb', line 75

def terminal?
	TERMINAL_STATES.include?( status )
end