Sha256: 2644fe4dafe705e100505d3cb6b7b1e1aad7e5246dbc7a4de8a6382d5569f8e3

Contents?: true

Size: 613 Bytes

Versions: 4

Compression:

Stored size: 613 Bytes

Contents

require 'construct/path_extensions'

module Construct
  module Helpers
    include PathExtensions
    extend self

    def within_construct(chdir=true)
      container = create_construct(chdir)
      container.maybe_change_dir(chdir) do
        yield(container)
      end
    ensure
      container.destroy!
    end

    def create_construct(chdir=true)
      path = (Pathname(Construct.tmpdir) + 
        "#{CONTAINER_PREFIX}-#{$PROCESS_ID}-#{rand(1_000_000_000)}")
      path.mkpath
      path.extend(PathExtensions)
      path.construct__chdir_default = chdir
      path
    end

  end
  
  extend Helpers
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
devver-construct-1.1.0 lib/construct/helpers.rb
test-construct-1.2.2 lib/construct/helpers.rb
test-construct-1.2.1 lib/construct/helpers.rb
test-construct-1.2.0 lib/construct/helpers.rb