Module: Hoe::Isolate

Defined in:
lib/hoe/isolate.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#isolate_dirObject

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



24
25
26
# File 'lib/hoe/isolate.rb', line 24

def isolate_dir
  @isolate_dir
end

#isolate_multirubyObject

Returns the value of attribute isolate_multiruby.



25
26
27
# File 'lib/hoe/isolate.rb', line 25

def isolate_multiruby
  @isolate_multiruby
end

Instance Method Details

#define_isolate_tasksObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/hoe/isolate.rb', line 47

def define_isolate_tasks
  sandbox = ::Isolate.sandbox

  # reset, now that they've had a chance to change it
  sandbox.options(:path       => isolate_dir,
                  :multiruby  => isolate_multiruby,
                  :system     => true)

  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

#initialize_isolateObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/hoe/isolate.rb', line 27

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"
  self.isolate_multiruby ||= false

  ::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