require 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- Require::Tasks.set :ask_docs, :ask_sudo
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.run "gem install #{dsl.name}#{" -v '#{dsl.version}'" if dsl.version}"
106
+ Require::Tasks.install_gem dsl.name, dsl.version
76
107
  end
77
108
  end
78
109
  end
data/require.rb CHANGED
@@ -11,7 +11,7 @@ Require do
11
11
  name 'require'
12
12
  homepage "http://github.com/winton/#{name}"
13
13
  summary "Manage your project's dependencies with a pretty DSL"
14
- version '0.2.2'
14
+ version '0.2.3'
15
15
  end
16
16
 
17
17
  rakefile do
@@ -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(Date.today.year, Date.today.mon, Date.today.mday, 8)
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.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-02-13 00:00:00 -08:00
12
+ date: 2010-03-03 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15