Sha256: 3c242431e80c1da12c105674d0d21a01726fbf35e135b7af9713cac6aed7581e

Contents?: true

Size: 704 Bytes

Versions: 26

Compression:

Stored size: 704 Bytes

Contents

module Danger
  class PrySetup
    def initialize(cork)
      @cork = cork
    end

    def setup_pry(dangerfile_path)
      return dangerfile_path if dangerfile_path.empty?
      validate_pry_available
      FileUtils.cp dangerfile_path, DANGERFILE_COPY
      File.open(DANGERFILE_COPY, "a") do |f|
        f.write("binding.pry; File.delete(\"#{DANGERFILE_COPY}\")")
      end
      DANGERFILE_COPY
    end

    private

    attr_reader :cork

    DANGERFILE_COPY = "_Dangerfile.tmp".freeze

    def validate_pry_available
      Kernel.require "pry"
    rescue LoadError
      cork.warn "Pry was not found, and is required for 'danger pr --pry'."
      cork.print_warnings
      abort
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
danger-4.3.4 lib/danger/commands/local_helpers/pry_setup.rb
danger-4.3.3 lib/danger/commands/local_helpers/pry_setup.rb
danger-4.3.2 lib/danger/commands/local_helpers/pry_setup.rb
danger-4.3.1 lib/danger/commands/local_helpers/pry_setup.rb
danger-4.3.0 lib/danger/commands/local_helpers/pry_setup.rb
danger-4.2.2 lib/danger/commands/local_helpers/pry_setup.rb