rubbish 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.rdoc +72 -0
- data/lib/rubbish/bash.rb +17 -0
- data/lib/rubbish/fish.rb +17 -0
- data/lib/rubbish/rubbish.rb +27 -0
- data/lib/rubbish/version.rb +3 -0
- data/lib/rubbish.rb +9 -0
- metadata +58 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8565ae6a8568b45b54f587bba2544ae209f45fbc
|
4
|
+
data.tar.gz: 8d9b86fac434eb9ceb98e5297ed1e865bdbd2e95
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c13205744c577ea582537f5753fab0e929c52df2bb503e9148d2851c6c90bf901806954eefa75bba7c78f84fddf8a5b7f4a26bc91bf9e455045e25677a2f4f88
|
7
|
+
data.tar.gz: da1ab0a3ac56ac2d48349eb7b243eff6754bc282ff25413a31a63552c2d9595eee1641e8f88d16d2f8488110bd35b4e1cd483b1c05f08509fcc22dbd86e32ce4
|
data/README.rdoc
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
= rubbish
|
2
|
+
|
3
|
+
== DESCRIPTION:
|
4
|
+
|
5
|
+
A ruby-ish way to go to the shell.
|
6
|
+
|
7
|
+
Bash and Fish aware.
|
8
|
+
|
9
|
+
== SYNOPSIS:
|
10
|
+
|
11
|
+
require 'rubbish'
|
12
|
+
extend Rubbish::Fish
|
13
|
+
a = fish <<FISH
|
14
|
+
echo "But why???"
|
15
|
+
FISH
|
16
|
+
puts a+'Because!!!!'
|
17
|
+
|
18
|
+
== FEATURES:
|
19
|
+
|
20
|
+
Read by default:
|
21
|
+
|
22
|
+
* Rubbish.shell('bash','echo "OK"') #=> OK
|
23
|
+
* Rubbish.shell('bash'){|p| p.puts 'echo "OK"'} #=> OK
|
24
|
+
* Rubbish.bash('echo "OK"') #=> OK
|
25
|
+
* Rubbish.fish('true') #=> ''
|
26
|
+
* Rubbish.fish('false') #=> ''
|
27
|
+
|
28
|
+
Passing false will not read, but get the exit status instead:
|
29
|
+
|
30
|
+
* Rubbish.fish('true', false) #=> true
|
31
|
+
* Rubbish.fish('false', false) #=> false
|
32
|
+
|
33
|
+
An edge case:
|
34
|
+
|
35
|
+
require 'rubbish'
|
36
|
+
b = nil
|
37
|
+
a = Rubbish.bash do |p|
|
38
|
+
p.puts "echo Good"
|
39
|
+
p.puts "echo Day!"
|
40
|
+
b = p.gets
|
41
|
+
end
|
42
|
+
puts b # Good
|
43
|
+
puts a # Day!
|
44
|
+
|
45
|
+
== INSTALL:
|
46
|
+
|
47
|
+
$ sudo gem install rubbish
|
48
|
+
|
49
|
+
== LICENSE:
|
50
|
+
|
51
|
+
(The MIT License)
|
52
|
+
|
53
|
+
Copyright (c) 2015 carlosjhr64
|
54
|
+
|
55
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
56
|
+
a copy of this software and associated documentation files (the
|
57
|
+
'Software'), to deal in the Software without restriction, including
|
58
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
59
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
60
|
+
permit persons to whom the Software is furnished to do so, subject to
|
61
|
+
the following conditions:
|
62
|
+
|
63
|
+
The above copyright notice and this permission notice shall be
|
64
|
+
included in all copies or substantial portions of the Software.
|
65
|
+
|
66
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
67
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
68
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
69
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
70
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
71
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
72
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/rubbish/bash.rb
ADDED
data/lib/rubbish/fish.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Rubbish
|
2
|
+
|
3
|
+
def self.shell(sh, a=nil, b=nil, &block)
|
4
|
+
script = [a,b].detect{|c|c.kind_of?(String)}
|
5
|
+
read = [a,b].detect{|c|c==true||c==false}
|
6
|
+
read = true if read.nil?
|
7
|
+
IO.popen(sh, (read)? 'w+' : 'w') do |psh|
|
8
|
+
# No matter what, we know we're going to write first.
|
9
|
+
writing = true
|
10
|
+
if script.class == String
|
11
|
+
# We were given the script, so we write it and close.
|
12
|
+
psh.write script
|
13
|
+
psh.close_write
|
14
|
+
writing = false
|
15
|
+
end
|
16
|
+
if block
|
17
|
+
block.call(psh)
|
18
|
+
# close if we were writing
|
19
|
+
psh.close_write if writing
|
20
|
+
end
|
21
|
+
# Read if reading
|
22
|
+
read = psh.read if read
|
23
|
+
end
|
24
|
+
read || $?.to_i==0
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/lib/rubbish.rb
ADDED
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubbish
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- carlosjhr64
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |
|
14
|
+
A ruby-ish way to go to the shell.
|
15
|
+
|
16
|
+
Bash and Fish aware.
|
17
|
+
email: carlosjhr64@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files:
|
21
|
+
- README.rdoc
|
22
|
+
files:
|
23
|
+
- README.rdoc
|
24
|
+
- lib/rubbish.rb
|
25
|
+
- lib/rubbish/bash.rb
|
26
|
+
- lib/rubbish/fish.rb
|
27
|
+
- lib/rubbish/rubbish.rb
|
28
|
+
- lib/rubbish/version.rb
|
29
|
+
homepage: https://github.com/carlosjhr64/rubbish
|
30
|
+
licenses:
|
31
|
+
- MIT
|
32
|
+
metadata: {}
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options:
|
35
|
+
- "--main"
|
36
|
+
- README.rdoc
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
requirements:
|
50
|
+
- 'ruby: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]'
|
51
|
+
- 'bash: GNU bash, version 4.2.53(1)-release (x86_64-redhat-linux-gnu)'
|
52
|
+
- 'fish: 2.1.1'
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 2.4.5.1
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: A ruby-ish way to go to the shell.
|
58
|
+
test_files: []
|