rlps 0.1.0 → 1.0.0

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: d61a68df5edd1909af9aca5cf6c5c1c3219fe6a0
4
- data.tar.gz: 6cc743712c12c4948412678658147c29330f7927
3
+ metadata.gz: 6c583ee6da08cac5398774eb33ca3c78a59a0032
4
+ data.tar.gz: ea80e6d8687aa5df423c8a691f283f5f55ebcf5c
5
5
  SHA512:
6
- metadata.gz: c6e8b7b6341b42f9e43f15aabbd8c6ad193e3c4d7d6793e1b36ac726bb3f100d57d6bcf7de618c38751614838b4e2dbddfe93d45ed13d1a4ff356f79cce5a2ad
7
- data.tar.gz: 11efb6930e540d746694c32425bc85e056c976c23dc1636019708ecd5e1e1164fae0b1b945ec04ed90076ad6806996802f8747c727907ec06b598efbbd340ca3
6
+ metadata.gz: d9f326a876581da1ec41faf51686c7385ca5b37dac0c28520139cc8ef653efc2bfe2804f719ac8357ba69ca4b9cd16836e70925cc7260aab6a3bd0c6e2a448b5
7
+ data.tar.gz: 1824536a28103ae1115f5c209933e716d9b163cc76ec8c8086f7cc12220d6abe2c7b9d59b5fdc2a3718b7e8f926b4756473e0485a63a4f73c58948ee24331083
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # RLPS
2
2
 
3
- **RLPS** is a very simple and pure Ruby gem which sole prupose is to get a **list** of the currently **running processes** in a **Linux** system by reading data from Linux /proc/ directory.
3
+ **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.
4
4
  More information read The Linux Documentation Project [topic](http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/proc.html) on this subject.
5
5
  ## Installation
6
6
 
@@ -32,9 +32,9 @@ p my_processes[0].pid # => 1
32
32
  ```
33
33
  Returns a list of [RLPS::Process](http://www.github.com/nemoload) objects.
34
34
  ## CLI
35
- **TL;DR: Don't.**
36
- Although this gem wasn't made to be used as a CLI application, it can act as a very bad, ineffecient version of Linux ``` $ ps -e ```:
37
-
35
+ **TL;DR: Don't.**
36
+ 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 ```:
37
+
38
38
  $ rlps
39
39
 
40
40
  ## Contributing
@@ -45,4 +45,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/nemolo
45
45
  ## License
46
46
 
47
47
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
48
-
data/lib/rlps.rb CHANGED
@@ -15,6 +15,12 @@ module RLPS
15
15
  @processes ||= parse_processes
16
16
  end
17
17
 
18
+ # Return this process RLPS::Process object.
19
+ def this_process
20
+ process = RLPS.processes.select { |p| p.pid == ::Process.pid }
21
+ RLPS::Process.new name: process[0].name, pid: ::Process.pid
22
+ end
23
+
18
24
  # Update the already fetched processes list.
19
25
  def update!
20
26
  @process = parse_processes
@@ -2,7 +2,6 @@ require 'rlps/string'
2
2
  require 'rlps/process'
3
3
 
4
4
  module RLPS
5
-
6
5
  # This class parses Linux's /proc/ directory status file.
7
6
  class Parser
8
7
  # This method gets a /proc/ directory, then it parses
@@ -17,6 +16,7 @@ module RLPS
17
16
  end
18
17
  end
19
18
  RLPS::Process.new name: status['Name'], pid: status['Pid'].to_i
19
+ # TODO: add more information
20
20
  end
21
21
  end
22
22
  end
data/lib/rlps/process.rb CHANGED
@@ -4,10 +4,10 @@ module RLPS
4
4
  ##
5
5
  class Process
6
6
  attr_reader :name, :pid
7
+
7
8
  # Takes two arguments _:name_ and _:pid_
8
9
  # If called without any arguments it calls RLPS::Process.this_process.
9
- # ==== Examples
10
- # RLPS::Process.new name: "ruby", pid: 2365
10
+
11
11
  def initialize(**args)
12
12
  #-- other = args.select { |k, _v| ((k == :name) &&
13
13
  # !args[k].nil?) || ((k == :pid) && !args[k].nil?) }
@@ -21,16 +21,17 @@ module RLPS
21
21
  "#{@name}: #{@pid}"
22
22
  end
23
23
 
24
+ def ==(obj)
25
+ obj.pid == @pid && obj.name.casecmp(@name).zero?
26
+ end
27
+
24
28
  def to_i
25
29
  @pid
26
30
  end
27
31
 
28
- # Returns true if the process is still running.
29
- def still_running?
30
- !RLPS.processes.select do |p|
31
- p.pid == @pid &&
32
- p.name.casecmp(@name.downcase).zero?
33
- end.empty?
32
+ # Returns true if the process is running.
33
+ def is_running?
34
+ !RLPS.processes.select { |p| p == self }.empty?
34
35
  end
35
36
 
36
37
  # Send INT signal to the process as a default behaviour.
@@ -40,15 +41,8 @@ module RLPS
40
41
  ::Process.kill(signal, @pid)
41
42
  end
42
43
 
43
- # Return this process RLPS::Process object.
44
- def self.this_process
45
- process = RLPS.processes.select { |p| p.pid == ::Process.pid }
46
- RLPS::Process.new name: process[0].name, pid: ::Process.pid
47
- end
48
44
 
49
- def self.get(name: nil, pid: nil) #:nodoc:
50
- # TODO
51
- end
45
+
52
46
  alias inspect to_s
53
47
  end
54
48
  end
data/lib/rlps/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module RLPS
2
2
  # The current gem version.
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '1.0.0'.freeze
4
4
  end
data/rlps.gemspec CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.homepage = 'https://nemoload.github.io'
17
17
  spec.license = 'MIT'
18
18
 
19
+ spec.required_ruby_version = '~> 2.0'
19
20
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
21
  # to allow pushing to a single host or delete this section to allow pushing to any host.
21
22
  # if spec.respond_to?(:metadata)
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: 0.1.0
4
+ version: 1.0.0
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-02-10 00:00:00.000000000 Z
11
+ date: 2017-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -101,9 +101,9 @@ require_paths:
101
101
  - lib
102
102
  required_ruby_version: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - ">="
104
+ - - "~>"
105
105
  - !ruby/object:Gem::Version
106
- version: '0'
106
+ version: '2.0'
107
107
  required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - ">="