procfs 0.0.1
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.
- data/.gitignore +19 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +6 -0
- data/Rakefile +15 -0
- data/lib/procfs.rb +6 -0
- data/lib/procfs/process_extensions.rb +24 -0
- data/lib/procfs/version.rb +3 -0
- data/procfs.gemspec +24 -0
- data/test/procfs_test.rb +20 -0
- metadata +77 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
ProcFS Ruby wrapper [](http://travis-ci.org/marcinwyszynski/procfs) [](https://gemnasium.com/marcinwyszynski/procfs) [](https://codeclimate.com/github/marcinwyszynski/procfs)
|
2
|
+
==================
|
3
|
+
|
4
|
+
A handy collection of Ruby wrappers around the Linux ProcFS.
|
5
|
+
|
6
|
+
So far it only sports one method (Process::file_desciprots) which allows listing open file descriptors as a hash from the Process object.
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake"
|
3
|
+
require "rake/testtask"
|
4
|
+
require "reek/rake/task"
|
5
|
+
|
6
|
+
task :default => [ :unittests ]
|
7
|
+
|
8
|
+
Rake::TestTask.new("unittests") do |t|
|
9
|
+
t.pattern = "test/*_test.rb"
|
10
|
+
t.verbose = true
|
11
|
+
end
|
12
|
+
|
13
|
+
Reek::Rake::Task.new do |t|
|
14
|
+
t.fail_on_error = false
|
15
|
+
end
|
data/lib/procfs.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module ProcFS::ProcessExtensions
|
2
|
+
|
3
|
+
def self.included(base)
|
4
|
+
base.extend(ClassMethods)
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
|
9
|
+
def file_descriptors(pid=nil)
|
10
|
+
pid ||= $$
|
11
|
+
result = {}
|
12
|
+
Dir::glob("/proc/#{$$}/fd/*").each do |fd|
|
13
|
+
begin
|
14
|
+
fd_id = fd.split("/").last
|
15
|
+
result[fd_id] = File::readlink(fd)
|
16
|
+
rescue Errno::ENOENT
|
17
|
+
end
|
18
|
+
end
|
19
|
+
result
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/procfs.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "procfs/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "procfs"
|
7
|
+
s.version = ProcFS::VERSION
|
8
|
+
s.authors = ["Marcin Wyszynski"]
|
9
|
+
s.email = ["marcin.pixie@gmail.com"]
|
10
|
+
s.homepage = "http://github.com/marcinwyszynski/procfs"
|
11
|
+
s.summary = "Linux ProcFS utilities"
|
12
|
+
s.description = "A handy collection of Ruby wrappers around the Linux ProcFS."
|
13
|
+
|
14
|
+
s.rubyforge_project = "procfs"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
s.add_development_dependency("rake")
|
22
|
+
s.add_development_dependency("reek")
|
23
|
+
|
24
|
+
end
|
data/test/procfs_test.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "procfs"
|
3
|
+
|
4
|
+
class ProcFSTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_file_descriptors
|
7
|
+
file_address = "/tmp/file_descriptors_test.txt"
|
8
|
+
begin
|
9
|
+
fd = File::open(file_address, "w")
|
10
|
+
open_descriptors = Process::file_descriptors
|
11
|
+
assert open_descriptors.is_a?(Hash)
|
12
|
+
assert open_descriptors.values.include?(file_address)
|
13
|
+
rescue Exception
|
14
|
+
puts "Snakes on a plane"
|
15
|
+
ensure
|
16
|
+
fd.close
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: procfs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Marcin Wyszynski
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &15950920 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *15950920
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: reek
|
27
|
+
requirement: &15949320 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *15949320
|
36
|
+
description: A handy collection of Ruby wrappers around the Linux ProcFS.
|
37
|
+
email:
|
38
|
+
- marcin.pixie@gmail.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- .travis.yml
|
45
|
+
- Gemfile
|
46
|
+
- README.md
|
47
|
+
- Rakefile
|
48
|
+
- lib/procfs.rb
|
49
|
+
- lib/procfs/process_extensions.rb
|
50
|
+
- lib/procfs/version.rb
|
51
|
+
- procfs.gemspec
|
52
|
+
- test/procfs_test.rb
|
53
|
+
homepage: http://github.com/marcinwyszynski/procfs
|
54
|
+
licenses: []
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project: procfs
|
73
|
+
rubygems_version: 1.8.15
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: Linux ProcFS utilities
|
77
|
+
test_files: []
|