grill 0.3.0 → 0.4.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 +37 -4
- data/lib/grill/version.rb +1 -1
- data/spec/grill_spec.rb +7 -7
- metadata +2 -2
data/lib/grill.rb
CHANGED
@@ -4,6 +4,7 @@ require "grill/version"
|
|
4
4
|
|
5
5
|
module Grill
|
6
6
|
class << self
|
7
|
+
|
7
8
|
def home
|
8
9
|
home = "#{ENV["GRILL_HOME"] || ENV["HOME"] || "."}/.grill"
|
9
10
|
unless File.directory?(home)
|
@@ -12,6 +13,15 @@ module Grill
|
|
12
13
|
home
|
13
14
|
end
|
14
15
|
|
16
|
+
def gemfile_path(gems)
|
17
|
+
fullpath = File.expand_path($0)
|
18
|
+
filename = "#{Digest::MD5.hexdigest(fullpath)}-#{Digest::MD5.hexdigest(gems)}"
|
19
|
+
path = File.join(home, ruby, filename)
|
20
|
+
dir = File.dirname(path)
|
21
|
+
FileUtils.mkdir_p(dir) unless File.directory?(dir)
|
22
|
+
path
|
23
|
+
end
|
24
|
+
|
15
25
|
def implant(*args)
|
16
26
|
gems = ""
|
17
27
|
args.each do |arg|
|
@@ -23,21 +33,44 @@ module Grill
|
|
23
33
|
gems << "\n"
|
24
34
|
end
|
25
35
|
|
26
|
-
|
27
|
-
gemfile = "#{home}/#{Digest::MD5.hexdigest(fullpath)}-#{Digest::MD5.hexdigest(gems)}"
|
36
|
+
gemfile = gemfile_path(gems)
|
28
37
|
tmp = File.open(gemfile, "w")
|
29
38
|
tmp.puts gems
|
30
39
|
tmp.close
|
31
40
|
ENV["BUNDLE_GEMFILE"] = tmp.path
|
32
41
|
|
33
|
-
|
42
|
+
gemdir = File.join(home, ruby)
|
43
|
+
unless system(%Q!bundle check --gemfile "#{gemfile}" --path "#{gemdir}" > #{devnull}!)
|
34
44
|
puts "missing gems found. will install them"
|
35
|
-
system(%Q!bundle install --gemfile "#{gemfile}" --path "#{
|
45
|
+
system(%Q!bundle install --gemfile "#{gemfile}" --path "#{gemdir}"!)
|
36
46
|
puts "gems are installed."
|
37
47
|
end
|
38
48
|
|
39
49
|
require "bundler/setup"
|
40
50
|
Bundler.require
|
41
51
|
end
|
52
|
+
|
53
|
+
private
|
54
|
+
def ruby
|
55
|
+
"#{defined?(RUBY_ENGINE) ? RUBY_ENGINE : "ruby18"}-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def devnull
|
59
|
+
# from https://github.com/marcandre/backports/blob/v2.6.5/lib/backports/1.9.3/file.rb
|
60
|
+
return File::NULL if File.const_defined?(:NULL)
|
61
|
+
|
62
|
+
platform = RUBY_PLATFORM
|
63
|
+
platform = RbConfig::CONFIG['host_os'] if platform == 'java'
|
64
|
+
case platform
|
65
|
+
when /mswin|mingw/i
|
66
|
+
'NUL'
|
67
|
+
when /amiga/i
|
68
|
+
'NIL:'
|
69
|
+
when /openvms/i
|
70
|
+
'NL:'
|
71
|
+
else
|
72
|
+
'/dev/null'
|
73
|
+
end
|
74
|
+
end
|
42
75
|
end
|
43
76
|
end
|
data/lib/grill/version.rb
CHANGED
data/spec/grill_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe Grill do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "#home" do
|
15
|
-
Grill.home.should
|
15
|
+
Grill.home.should match %r!^#{ENV["GRILL_HOME"]}/.grill!
|
16
16
|
end
|
17
17
|
|
18
18
|
# cannot use `context` because test will be broken
|
@@ -69,14 +69,14 @@ describe Grill do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
it "separete Gemfile different contants" do
|
72
|
-
|
73
|
-
|
74
|
-
GEM
|
75
|
-
Dir.glob("#{Grill.home}/*-*").length.should == 2 # Gemfile and Gemfile.lock
|
72
|
+
gemfile1 = 'gem "bundler"'
|
73
|
+
file1 = Grill.gemfile_path(gemfile1)
|
76
74
|
|
77
|
-
|
75
|
+
gemfile2 = <<-GEM
|
78
76
|
gem "dummy", :path => "#{File.expand_path(".././support", __FILE__)}"
|
79
77
|
GEM
|
80
|
-
|
78
|
+
file2 = Grill.gemfile_path(gemfile2)
|
79
|
+
|
80
|
+
file1.should_not == file2
|
81
81
|
end
|
82
82
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|