sys-proc 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/sys-proc.rb +34 -35
- data/lib/sys/proc.rb +8 -0
- data/lib/sys/proc/concern.rb +0 -2
- data/lib/sys/proc/concern/helper.rb +0 -1
- data/lib/sys/proc/concern/static_instance.rb +5 -1
- data/lib/sys/proc/concern/system.rb +11 -3
- data/lib/sys/proc/concern/system/freebsd.rb +0 -2
- data/lib/sys/proc/concern/system/generic.rb +0 -2
- data/lib/sys/proc/concern/system/linux_gnu.rb +0 -2
- data/lib/sys/proc/concern/versionable.rb +10 -4
- data/lib/sys/proc/helper/inflector.rb +3 -2
- data/lib/sys/proc/version_info.yml +2 -2
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8b275dfa40aae0cadab2ef0ab886de7f569b78cb640cc94c74b655f68e45a40f
|
4
|
+
data.tar.gz: 3bfea024129dbdd12fbc113851f43fff15d883dbf3342c5049ae7db20b6f5123
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26c00d1ee9cf5fd7d3acf0c50593ae2c14072498edba8278c44187c2d617453fe5cde489e810dd50c5a44cb371eafd3db608aa4a8801b49f309aa7f8bab4434d
|
7
|
+
data.tar.gz: 9005b9dca1aec9bb9d5ffacb1a9a6224bb685d5de98f9ce1af7bcb0938241ab614b0b1128ad7babf8552e6890f8a20c886590283af445e3c8c24f6373452bcfc
|
data/lib/sys-proc.rb
CHANGED
@@ -8,45 +8,44 @@
|
|
8
8
|
# This is free software: you are free to change and redistribute it.
|
9
9
|
# There is NO WARRANTY, to the extent permitted by law.
|
10
10
|
|
11
|
-
|
12
|
-
require 'rubygems'
|
13
|
-
require 'bundler'
|
11
|
+
$LOAD_PATH.unshift(__dir__)
|
14
12
|
|
15
|
-
|
13
|
+
lock = Dir.chdir("#{__dir__}/..") do
|
14
|
+
[['gems.rb', 'gems.locked'], ['Gemfile', 'Gemfile.lock']]
|
15
|
+
.map { |m| Dir.glob(m).size >= 2 }
|
16
|
+
.include?(true)
|
16
17
|
end
|
18
|
+
mode = (ENV['PROJECT_MODE'] || lock ? 'development' : 'production').to_sym
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
require 'bundler/setup'
|
23
|
-
|
24
|
-
require 'pp'
|
25
|
-
begin
|
26
|
-
require 'coderay'
|
27
|
-
require 'pry/color_printer'
|
28
|
-
rescue LoadError => e
|
29
|
-
# rubocop:disable Performance/Caller
|
30
|
-
warn('%s: %s' % [caller[0], e.message])
|
31
|
-
# rubocop:enable Performance/Caller
|
32
|
-
end
|
20
|
+
if lock
|
21
|
+
require 'rubygems'
|
22
|
+
require 'bundler/setup'
|
23
|
+
end
|
33
24
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
#
|
41
|
-
|
42
|
-
#
|
43
|
-
|
44
|
-
args = [obj, out, width].compact
|
45
|
-
colorable = (out.isatty and Kernel.const_defined?('Pry::ColorPrinter'))
|
25
|
+
if lock and :development == mode
|
26
|
+
require 'pp'
|
27
|
+
begin
|
28
|
+
require 'coderay'
|
29
|
+
require 'pry/color_printer'
|
30
|
+
rescue LoadError => e
|
31
|
+
# rubocop:disable Performance/Caller
|
32
|
+
warn('%s: %s' % [caller[0], e.message])
|
33
|
+
# rubocop:enable Performance/Caller
|
34
|
+
end
|
46
35
|
|
47
|
-
|
48
|
-
|
36
|
+
# Outputs obj to out in pretty printed format of width columns in width.
|
37
|
+
#
|
38
|
+
# If out is omitted, ``STDOUT`` is assumed.
|
39
|
+
# If width is omitted, ``79`` is assumed.
|
40
|
+
#
|
41
|
+
# @param [Object] obj
|
42
|
+
# @param [IO] out
|
43
|
+
# @param [Fixnum] width
|
44
|
+
# @see http://ruby-doc.org/stdlib-2.2.0/libdoc/pp/rdoc/PP.html
|
45
|
+
def pp(obj, out = STDOUT, width = 79)
|
46
|
+
args = [obj, out, width].compact
|
47
|
+
colorable = (out.isatty and Kernel.const_defined?('Pry::ColorPrinter'))
|
48
|
+
|
49
|
+
(colorable ? Pry::ColorPrinter : PP).pp(*args)
|
49
50
|
end
|
50
51
|
end
|
51
|
-
|
52
|
-
require File.basename(__FILE__, '.rb').tr('-', '/')
|
data/lib/sys/proc.rb
CHANGED
@@ -50,4 +50,12 @@ class Sys::Proc
|
|
50
50
|
def pid
|
51
51
|
$PROCESS_ID
|
52
52
|
end
|
53
|
+
|
54
|
+
# Time in seconds since system boot
|
55
|
+
#
|
56
|
+
# @see https://blog.dnsimple.com/2018/03/elapsed-time-with-ruby-the-right-way/
|
57
|
+
# @return [Float]
|
58
|
+
def uptime
|
59
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
60
|
+
end
|
53
61
|
end
|
data/lib/sys/proc/concern.rb
CHANGED
@@ -10,7 +10,11 @@ require 'sys/proc/concern'
|
|
10
10
|
|
11
11
|
# Provides static accesses
|
12
12
|
module Sys::Proc::Concern::StaticInstance
|
13
|
-
|
13
|
+
class << self
|
14
|
+
def included(base)
|
15
|
+
base.extend(ClassMethods)
|
16
|
+
end
|
17
|
+
end
|
14
18
|
|
15
19
|
module ClassMethods
|
16
20
|
# Provides access to instance methods
|
@@ -13,11 +13,17 @@ require 'sys/proc/concern/helper'
|
|
13
13
|
#
|
14
14
|
# This ``Concern`` loads system (OS) related sub-concern (specialisation)
|
15
15
|
module Sys::Proc::Concern::System
|
16
|
-
extend ActiveSupport::Concern
|
17
16
|
include Sys::Proc::Concern::Helper
|
18
17
|
|
19
|
-
|
20
|
-
|
18
|
+
class << self
|
19
|
+
include Sys::Proc::Concern::Helper
|
20
|
+
|
21
|
+
def included(base)
|
22
|
+
# Related concern is included recursively
|
23
|
+
|
24
|
+
base.include(base.new.__send__(:system_concern))
|
25
|
+
end
|
26
|
+
end
|
21
27
|
|
22
28
|
# Identify operating system
|
23
29
|
#
|
@@ -26,6 +32,8 @@ module Sys::Proc::Concern::System
|
|
26
32
|
(@system || helper.get(:system).identify).to_sym
|
27
33
|
end
|
28
34
|
|
35
|
+
protected
|
36
|
+
|
29
37
|
# Get operating system related concern
|
30
38
|
#
|
31
39
|
# @return [Module]
|
@@ -14,8 +14,6 @@ require 'sys/proc/concern/system'
|
|
14
14
|
# in other system(s) specific modules.
|
15
15
|
# This is the default (included) module when specific module is missing.
|
16
16
|
module Sys::Proc::Concern::System::Generic
|
17
|
-
extend ActiveSupport::Concern
|
18
|
-
|
19
17
|
# Set program name
|
20
18
|
#
|
21
19
|
# When ``progname`` is ``nil`` will use a default ``progname``
|
@@ -6,15 +6,21 @@
|
|
6
6
|
# This is free software: you are free to change and redistribute it.
|
7
7
|
# There is NO WARRANTY, to the extent permitted by law.
|
8
8
|
|
9
|
+
require_relative '../concern'
|
9
10
|
require 'pathname'
|
10
|
-
|
11
|
-
require 'sys/proc/concern'
|
11
|
+
require 'version_info'
|
12
12
|
|
13
13
|
# Provides a standardized way to use ``VersionInfo``
|
14
14
|
module Sys::Proc::Concern::Versionable
|
15
|
-
extend ActiveSupport::Concern
|
16
15
|
|
17
|
-
|
16
|
+
|
17
|
+
class << self
|
18
|
+
def included(base)
|
19
|
+
base.extend(ClassMethods)
|
20
|
+
|
21
|
+
base.version_info
|
22
|
+
end
|
23
|
+
end
|
18
24
|
|
19
25
|
module ClassMethods
|
20
26
|
def version_info
|
@@ -8,11 +8,12 @@
|
|
8
8
|
|
9
9
|
require 'sys/proc/helper'
|
10
10
|
|
11
|
+
# Inflector built on top of ``Dry::Inflector``
|
11
12
|
class Sys::Proc::Helper::Inflector
|
12
13
|
def initialize
|
13
|
-
require '
|
14
|
+
require 'dry/inflector'
|
14
15
|
|
15
|
-
@inflector =
|
16
|
+
@inflector = Dry::Inflector.new
|
16
17
|
end
|
17
18
|
|
18
19
|
# Load constant from a loadable/requirable path
|
@@ -1,10 +1,10 @@
|
|
1
1
|
---
|
2
2
|
major: 1
|
3
3
|
minor: 0
|
4
|
-
patch:
|
4
|
+
patch: 5
|
5
5
|
authors: ['Dimitri Arrigoni']
|
6
6
|
email: 'dimitri@arrigoni.me'
|
7
|
-
date: '
|
7
|
+
date: '2018-05-12'
|
8
8
|
summary: 'A cross-platform interface to customize the process name'
|
9
9
|
description: 'A cross-platform interface to customize the process name'
|
10
10
|
licenses: ['GPL-3.0']
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sys-proc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitri Arrigoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: dry-inflector
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
+
- - "<"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.2'
|
17
20
|
- - "~>"
|
18
21
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
22
|
+
version: '0.1'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
27
|
+
- - "<"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.2'
|
24
30
|
- - "~>"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
32
|
+
version: '0.1'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: version_info
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -268,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
268
274
|
version: '0'
|
269
275
|
requirements: []
|
270
276
|
rubyforge_project:
|
271
|
-
rubygems_version: 2.
|
277
|
+
rubygems_version: 2.7.6
|
272
278
|
signing_key:
|
273
279
|
specification_version: 4
|
274
280
|
summary: A cross-platform interface to customize the process name
|