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.
- data/lib/grill.rb +9 -9
- data/lib/grill/version.rb +1 -1
- data/spec/grill_spec.rb +24 -0
- metadata +1 -1
data/lib/grill.rb
CHANGED
@@ -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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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 = "#{
|
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 #{
|
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 "#{
|
26
|
+
system(%Q!bundle install --gemfile "#{gemfile}" --path "#{home}/gems"!)
|
27
27
|
puts "gems are installed."
|
28
28
|
end
|
29
29
|
require "bundler/setup"
|
data/lib/grill/version.rb
CHANGED
data/spec/grill_spec.rb
CHANGED
@@ -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
|