epitools 0.4.40 → 0.4.41

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.40
1
+ 0.4.41
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{epitools}
8
- s.version = "0.4.40"
8
+ s.version = "0.4.41"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["epitron"]
12
- s.date = %q{2011-06-07}
12
+ s.date = %q{2011-06-09}
13
13
  s.description = %q{Miscellaneous utility libraries to make my life easier.}
14
14
  s.email = %q{chris@ill-logic.com}
15
15
  s.extra_rdoc_files = [
@@ -124,3 +124,10 @@ def cmd(*args)
124
124
  system(*cmd_args)
125
125
  end
126
126
 
127
+ def autoinstall(*packages)
128
+ all_packages_installed = packages.all? { |pkg| Path.which pkg }
129
+
130
+ unless all_packages_installed
131
+ cmd(["sudo apt-get install ?", packages.join(' ')])
132
+ end
133
+ end
@@ -60,6 +60,21 @@ class Path
60
60
  #def self.verbose=(value); @@verbose = value; end
61
61
  #def self.verbose; @@verbose ||= false; end
62
62
 
63
+ if Sys.windows?
64
+ PATH_SEPARATOR = ";"
65
+ BINARY_EXTENSION = ".exe"
66
+ else
67
+ PATH_SEPARATOR = ":"
68
+ BINARY_EXTENSION = ""
69
+ end
70
+
71
+ def self.which(bin)
72
+ ENV["PATH"].split(PATH_SEPARATOR).find do |path|
73
+ result = (Path[path] / (bin + BINARY_EXTENSION))
74
+ return result if result.exists?
75
+ end
76
+ nil
77
+ end
63
78
 
64
79
  ## setters
65
80
 
@@ -249,4 +249,9 @@ describe Path do
249
249
  Path[__FILE__].mimetype == "application/x-ruby"
250
250
  end
251
251
 
252
+ it "whiches" do
253
+ Path.which("ruby").should_not be_nil
254
+ Path.which("asdfasdfhkajlsdhfkljashdf").should be_nil
255
+ end
256
+
252
257
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: epitools
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.40
5
+ version: 0.4.41
6
6
  platform: ruby
7
7
  authors:
8
8
  - epitron
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-07 00:00:00 -04:00
13
+ date: 2011-06-09 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency