Sha256: a151e41e9c8549a27dd2b62f6e2ee619ad276f5b183eadebad7736645ae0a54b

Contents?: true

Size: 886 Bytes

Versions: 1

Compression:

Stored size: 886 Bytes

Contents

require "danger/ci_source/ci_source"
require "danger/request_sources/github"

module Danger
  class EnvironmentManager
    attr_accessor :ci_source, :request_source, :scm

    def initialize(env)
      CISource.constants.each do |symb|
        c = CISource.const_get(symb)
        next unless c.kind_of?(Class)
        next unless c.validates?(env)

        self.ci_source = c.new(env)
        if self.ci_source.repo_slug and self.ci_source.pull_request_id
          break
        else
          puts "Not a Pull Request - skipping `danger` run"
          self.ci_source = nil
          return nil
        end
      end

      raise "Could not find a CI source".red unless self.ci_source

      self.request_source = GitHub.new(self.ci_source) # for now
    end

    def fill_environment_vars
      request_source.fetch_details

      self.scm = GitRepo.new # For now
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-0.1.1 lib/danger/environment_manager.rb