Sha256: 6e302d7b8c62a7066a70fdb7efbd41145b0fa75e14e732452f693657123698da

Contents?: true

Size: 1.68 KB

Versions: 4

Compression:

Stored size: 1.68 KB

Contents

require "rubygems"
require "isolate"

class Hoe # :nodoc:

  # This module is a Hoe plugin. You can set its attributes in your
  # Rakefile's Hoe spec, like this:
  #
  #    Hoe.plugin :isolate
  #
  #    Hoe.spec "myproj" do
  #      self.isolate_dir = "tmp/isolated"
  #    end
  #
  # NOTE! The Isolate plugin is a little bit special: It messes with
  # the plugin ordering to make sure that it comes before everything
  # else.

  module Isolate

    # Where should Isolate, um, isolate? [default: <tt>"tmp/isolate"</tt>]
    # FIX: consider removing this and allowing +isolate_options+ instead.

    attr_accessor :isolate_dir

    def initialize_isolate
      # Tee hee! Move ourselves to the front to beat out :test.
      Hoe.plugins.unshift Hoe.plugins.delete(:isolate)

      self.isolate_dir ||= "tmp/isolate"

      ::Isolate.sandbox ||= ::Isolate::Sandbox.new

      ::Isolate.sandbox.entries.each do |entry|
        dep = [entry.name, *entry.requirement.as_list]

        if entry.environments.include? "development"
          extra_dev_deps << dep
        elsif entry.environments.empty?
          extra_deps << dep
        end
      end
    end

    def define_isolate_tasks
      sandbox = ::Isolate.sandbox

      # reset, now that they've had a chance to change it
      sandbox.options :path => isolate_dir, :system => false

      task :isolate do
        self.extra_deps.each do |name, version|
          sandbox.gem name, *Array(version)
        end

        self.extra_dev_deps.each do |name, version|
          sandbox.env "development" do
            sandbox.gem name, *Array(version)
          end
        end

        sandbox.activate
      end

      task :test => :isolate
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
isolate-3.4.0 lib/hoe/isolate.rb
isolate-3.3.1 lib/hoe/isolate.rb
isolate-3.2.4 lib/hoe/isolate.rb
isolate-3.2.2 lib/hoe/isolate.rb