rubbish 0.1.191210 → 0.2.200128
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/rubbish.rb +30 -9
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4cf8bce4e93ddb99df77ab62e0223ef4dd3c3d7a9397ecfee07a7630a13606d
|
4
|
+
data.tar.gz: 6d5be379098c58eacac6b74ec5eedb5909f30be9bee03aeaf094f6726c04023a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de35ecaa12da6ca6c3888afd9271344eaec0501baa669a58b0c90a4c1aa730868697b68c5b850cefe1ca62ab3780c255a87109868e63ff785228ec7733b33431
|
7
|
+
data.tar.gz: 197de12725801e594fc1a5718f15e41e6998c57bd198c30d9f9d9fb44586c9ad3d00e34d763e5d7786a2fcf80811a1d919f5e4e164851706c84eae44c9066d03
|
data/README.md
CHANGED
data/lib/rubbish.rb
CHANGED
@@ -1,24 +1,44 @@
|
|
1
1
|
module Rubbish
|
2
|
-
VERSION = '0.
|
2
|
+
VERSION = '0.2.200128'
|
3
3
|
SHELL_VERSION = {bash: nil, fish: nil}
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
# Fine!
|
6
|
+
# Let there be Rubbish.args!!!
|
7
|
+
def self.args(*args)
|
8
|
+
script, read = nil, true
|
9
|
+
until args.empty?
|
10
|
+
arg = args.shift
|
11
|
+
case arg
|
12
|
+
when String
|
13
|
+
script = arg
|
14
|
+
when TrueClass, FalseClass
|
15
|
+
read = arg
|
16
|
+
when Hash
|
17
|
+
script = arg[:script] if arg.has_key? :script
|
18
|
+
read = arg[:read] if arg.has_key? :read
|
19
|
+
end
|
20
|
+
end
|
21
|
+
return script, read
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.shell(shell, *args, &block)
|
25
|
+
script, read = Rubbish.args(*args)
|
26
|
+
IO.popen(shell, (read)? 'w+' : 'w') do |pipe|
|
7
27
|
# No matter what, we know we're going to write first.
|
8
28
|
writing = true
|
9
29
|
if script
|
10
30
|
# We were given the script, so we write it and close.
|
11
|
-
|
12
|
-
|
31
|
+
pipe.write script
|
32
|
+
pipe.close_write
|
13
33
|
writing = false
|
14
34
|
end
|
15
35
|
if block
|
16
|
-
block.call(
|
36
|
+
block.call(pipe)
|
17
37
|
# close if we were writing
|
18
|
-
|
38
|
+
pipe.close_write if writing
|
19
39
|
end
|
20
40
|
# Read if reading
|
21
|
-
read =
|
41
|
+
read = pipe.read if read
|
22
42
|
end
|
23
43
|
read || $?.to_i==0
|
24
44
|
end
|
@@ -37,7 +57,8 @@ module Rubbish
|
|
37
57
|
raise "Could not get the #{shell} version"
|
38
58
|
end
|
39
59
|
end
|
40
|
-
|
60
|
+
script, read = Rubbish.args(*args)
|
61
|
+
return Rubbish.shell(shell.to_s, script, read, &block)
|
41
62
|
end
|
42
63
|
super
|
43
64
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubbish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.200128
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- carlosjhr64
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
A ruby-ish way to go to the shell.
|
@@ -40,10 +40,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
requirements:
|
43
|
-
- 'ruby: ruby 2.
|
43
|
+
- 'ruby: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]'
|
44
44
|
- 'bash: GNU bash, version 5.0.11(1)-release (x86_64-redhat-linux-gnu)'
|
45
45
|
- 'fish: fish, version 3.0.2'
|
46
|
-
rubygems_version: 3.
|
46
|
+
rubygems_version: 3.1.2
|
47
47
|
signing_key:
|
48
48
|
specification_version: 4
|
49
49
|
summary: A ruby-ish way to go to the shell.
|