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-additional-logging-0.0.23 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.22 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.21 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.20 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.19 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.18 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.17 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.16 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.15 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.14 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.13 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.12 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.11 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.10 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.9 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.8 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.7 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.6 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.5 lib/danger/commands/local_helpers/pry_setup.rb
danger-additional-logging-0.0.4 lib/danger/commands/local_helpers/pry_setup.rb