Class: Danger::Surf

Inherits:
CI
  • Object
show all
Defined in:
lib/danger/ci_source/surf.rb

Overview

### CI Setup

You want to add ‘bundle exec danger` to your `build.sh` file to run Danger at the end of your build.

### Token Setup

As this is self-hosted, you will need to add the ‘DANGER_GITHUB_API_TOKEN` to your build user’s ENV. The alternative is to pass in the token as a prefix to the command ‘DANGER_GITHUB_API_TOKEN=“123” bundle exec danger`.

Instance Attribute Summary

Attributes inherited from CI

#pull_request_id, #repo_slug, #repo_url

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CI

available_ci_sources, inherited, #supports?

Constructor Details

#initialize(env) ⇒ Surf

Returns a new instance of Surf.



28
29
30
31
32
33
34
35
# File 'lib/danger/ci_source/surf.rb', line 28

def initialize(env)
  self.repo_slug = env["SURF_NWO"]
  if env["SURF_PR_NUM"].to_i > 0
    self.pull_request_id = env["SURF_PR_NUM"]
  end

  self.repo_url = env["SURF_REPO"]
end

Class Method Details

.validates_as_ci?(env) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/danger/ci_source/surf.rb', line 16

def self.validates_as_ci?(env)
  return ["SURF_REPO", "SURF_NWO"].all? { |x| env[x] && !env[x].empty? }
end

.validates_as_pr?(env) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/danger/ci_source/surf.rb', line 20

def self.validates_as_pr?(env)
  validates_as_ci?(env)
end

Instance Method Details

#supported_request_sourcesObject



24
25
26
# File 'lib/danger/ci_source/surf.rb', line 24

def supported_request_sources
  @supported_request_sources ||= [Danger::RequestSources::GitHub]
end