Sha256: 0dd8427724a3ade71b945236ccc657b61896f1901be594d14d6cbe6f608045c0

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

require "danger/plugin_support/plugin"

# Danger
module Danger
  # Handles interacting with local only plugin inside a Dangerfile.
  # It is support plugin for dry_run command and does not expose any methods.
  # But you can still use other plugins like git
  #
  # @example Check that added lines contains agreed form of words 
  #
  #       git.diff.each do |chunk|
  #         chunk.patch.lines.grep(/^\+/).each do |added_line|
  #           if added_line.gsub!(/(?<cancel>cancel)(?<rest>[^l[[:space:]][[:punct:]]]+)/i, '>>\k<cancel>-l-\k<rest><<')
  #             fail "Single 'L' for cancellation-alike words in '#{added_line}'" 
  #           end
  #         end
  #       end
  #
  # @see  danger/danger
  # @tags core, local_only
  #
  class DangerfileLocalOnlyPlugin < Plugin
    # So that this init can fail.
    def self.new(dangerfile)
      return nil if dangerfile.env.request_source.class != Danger::RequestSources::LocalOnly
      super
    end

    def initialize(dangerfile)
      super(dangerfile)

      @local_repo = dangerfile.env.request_source
    end

    # The instance name used in the Dangerfile
    # @return [String]
    #
    def self.instance_name
      "local_repo"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-9.1.0 lib/danger/danger_core/plugins/dangerfile_local_only_plugin.rb