kelredd-useful 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -1
- data/lib/useful/ruby_extensions/object.rb +22 -0
- data/lib/useful/version.rb +1 -1
- metadata +38 -6
data/Rakefile
CHANGED
@@ -18,7 +18,10 @@ spec = Gem::Specification.new do |s|
|
|
18
18
|
s.homepage = 'http://code.kelredd.com'
|
19
19
|
s.files = %w(README.rdoc Rakefile) + Dir.glob("{lib}/**/*")
|
20
20
|
# s.executables = ['useful']
|
21
|
-
|
21
|
+
|
22
|
+
s.add_development_dependency("shoulda", [">= 2.10.2"])
|
23
|
+
s.add_development_dependency("leftright", [">= 0.0.6"])
|
24
|
+
|
22
25
|
s.add_dependency('json')
|
23
26
|
end
|
24
27
|
|
@@ -28,6 +28,28 @@ module Useful::RubyExtensions::Object
|
|
28
28
|
$stderr = STDERR
|
29
29
|
end
|
30
30
|
|
31
|
+
# Invokes a system command using `` and
|
32
|
+
# pass the status and result to a given block
|
33
|
+
def sudo(cmd, logger=nil, &block)
|
34
|
+
begin
|
35
|
+
require 'open4' unless defined?(::Open4)
|
36
|
+
rescue LoadError => err
|
37
|
+
puts "you need open4 to run the sudo helper: gem install open4"
|
38
|
+
else
|
39
|
+
logger.debug "`sudo #{cmd}` ..." if logger && logger.respond_to?(:debug)
|
40
|
+
result = {}
|
41
|
+
status = Open4.popen4("sudo #{cmd}") do |pid, stdin_io, stdout_io, stderr_io|
|
42
|
+
result[:out] = stdout_io.gets
|
43
|
+
result[:err] = stderr_io.gets
|
44
|
+
end
|
45
|
+
if block
|
46
|
+
block.call(status, status.success? ? result[:out] : result[:err])
|
47
|
+
else
|
48
|
+
status
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
31
53
|
module FromActivesupport
|
32
54
|
|
33
55
|
def blank?
|
data/lib/useful/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kelredd-useful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 5
|
10
|
+
version: 0.3.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kelly Redding
|
@@ -15,13 +15,45 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-28 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: shoulda
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 35
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 10
|
33
|
+
- 2
|
34
|
+
version: 2.10.2
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: leftright
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 19
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 0
|
49
|
+
- 6
|
50
|
+
version: 0.0.6
|
51
|
+
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: json
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
25
57
|
none: false
|
26
58
|
requirements:
|
27
59
|
- - ">="
|
@@ -31,7 +63,7 @@ dependencies:
|
|
31
63
|
- 0
|
32
64
|
version: "0"
|
33
65
|
type: :runtime
|
34
|
-
version_requirements: *
|
66
|
+
version_requirements: *id003
|
35
67
|
description:
|
36
68
|
email: kelly@kelredd.com
|
37
69
|
executables: []
|