grill 0.2.0 → 0.2.1
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/README.md +19 -0
- data/lib/grill.rb +9 -3
- data/lib/grill/version.rb +1 -1
- data/spec/grill_spec.rb +34 -12
- data/spec/spec_helper.rb +8 -0
- data/spec/support/dummy2/dummy2.gemspec +15 -0
- data/spec/support/dummy2/lib/dummy2.rb +4 -0
- metadata +6 -2
data/README.md
CHANGED
@@ -27,6 +27,25 @@ If you want to uninstall gems installed by Grill, delete `$HOME/.grill` director
|
|
27
27
|
|
28
28
|
p defined?(Rack) # => "constant"
|
29
29
|
|
30
|
+
Or, more handy way to use as below (since v0.2.1):
|
31
|
+
|
32
|
+
$ cat $HOME/.grill/commontools
|
33
|
+
source :rubygems
|
34
|
+
gem "typhoeus"
|
35
|
+
gem "nokogiri"
|
36
|
+
gem "slop"
|
37
|
+
|
38
|
+
$ cat scraper.rb
|
39
|
+
require "grill"
|
40
|
+
|
41
|
+
Grill.implant :commontools
|
42
|
+
|
43
|
+
opts = Slop.parse do
|
44
|
+
# ...
|
45
|
+
end
|
46
|
+
|
47
|
+
# Compatibility of Gemfile
|
48
|
+
|
30
49
|
It is completely compatible (you installed version) Bundler's Gemfile so you can use [full spec of it](http://gembundler.com/gemfile.html) for version fixation, `:require`, `:path`, etc.
|
31
50
|
|
32
51
|
## When use this?
|
data/lib/grill.rb
CHANGED
@@ -12,12 +12,17 @@ module Grill
|
|
12
12
|
home
|
13
13
|
end
|
14
14
|
|
15
|
-
def implant(
|
15
|
+
def implant(gems_or_sym)
|
16
|
+
if gems_or_sym.class == Symbol
|
17
|
+
gems = File.read(File.join(home, gems_or_sym.to_s))
|
18
|
+
else
|
19
|
+
gems = gems_or_sym
|
20
|
+
end
|
21
|
+
|
16
22
|
fullpath = File.expand_path($0)
|
17
23
|
gemfile = "#{home}/#{Digest::MD5.hexdigest(fullpath)}-#{Digest::MD5.hexdigest(gems)}"
|
18
|
-
@gem = gems
|
19
24
|
tmp = File.open(gemfile, "w")
|
20
|
-
tmp.puts
|
25
|
+
tmp.puts gems
|
21
26
|
tmp.close
|
22
27
|
ENV["BUNDLE_GEMFILE"] = tmp.path
|
23
28
|
|
@@ -26,6 +31,7 @@ module Grill
|
|
26
31
|
system(%Q!bundle install --gemfile "#{gemfile}" --path "#{home}/gems"!)
|
27
32
|
puts "gems are installed."
|
28
33
|
end
|
34
|
+
|
29
35
|
require "bundler/setup"
|
30
36
|
Bundler.require
|
31
37
|
end
|
data/lib/grill/version.rb
CHANGED
data/spec/grill_spec.rb
CHANGED
@@ -15,19 +15,41 @@ describe Grill do
|
|
15
15
|
Grill.home.should == "#{ENV["GRILL_HOME"]}/.grill"
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
# cannot use `context` because test will be broken
|
19
|
+
# I don't know why but maybe that `context` require Bundler
|
20
|
+
it "#implant by String" do
|
21
|
+
cleanroom do
|
22
|
+
defined?(Bundler).should be_nil
|
23
|
+
defined?(Dummy).should be_nil
|
24
|
+
defined?(DummyGit).should be_nil
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
Grill.implant(<<-GEM)
|
27
|
+
gem "bundler"
|
28
|
+
gem "dummy", :path => "#{File.expand_path(".././support", __FILE__)}"
|
29
|
+
gem "dummy_git", :git => "file://#{File.expand_path(".././support/dummy_git", __FILE__)}"
|
30
|
+
GEM
|
31
|
+
defined?(Bundler).should_not be_nil
|
32
|
+
defined?(Dummy).should_not be_nil
|
33
|
+
defined?(DummyGit).should_not be_nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "#implant by Symbol" do
|
38
|
+
cleanroom do
|
39
|
+
name = :test
|
40
|
+
File.open("#{Grill.home}/#{name}", "w") do |f|
|
41
|
+
f.puts <<-GEM
|
42
|
+
gem "dummy", :path => "#{File.expand_path(".././support", __FILE__)}"
|
43
|
+
gem "dummy2", :path => "#{File.expand_path(".././support", __FILE__)}"
|
44
|
+
GEM
|
45
|
+
end
|
46
|
+
defined?(Dummy).should be_nil
|
47
|
+
defined?(Dummy2).should be_nil
|
48
|
+
|
49
|
+
Grill.implant name
|
50
|
+
defined?(Dummy).should_not be_nil
|
51
|
+
defined?(Dummy2).should_not be_nil
|
52
|
+
end
|
31
53
|
end
|
32
54
|
|
33
55
|
it "separete Gemfile different contants" do
|
data/spec/spec_helper.rb
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
require "pp"
|
4
4
|
require File.expand_path("../../lib/grill", __FILE__)
|
5
5
|
require "rubygems"
|
6
|
+
require "rspec-expectations"
|
7
|
+
require "rspec/matchers/built_in/be"
|
6
8
|
|
7
9
|
RSpec.configure do |config|
|
10
|
+
# Bundler is a singleton, so we must isolate each test processes
|
11
|
+
def cleanroom(&block)
|
12
|
+
pending "unsupported `fork`" unless
|
13
|
+
pid = fork { block.call }
|
14
|
+
Process.waitall
|
15
|
+
end
|
8
16
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = "dummy2"
|
5
|
+
gem.version = "0.0.1"
|
6
|
+
gem.authors = ["uu59"]
|
7
|
+
gem.email = ["k@uu59.org"]
|
8
|
+
gem.description = %q{Write a gem description}
|
9
|
+
gem.summary = %q{Write a gem summary}
|
10
|
+
gem.homepage = ""
|
11
|
+
|
12
|
+
gem.files = "#{File.expand_path(".././dummy2.rb", __FILE__)}"
|
13
|
+
#gem.add_dependency "bundler"
|
14
|
+
#gem.add_development_dependency "rspec"
|
15
|
+
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.2.
|
4
|
+
version: 0.2.1
|
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-09-
|
12
|
+
date: 2012-09-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -62,6 +62,8 @@ files:
|
|
62
62
|
- spec/spec_helper.rb
|
63
63
|
- spec/support/dummy/dummy.gemspec
|
64
64
|
- spec/support/dummy/lib/dummy.rb
|
65
|
+
- spec/support/dummy2/dummy2.gemspec
|
66
|
+
- spec/support/dummy2/lib/dummy2.rb
|
65
67
|
homepage: https://github.com/uu59/grill
|
66
68
|
licenses: []
|
67
69
|
post_install_message:
|
@@ -91,4 +93,6 @@ test_files:
|
|
91
93
|
- spec/spec_helper.rb
|
92
94
|
- spec/support/dummy/dummy.gemspec
|
93
95
|
- spec/support/dummy/lib/dummy.rb
|
96
|
+
- spec/support/dummy2/dummy2.gemspec
|
97
|
+
- spec/support/dummy2/lib/dummy2.rb
|
94
98
|
has_rdoc:
|