nub 0.0.95 → 0.0.96

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nub/process.rb +44 -0
  3. data/lib/nub.rb +1 -0
  4. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97804c515b6dcb72c61daa1c637ae4f796a6ed8fd8509ee3951eb55511a8e175
4
- data.tar.gz: e9898248566cf973a15e238873564116da42192825df20f43c3da06f7123d0b1
3
+ metadata.gz: a0f201649f1ad4a08b5350321b544e0188141e414cae039f9aa27ba3288ed4bf
4
+ data.tar.gz: 7bd2ef167e448539838bc5c1040ece7f652b3e3713d55450eeec74a9a2fcec26
5
5
  SHA512:
6
- metadata.gz: 6d89eae0dca6cd667974612ab2dce382cb3954ccb94cc1f1df77ac5b78f4801fc884345a26e37847fc7f265fe2dfaa619c35032f372af4bd9e10c69e610feed4
7
- data.tar.gz: 12c1d4f810840f13fb3ec3d28851233ea352a5830a63ad5451bc3203dd6a90f66714e86f38eb21ecd275abeadf6fd707e38d51de1e6c1f626ca41b2da9a4d1c4
6
+ metadata.gz: a50433d69104c80b7fb77ca5ab1ce2402e15aa2d9269b5ee4fbef4e5c070dc337e36d37ce4be1eb4085caaac1bb7a3c606aeac7bde96f68cdecebdcf8ae2be71
7
+ data.tar.gz: 3653bbcfb850ec55aa6da6773b56bf955ca03503dd7fbbef2b20ac79834f2d8c146eaa7d67a7d243faf7b686626de87cd42d42f92926901f77f65b81d9a64621
@@ -0,0 +1,44 @@
1
+ #MIT License
2
+ #Copyright (c) 2018 phR0ze
3
+ #
4
+ #Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ #of this software and associated documentation files (the "Software"), to deal
6
+ #in the Software without restriction, including without limitation the rights
7
+ #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ #copies of the Software, and to permit persons to whom the Software is
9
+ #furnished to do so, subject to the following conditions:
10
+ #
11
+ #The above copyright notice and this permission notice shall be included in all
12
+ #copies or substantial portions of the Software.
13
+ #
14
+ #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ #SOFTWARE.
21
+
22
+ # Monkey patch Process with some useful methods
23
+ module Process
24
+
25
+ # Get the pid of the process found with the given search term
26
+ # @param term [String] search term to use to find the pid
27
+ def self.pidof(term)
28
+ pid = nil
29
+
30
+ str = `ps -ef | grep "[#{term[0]}]#{term[1..-1]}"`
31
+ pid = str.split()[1].to_i if !str.empty?
32
+
33
+ return pid
34
+ end
35
+
36
+ # Kill the process found with the given search term
37
+ # @param term [String] search term to use to find the pid
38
+ def self.killall(term)
39
+ pid = pidof(term)
40
+ Process.kill("KILL", pid) if pid
41
+ end
42
+ end
43
+
44
+ # vim: ft=ruby:ts=2:sw=2:sts=2
data/lib/nub.rb CHANGED
@@ -31,6 +31,7 @@ module Nub
31
31
  require 'nub/module'
32
32
  require 'nub/net'
33
33
  require 'nub/pacman'
34
+ require 'nub/process'
34
35
  require 'nub/thread_comm'
35
36
  require 'nub/user'
36
37
  require 'nub/sys'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.95
4
+ version: 0.0.96
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Crummett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-22 00:00:00.000000000 Z
11
+ date: 2018-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -98,6 +98,7 @@ files:
98
98
  - lib/nub/module.rb
99
99
  - lib/nub/net.rb
100
100
  - lib/nub/pacman.rb
101
+ - lib/nub/process.rb
101
102
  - lib/nub/sys.rb
102
103
  - lib/nub/thread_comm.rb
103
104
  - lib/nub/user.rb