Sha256: c64fe3738fea88bc060d902601ee2e57b42bc7287ea9242de648fcd461f4ada1

Contents?: true

Size: 742 Bytes

Versions: 46

Compression:

Stored size: 742 Bytes

Contents

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

    def setup_pry(dangerfile_path, command)
      return dangerfile_path if dangerfile_path.empty?

      validate_pry_available(command)
      FileUtils.cp dangerfile_path, DANGERFILE_COPY
      File.open(DANGERFILE_COPY, "a") do |f|
        f.write("\nbinding.pry; File.delete(\"#{DANGERFILE_COPY}\")")
      end
      DANGERFILE_COPY
    end

    private

    attr_reader :cork

    DANGERFILE_COPY = "_Dangerfile.tmp".freeze

    def validate_pry_available(command)
      Kernel.require "pry"
    rescue LoadError
      cork.warn "Pry was not found, and is required for 'danger #{command} --pry'."
      cork.print_warnings
      abort
    end
  end
end

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
danger-9.5.1 lib/danger/commands/local_helpers/pry_setup.rb
danger-9.5.0 lib/danger/commands/local_helpers/pry_setup.rb
danger-9.4.3 lib/danger/commands/local_helpers/pry_setup.rb
danger-9.4.2 lib/danger/commands/local_helpers/pry_setup.rb
danger-9.4.1 lib/danger/commands/local_helpers/pry_setup.rb
danger-9.4.0 lib/danger/commands/local_helpers/pry_setup.rb
danger-9.3.2 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.36 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.35 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.34 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.33 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.32 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.31 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.30 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.29 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.28 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.27 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.26 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.25 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.24 lib/danger/commands/local_helpers/pry_setup.rb