rlps 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c583ee6da08cac5398774eb33ca3c78a59a0032
4
- data.tar.gz: ea80e6d8687aa5df423c8a691f283f5f55ebcf5c
3
+ metadata.gz: 68acee543c2e1660c3999619d2f54b6e1776d2c8
4
+ data.tar.gz: cdd09471ad493fb8747d3ca698fa994b513a16db
5
5
  SHA512:
6
- metadata.gz: d9f326a876581da1ec41faf51686c7385ca5b37dac0c28520139cc8ef653efc2bfe2804f719ac8357ba69ca4b9cd16836e70925cc7260aab6a3bd0c6e2a448b5
7
- data.tar.gz: 1824536a28103ae1115f5c209933e716d9b163cc76ec8c8086f7cc12220d6abe2c7b9d59b5fdc2a3718b7e8f926b4756473e0485a63a4f73c58948ee24331083
6
+ metadata.gz: e824c71acf91ba0e170af50faa33ceadad12789cf2c76774fbdeaab152af703d677cf8d8798bef542a247c471b020a42c794978c55bf45554e0ff6f2f6c0ef21
7
+ data.tar.gz: 1c29aabb5b6702561969373d0461d282ba252e39374f4e3dd6ed67d171b16d1869c2ffa5d1e279f8f69f0c39d08fdc195f18aa28c2071952dd74795bd85c3952
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ [![Gem Version](https://badge.fury.io/rb/rlps.svg)](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 https://nemoload.github.io/rlps/
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
- p my_processes[0] # => systemd: 1
30
- p my_processes[0].name # => systemd
31
- p my_processes[0].pid # => 1
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 ```:
@@ -12,7 +12,7 @@ module RLPS
12
12
 
13
13
  # Get the currently runing processes as a list.
14
14
  def processes
15
- @processes ||= parse_processes
15
+ @processes = parse_processes
16
16
  end
17
17
 
18
18
  # Return this process RLPS::Process object.
@@ -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] || this_process.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
@@ -1,4 +1,4 @@
1
1
  module RLPS
2
2
  # The current gem version.
3
- VERSION = '1.0.0'.freeze
3
+ VERSION = '1.0.2'.freeze
4
4
  end
@@ -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.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-01 00:00:00.000000000 Z
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
- A pure and intutive way to walk \
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: