Sha256: 4a90fc321661a3104da5664a5ae343bd7809211bbf033534f4aaa6c3c46e69fe

Contents?: true

Size: 744 Bytes

Versions: 3

Compression:

Stored size: 744 Bytes

Contents

require 'tmpdir'
require 'tempfile'

module PkgForge
  ##
  # Add dir methods to Forge
  class Forge
    Contract Or[String, Symbol] => String
    def dep(package)
      tmpdir(package.to_sym)
    end

    Contract None => String
    def releasedir
      tmpdir(:release)
    end

    Contract Symbol => String
    def tmpdir(id)
      @tmpdirs ||= {}
      @tmpdirs[id] ||= Dir.mktmpdir(id.to_s)
    end

    Contract Symbol => String
    def tmpfile(id)
      @tmpfiles ||= {}
      @tmpfiles[id] ||= Tempfile.create(id.to_s).path
    end
  end

  module DSL
    ##
    # Add dir methods to Forge DSL
    class Forge
      Contract Or[String, Symbol] => String
      def dep(dep_name)
        @forge.dep(dep_name)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pkgforge-0.4.6 lib/pkgforge/components/dirs.rb
pkgforge-0.4.5 lib/pkgforge/components/dirs.rb
pkgforge-0.4.4 lib/pkgforge/components/dirs.rb