require 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/require/tasks.rb +34 -3
- data/require.rb +1 -1
- data/spec/require/gemspec_spec.rb +1 -1
- metadata +2 -2
data/lib/require/tasks.rb
CHANGED
@@ -31,6 +31,35 @@ class Require
|
|
31
31
|
$stdout.puts cmd
|
32
32
|
system cmd
|
33
33
|
end
|
34
|
+
|
35
|
+
def self.install_gem(name, version = nil)
|
36
|
+
unless has_gem?(name, version)
|
37
|
+
run "gem install #{name}#{" -v '#{version}'" if version}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.has_gem?(name, version=nil)
|
42
|
+
if !$GEM_LIST
|
43
|
+
gems = {}
|
44
|
+
`gem list --local`.each_line do |line|
|
45
|
+
gems[$1.to_sym] = $2.split(/, /) if line =~ /^(.*) \(([^\)]*)\)$/
|
46
|
+
end
|
47
|
+
$GEM_LIST = gems
|
48
|
+
end
|
49
|
+
if $GEM_LIST[name.to_sym]
|
50
|
+
if version
|
51
|
+
version = version.gsub("=",'')
|
52
|
+
if $GEM_LIST[name.to_sym].include?(version)
|
53
|
+
$stdout.puts "Gem: #{name}:#{version} already installed, skipping"
|
54
|
+
return true
|
55
|
+
end
|
56
|
+
else
|
57
|
+
$stdout.puts "Gem: #{name} already installed, skipping"
|
58
|
+
return true
|
59
|
+
end
|
60
|
+
end
|
61
|
+
false
|
62
|
+
end
|
34
63
|
end
|
35
64
|
end
|
36
65
|
|
@@ -68,11 +97,13 @@ task :gems do
|
|
68
97
|
end
|
69
98
|
|
70
99
|
namespace :gems do
|
71
|
-
desc "Install gem dependencies"
|
100
|
+
desc "Install gem dependencies, use DOCS=1|0, SUDO=1|0 to bypass prompts"
|
72
101
|
task :install do
|
73
|
-
|
102
|
+
doc_me = ENV['DOCS'].nil? ? :ask_docs : (ENV['DOCS'] == "1" ? :docs : :no_docs)
|
103
|
+
sudo_me = ENV['SUDO'].nil? ? :ask_sudo : (ENV['SUDO'] == "1" ? :sudo : :no_sudo)
|
104
|
+
Require::Tasks.set doc_me, sudo_me
|
74
105
|
Require.all(:gem).sort { |a,b| a.name.to_s <=> b.name.to_s }.each do |dsl|
|
75
|
-
Require::Tasks.
|
106
|
+
Require::Tasks.install_gem dsl.name, dsl.version
|
76
107
|
end
|
77
108
|
end
|
78
109
|
end
|
data/require.rb
CHANGED
@@ -25,7 +25,7 @@ class Require
|
|
25
25
|
|
26
26
|
s = Require.gemspec
|
27
27
|
s.authors.should == [ "Winton Welsh" ]
|
28
|
-
s.date.should == Time.utc(
|
28
|
+
s.date.should == Time.utc(Time.now.year, Time.now.mon, Time.now.mday, 8)
|
29
29
|
s.default_executable.should == "bin"
|
30
30
|
s.dependencies.should == [Gem::Dependency.new("rspec", Gem::Requirement.new(["= 1.3.0"]), :runtime)]
|
31
31
|
s.email.should == 'mail@wintoni.us'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: require
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Winton Welsh
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-03-03 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|