Class: Danger::RequestSources::RequestSource

Inherits:
Object
  • Object
show all
Defined in:
lib/danger/request_source/request_source.rb

Direct Known Subclasses

GitHub

Constant Summary collapse

DANGER_REPO_NAME =
"danger".freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_ci_source, _environment) ⇒ RequestSource

Returns a new instance of RequestSource.



17
18
19
# File 'lib/danger/request_source/request_source.rb', line 17

def initialize(_ci_source, _environment)
  raise "Subclass and overwrite initialize"
end

Instance Attribute Details

#ci_sourceObject

Returns the value of attribute ci_source.



6
7
8
# File 'lib/danger/request_source/request_source.rb', line 6

def ci_source
  @ci_source
end

#environmentObject

Returns the value of attribute environment.



6
7
8
# File 'lib/danger/request_source/request_source.rb', line 6

def environment
  @environment
end

#hostObject

Returns the value of attribute host.



6
7
8
# File 'lib/danger/request_source/request_source.rb', line 6

def host
  @host
end

#ignored_violationsObject

Returns the value of attribute ignored_violations.



6
7
8
# File 'lib/danger/request_source/request_source.rb', line 6

def ignored_violations
  @ignored_violations
end

#scmObject

Returns the value of attribute scm.



6
7
8
# File 'lib/danger/request_source/request_source.rb', line 6

def scm
  @scm
end

Class Method Details

.available_request_sourcesObject



13
14
15
# File 'lib/danger/request_source/request_source.rb', line 13

def self.available_request_sources
  @available_request_sources ||= Set.new
end

.inherited(child_class) ⇒ Object



8
9
10
11
# File 'lib/danger/request_source/request_source.rb', line 8

def self.inherited(child_class)
  available_request_sources.add child_class
  super
end

Instance Method Details

#danger_repo?(_organisation: nil, _repository: nil) ⇒ Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/danger/request_source/request_source.rb', line 61

def danger_repo?(_organisation: nil, _repository: nil)
  raise "Subclass and overwrite danger_repo?"
end

#fetch_danger_repo(_organisation: nil) ⇒ Object



57
58
59
# File 'lib/danger/request_source/request_source.rb', line 57

def fetch_danger_repo(_organisation: nil)
  raise "Subclass and overwrite fetch_danger_repo"
end

#fetch_detailsObject



45
46
47
# File 'lib/danger/request_source/request_source.rb', line 45

def fetch_details
  raise "Subclass and overwrite initialize"
end

#fetch_repository(_organisation: nil, _repository: nil) ⇒ Object



53
54
55
# File 'lib/danger/request_source/request_source.rb', line 53

def fetch_repository(_organisation: nil, _repository: nil)
  raise "Subclass and overwrite fetch_repository"
end

#file_url(_organisation: nil, _repository: nil, _branch: "master", _path: nil) ⇒ Object



65
66
67
# File 'lib/danger/request_source/request_source.rb', line 65

def file_url(_organisation: nil, _repository: nil, _branch: "master", _path: nil)
  raise "Subclass and overwrite file_url"
end

#organisationObject



49
50
51
# File 'lib/danger/request_source/request_source.rb', line 49

def organisation
  raise "Subclass and overwrite organisation"
end

#setup_danger_branchesObject



41
42
43
# File 'lib/danger/request_source/request_source.rb', line 41

def setup_danger_branches
  raise "Subclass and overwrite setup_danger_branches"
end

#update_pull_request!(_warnings: [], _errors: [], _messages: [], _markdowns: []) ⇒ Object



37
38
39
# File 'lib/danger/request_source/request_source.rb', line 37

def update_pull_request!(_warnings: [], _errors: [], _messages: [], _markdowns: [])
  raise "Subclass and overwrite update_pull_request!"
end

#validates?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/danger/request_source/request_source.rb', line 21

def validates?
  !!self.scm.origins.match(%r{#{Regexp.escape self.host}(:|/)(?<repo_slug>.+/.+?)(?:\.git)?$})
end