rubbish 0.1.191210 → 0.2.200128

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/rubbish.rb +30 -9
  4. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 042fd02674603c2c64373010fa131f5de23e83d677f0439450eb7956275340f0
4
- data.tar.gz: 82f9d9dc31a0ab7dcb14c9483f79bbe46d1cd5b002d53e00a9e374032593d5b6
3
+ metadata.gz: e4cf8bce4e93ddb99df77ab62e0223ef4dd3c3d7a9397ecfee07a7630a13606d
4
+ data.tar.gz: 6d5be379098c58eacac6b74ec5eedb5909f30be9bee03aeaf094f6726c04023a
5
5
  SHA512:
6
- metadata.gz: 6429a13123d6f33359074e9a3ce23b2841b6f64a800a9f2463fd18f5fa7112bd869ceb1d7faa206875dd6f2c03a4d8c248829125de6c8f9fdf28b17a90573fc1
7
- data.tar.gz: 9e7d8a4138c34a0c96801cf4f2cf8b97052402d238f8fc2353f0ecf7f0380071a092c70423e2000c020fe946d8c0729563c95af8bff7760476508c5dc378a41d
6
+ metadata.gz: de35ecaa12da6ca6c3888afd9271344eaec0501baa669a58b0c90a4c1aa730868697b68c5b850cefe1ca62ab3780c255a87109868e63ff785228ec7733b33431
7
+ data.tar.gz: 197de12725801e594fc1a5718f15e41e6998c57bd198c30d9f9d9fb44586c9ad3d00e34d763e5d7786a2fcf80811a1d919f5e4e164851706c84eae44c9066d03
data/README.md CHANGED
@@ -67,7 +67,7 @@ An edge case:
67
67
 
68
68
  (The MIT License)
69
69
 
70
- Copyright (c) 2019 carlosjhr64
70
+ Copyright (c) 2020 carlosjhr64
71
71
 
72
72
  Permission is hereby granted, free of charge, to any person obtaining
73
73
  a copy of this software and associated documentation files (the
@@ -1,24 +1,44 @@
1
1
  module Rubbish
2
- VERSION = '0.1.191210'
2
+ VERSION = '0.2.200128'
3
3
  SHELL_VERSION = {bash: nil, fish: nil}
4
4
 
5
- def self.shell(sh, script=nil, read: true, &block)
6
- IO.popen(sh, (read)? 'w+' : 'w') do |psh|
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
- psh.write script
12
- psh.close_write
31
+ pipe.write script
32
+ pipe.close_write
13
33
  writing = false
14
34
  end
15
35
  if block
16
- block.call(psh)
36
+ block.call(pipe)
17
37
  # close if we were writing
18
- psh.close_write if writing
38
+ pipe.close_write if writing
19
39
  end
20
40
  # Read if reading
21
- read = psh.read if 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
- return Rubbish.shell(shell.to_s, *args, &block)
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.1.191210
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: 2019-12-10 00:00:00.000000000 Z
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.6.5p114 (2019-10-01 revision 67812) [x86_64-linux]'
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.0.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.