Sha256: 272d675bf4492b2cfc2b4d0b8edf29cf1ea899d6da16a528d60ac544c172647a

Contents?: true

Size: 641 Bytes

Versions: 5

Compression:

Stored size: 641 Bytes

Contents

module Wright # rubocop:disable Documentation
  @dry_run = false

  # Checks if dry-run mode is currently active.
  #
  # @example
  #   puts 'Just a dry-run...' if Wright.dry_run?
  #
  # @return [Bool] true if dry-run mode is currently active and false
  #   otherwise
  def self.dry_run?
    @dry_run
  end

  # Runs a block in dry-run mode.
  #
  # @example
  #   Wright.dry_run do
  #     symlink '/tmp/fstab' do |s|
  #       s.to = '/etc/fstab'
  #     end
  #   end
  #
  # @return the block's return value
  def self.dry_run
    saved_dry_run = @dry_run
    @dry_run = true
    yield
  ensure
    @dry_run = saved_dry_run
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wright-0.3.2 lib/wright/dry_run.rb
wright-0.3.1 lib/wright/dry_run.rb
wright-0.3.0 lib/wright/dry_run.rb
wright-0.2.0 lib/wright/dry_run.rb
wright-0.1.2 lib/wright/dry_run.rb