Class: Danger::RequestSources::RequestSource

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

Direct Known Subclasses

GitHub, GitLab

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

#fetch_detailsObject



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

def fetch_details
  raise "Subclass and overwrite initialize"
end

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



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

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

#organisationObject



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

def organisation
  raise "Subclass and overwrite organisation"
end

#setup_danger_branchesObject



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

def setup_danger_branches
  raise "Subclass and overwrite setup_danger_branches"
end

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



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

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

#validates_as_api_source?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/danger/request_source/request_source.rb', line 26

def validates_as_api_source?
  raise "Subclass and overwrite validates_as_api_source?"
end

#validates_as_ci?Boolean

What does this do?

Returns:

  • (Boolean)


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

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