rlps 1.0.0 → 1.0.2
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.
- checksums.yaml +4 -4
- data/README.md +23 -5
- data/lib/rlps.rb +1 -1
- data/lib/rlps/process.rb +2 -2
- data/lib/rlps/version.rb +1 -1
- data/rlps.gemspec +2 -2
- metadata +4 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68acee543c2e1660c3999619d2f54b6e1776d2c8
|
4
|
+
data.tar.gz: cdd09471ad493fb8747d3ca698fa994b513a16db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e824c71acf91ba0e170af50faa33ceadad12789cf2c76774fbdeaab152af703d677cf8d8798bef542a247c471b020a42c794978c55bf45554e0ff6f2f6c0ef21
|
7
|
+
data.tar.gz: 1c29aabb5b6702561969373d0461d282ba252e39374f4e3dd6ed67d171b16d1869c2ffa5d1e279f8f69f0c39d08fdc195f18aa28c2071952dd74795bd85c3952
|
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[](https://badge.fury.io/rb/rlps)
|
1
2
|
# RLPS
|
2
3
|
|
3
4
|
**RLPS** is a very simple and pure Ruby gem which sole purpose is to get a **list** of the currently **running processes** in a **Linux** system by reading data from Linux /proc/ directory.
|
@@ -19,18 +20,35 @@ Or install it yourself as:
|
|
19
20
|
$ gem install rlps
|
20
21
|
|
21
22
|
## Documentation
|
22
|
-
See
|
23
|
+
See http://www.rubydoc.info/gems/rlps/
|
23
24
|
## Usage
|
24
25
|
``` ruby
|
26
|
+
# There are other helpful methods in addition to the ones I showed here.
|
27
|
+
# See http://www.rubydoc.info/gems/rlps/ for full documentation
|
28
|
+
|
25
29
|
require 'rlps'
|
26
30
|
|
27
31
|
my_processes = RLPS.processes
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
|
33
|
+
my_processes.first # => systemd: 1
|
34
|
+
my_processes.first.name # => systemd
|
35
|
+
my_processes.first.pid # => 1
|
36
|
+
my_process.class # => Array
|
37
|
+
my_process.length # => 150
|
38
|
+
|
39
|
+
# KDE Spectacle sometimes remains hidden after saving a screenshot
|
40
|
+
# When accumlated, it consumes too much from the RAM.
|
41
|
+
RLPS.processes.select{ |pr| pr.name=='spectacle' }.length # => 3
|
42
|
+
RLPS.processes.select{ |pr| pr.name=='spectacle' }.each{ |pr| pr.kill! }
|
43
|
+
RLPS.processes.select{ |pr| pr.name=='spectacle' }.length # => 0
|
44
|
+
|
45
|
+
|
46
|
+
# #is_running? method is useful in daemons
|
47
|
+
my_process = RLPS.this_process
|
48
|
+
my_process.is_running? # => true
|
49
|
+
john_cena_process = RLPS::Process.new pid:619, name: "cena"
|
50
|
+
john_cena_process.is_running? # => false
|
32
51
|
```
|
33
|
-
Returns a list of [RLPS::Process](http://www.github.com/nemoload) objects.
|
34
52
|
## CLI
|
35
53
|
**TL;DR: Don't.**
|
36
54
|
Although this gem wasn't made to be used as a CLI application, it can act as a very bad, inefficient version of Linux ``` $ ps -e ```:
|
data/lib/rlps.rb
CHANGED
data/lib/rlps/process.rb
CHANGED
@@ -13,8 +13,8 @@ module RLPS
|
|
13
13
|
# !args[k].nil?) || ((k == :pid) && !args[k].nil?) }
|
14
14
|
# raise if (other.count == 0) || (args.count != 2)
|
15
15
|
# TODO check if this process actually exists
|
16
|
-
@name = args[:name] || this_process.name
|
17
|
-
@pid = args[:pid]
|
16
|
+
@name = args[:name] || RLPS.this_process.name
|
17
|
+
@pid = args[:pid] || RLPS.this_process.pid
|
18
18
|
end
|
19
19
|
|
20
20
|
def to_s
|
data/lib/rlps/version.rb
CHANGED
data/rlps.gemspec
CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ['nemoload@aol.com']
|
11
11
|
|
12
12
|
spec.summary = 'Pure Ruby impelementation to walk through Linux\'s proc'
|
13
|
-
spec.description = 'A pure and intutive way to walk
|
14
|
-
through the current running processes
|
13
|
+
spec.description = 'A pure and intutive way to walk
|
14
|
+
through the current running processes
|
15
15
|
on Linux machine'
|
16
16
|
spec.homepage = 'https://nemoload.github.io'
|
17
17
|
spec.license = 'MIT'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rlps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ahmed Khaled
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,10 +66,8 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '5.0'
|
69
|
-
description:
|
70
|
-
|
71
|
-
through the current running processes \
|
72
|
-
on Linux machine
|
69
|
+
description: "A pure and intutive way to walk\n through the
|
70
|
+
current running processes \n on Linux machine"
|
73
71
|
email:
|
74
72
|
- nemoload@aol.com
|
75
73
|
executables:
|