rubbish 1.0.210921 → 1.1.221208
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -5
- data/lib/rubbish.rb +29 -23
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6a9c2f7befeba1ee6244441d88f39abb7f3f955108913885c4a785d55b325dd
|
4
|
+
data.tar.gz: b7f136c136d7ab3711186afdc2334276432347010ddf899e09a4c85c9790a43c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8d6e4ce9dab28c64dde5a56f91178ad0dba87f2f20087722cad5c988733416f26633c95277bf5b14f6574c78d8537cd27e6fbc1609115bb9a370a9a0557d6e9
|
7
|
+
data.tar.gz: 1c9ba07b399f41aaff250b10fb09b151ce2122a65211b4cb8cc74fa8d9eee540ba06232b1ea0a7b9baeedb00e028df6991ff3420d5533c50f181c14d294dab34
|
data/README.md
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
# rubbish
|
2
2
|
|
3
|
-
* [VERSION 1.
|
4
|
-
* [github](https://www.github.com/
|
3
|
+
* [VERSION 1.1.221208](https://github.com/carlosjhr64/rubbish/releases)
|
4
|
+
* [github](https://www.github.com/carlosjhr64/rubbish)
|
5
5
|
* [rubygems](https://rubygems.org/gems/rubbish)
|
6
6
|
|
7
|
+
## Deprecation notice:
|
8
|
+
|
9
|
+
This is my last `Rubbish` update.
|
10
|
+
I've merged this project with [Helpema](https://www.github.com/carlosjhr64/helpema).
|
11
|
+
|
7
12
|
## DESCRIPTION:
|
8
13
|
|
9
14
|
A ruby-ish way to go to the shell.
|
@@ -72,17 +77,17 @@ a #=> "Day!\n"
|
|
72
77
|
Passing options to the "shell":
|
73
78
|
```ruby
|
74
79
|
Rubbish::SHELL_VERSION[:date] = nil
|
75
|
-
Rubbish.date date:'2021-09-21' #=> "Tue Sep
|
80
|
+
Rubbish.date date:'2021-09-21', R:true #=> "Tue, 21 Sep 2021 00:00:00 -0700\n"
|
76
81
|
```
|
77
82
|
## INSTALL:
|
78
83
|
```console
|
79
84
|
$ gem install rubbish
|
80
85
|
```
|
81
|
-
|
86
|
+
## LICENSE:
|
82
87
|
|
83
88
|
(The MIT License)
|
84
89
|
|
85
|
-
Copyright (c)
|
90
|
+
Copyright (c) 2022 CarlosJHR64
|
86
91
|
|
87
92
|
Permission is hereby granted, free of charge, to any person obtaining
|
88
93
|
a copy of this software and associated documentation files (the
|
data/lib/rubbish.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Rubbish
|
2
|
-
VERSION = '1.
|
2
|
+
VERSION = '1.1.221208'
|
3
3
|
SHELL_VERSION = {bash: nil, fish: nil}
|
4
|
+
# This is a contraction of Shellwords.escape function
|
5
|
+
SHELLWORDS_ESCAPE = lambda{|w|w.gsub(/[^\w\-.,:+\/@\n]/,'\\\\\\&').gsub(/\n/,"'\n'")}
|
4
6
|
|
5
7
|
def self.shell(script=nil, shell:'bash', read:true, &block)
|
6
8
|
IO.popen(shell, (read)? 'w+' : 'w') do |pipe|
|
@@ -21,32 +23,36 @@ module Rubbish
|
|
21
23
|
read || $?.to_i==0
|
22
24
|
end
|
23
25
|
|
24
|
-
def self.method_missing(
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
35
|
-
# need to only check once
|
36
|
-
SHELL_VERSION[shell] = nil
|
37
|
-
else
|
38
|
-
raise "Could not get the #{shell} version"
|
26
|
+
def self.method_missing(cmd, *args, **kw, &block)
|
27
|
+
cmd=cmd[0..-2].to_sym unless read=(cmd[-1]!='?')
|
28
|
+
return super unless SHELL_VERSION.has_key?(cmd) and args.length.between?(0,1)
|
29
|
+
if minimum = SHELL_VERSION[cmd]
|
30
|
+
minimum = Gem::Version.new minimum
|
31
|
+
if version = `#{cmd} --version`.match(/\d+\.\d+\.\d+/)&.match(0)
|
32
|
+
version = Gem::Version.new version
|
33
|
+
bumped = minimum.bump
|
34
|
+
unless version >= minimum and version < bumped
|
35
|
+
raise "Need #{cmd} version ~> #{minimum}"
|
39
36
|
end
|
37
|
+
# need to only check once
|
38
|
+
SHELL_VERSION[cmd] = nil
|
39
|
+
else
|
40
|
+
raise "Could not get the #{cmd} version"
|
40
41
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
end
|
43
|
+
command = [cmd.to_s]
|
44
|
+
if kw.length > 0
|
45
|
+
kw.each do |k,w|
|
46
|
+
next if not w
|
47
|
+
if w==true
|
48
|
+
command << "#{k.length>1? '--':'-'}#{k}"
|
49
|
+
else
|
50
|
+
command << "--#{k}=#{w}"
|
51
|
+
end
|
45
52
|
end
|
46
|
-
script = args[0]
|
47
|
-
return Rubbish.shell(script, shell:shell, read:read, &block)
|
48
53
|
end
|
49
|
-
|
54
|
+
script = args[0]
|
55
|
+
return Rubbish.shell(script, shell:command, read:read, &block)
|
50
56
|
end
|
51
57
|
end
|
52
58
|
# Requires:
|
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: 1.
|
4
|
+
version: 1.1.221208
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CarlosJHR64
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
A ruby-ish way to go to the shell.
|
@@ -25,7 +25,7 @@ homepage: https://github.com/carlosjhr64/rubbish
|
|
25
25
|
licenses:
|
26
26
|
- MIT
|
27
27
|
metadata: {}
|
28
|
-
post_install_message:
|
28
|
+
post_install_message:
|
29
29
|
rdoc_options: []
|
30
30
|
require_paths:
|
31
31
|
- lib
|
@@ -40,11 +40,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
requirements:
|
43
|
-
- 'ruby: ruby 3.
|
44
|
-
- 'bash: GNU bash, version 5.1.
|
45
|
-
- 'fish: fish, version 3.
|
46
|
-
rubygems_version: 3.
|
47
|
-
signing_key:
|
43
|
+
- 'ruby: ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [aarch64-linux]'
|
44
|
+
- 'bash: GNU bash, version 5.1.4(1)-release (aarch64-unknown-linux-gnu)'
|
45
|
+
- 'fish: fish, version 3.5.1'
|
46
|
+
rubygems_version: 3.3.7
|
47
|
+
signing_key:
|
48
48
|
specification_version: 4
|
49
49
|
summary: A ruby-ish way to go to the shell.
|
50
50
|
test_files: []
|