grill 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,29 +1,29 @@
1
- require "tempfile"
2
1
  require "digest/md5"
3
2
  require "fileutils"
4
3
  require "grill/version"
5
4
 
6
5
  module Grill
7
6
  class << self
8
- attr_reader :gemfile
9
-
10
- HOME = "#{ENV["HOME"] || "."}/.grill"
11
- unless File.directory?(HOME)
12
- FileUtils.mkdir(HOME)
7
+ def home
8
+ home = "#{ENV["GRILL_HOME"] || ENV["HOME"] || "."}/.grill"
9
+ unless File.directory?(home)
10
+ FileUtils.mkdir_p(home)
11
+ end
12
+ home
13
13
  end
14
14
 
15
15
  def implant(gems)
16
16
  fullpath = File.expand_path($0)
17
- gemfile = "#{HOME}/#{Digest::MD5.hexdigest(fullpath)}"
17
+ gemfile = "#{home}/#{Digest::MD5.hexdigest(fullpath)}-#{Digest::MD5.hexdigest(gems)}"
18
18
  @gem = gems
19
19
  tmp = File.open(gemfile, "w")
20
20
  tmp.puts @gem
21
21
  tmp.close
22
22
  ENV["BUNDLE_GEMFILE"] = tmp.path
23
23
 
24
- unless system(%Q!bundle check --gemfile "#{gemfile}" --path #{HOME}/gems > #{File::NULL}!)
24
+ unless system(%Q!bundle check --gemfile "#{gemfile}" --path #{home}/gems > #{File::NULL}!)
25
25
  puts "missing gems found. will install them"
26
- system(%Q!bundle install --gemfile "#{gemfile}" --path "#{HOME}/gems"!)
26
+ system(%Q!bundle install --gemfile "#{gemfile}" --path "#{home}/gems"!)
27
27
  puts "gems are installed."
28
28
  end
29
29
  require "bundler/setup"
@@ -1,3 +1,3 @@
1
1
  module Grill
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -3,6 +3,18 @@
3
3
  require "spec_helper"
4
4
 
5
5
  describe Grill do
6
+ before(:all) do
7
+ ENV["GRILL_HOME"] = File.expand_path("../tmp", __FILE__)
8
+ end
9
+
10
+ after(:each) do
11
+ FileUtils.rm_rf(ENV["GRILL_HOME"])
12
+ end
13
+
14
+ it "#home" do
15
+ Grill.home.should == "#{ENV["GRILL_HOME"]}/.grill"
16
+ end
17
+
6
18
  it "#implant" do
7
19
  defined?(Bundler).should be_nil
8
20
  defined?(Dummy).should be_nil
@@ -17,4 +29,16 @@ describe Grill do
17
29
  defined?(Dummy).should_not be_nil
18
30
  defined?(DummyGit).should_not be_nil
19
31
  end
32
+
33
+ it "separete Gemfile different contants" do
34
+ Grill.implant(<<-GEM)
35
+ gem "bundler"
36
+ GEM
37
+ Dir.glob("#{Grill.home}/*-*").length.should == 2 # Gemfile and Gemfile.lock
38
+
39
+ Grill.implant(<<-GEM)
40
+ gem "dummy", :path => "#{File.expand_path(".././support", __FILE__)}"
41
+ GEM
42
+ Dir.glob("#{Grill.home}/*-*").length.should == 4
43
+ end
20
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: