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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ef430fcc11653031cddb758f6c437226d8f68bf2
4
- data.tar.gz: 80f41aef12dc56df8a65d1747fe78d10fa33dcb4
2
+ SHA256:
3
+ metadata.gz: 8b275dfa40aae0cadab2ef0ab886de7f569b78cb640cc94c74b655f68e45a40f
4
+ data.tar.gz: 3bfea024129dbdd12fbc113851f43fff15d883dbf3342c5049ae7db20b6f5123
5
5
  SHA512:
6
- metadata.gz: a12621872b2b9a640d63c0f64d471cb1edc2db6a6dbd0c9164d738f0594592e38a877692dfecf6a7c813ea503b2c2ad7b43f55a4e1c8124886456e71f6a94cdc
7
- data.tar.gz: ebd2f9fd1e2506a0dad2f5ce111ce7e70dc470aec4c553168fbb021c49df5c08d2c415595dba267cedbbe1543135a841fbdecf5a1e3642db739cb23942809079
6
+ metadata.gz: 26c00d1ee9cf5fd7d3acf0c50593ae2c14072498edba8278c44187c2d617453fe5cde489e810dd50c5a44cb371eafd3db608aa4a8801b49f309aa7f8bab4434d
7
+ data.tar.gz: 9005b9dca1aec9bb9d5ffacb1a9a6224bb685d5de98f9ce1af7bcb0938241ab614b0b1128ad7babf8552e6890f8a20c886590283af445e3c8c24f6373452bcfc
@@ -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
- if File.file?("#{__dir__}/../Gemfile.lock")
12
- require 'rubygems'
13
- require 'bundler'
11
+ $LOAD_PATH.unshift(__dir__)
14
12
 
15
- Bundler.setup(:default)
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
- $LOAD_PATH.unshift __dir__
19
-
20
- if File.file?("#{__dir__}/../Gemfile.lock")
21
- if 'development' == ENV['PROJECT_MODE']
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
- # Outputs obj to out in pretty printed format of width columns in width.
35
- #
36
- # If out is omitted, ``STDOUT`` is assumed.
37
- # If width is omitted, ``79`` is assumed.
38
- #
39
- # @param [Object] obj
40
- # @param [IO] out
41
- # @param [Fixnum] width
42
- # @see http://ruby-doc.org/stdlib-2.2.0/libdoc/pp/rdoc/PP.html
43
- def pp(obj, out = STDOUT, width = 79)
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
- (colorable ? Pry::ColorPrinter : PP).pp(*args)
48
- end
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('-', '/')
@@ -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
@@ -6,8 +6,6 @@
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 'active_support/concern'
10
-
11
9
  module Sys::Proc::Concern
12
10
 
13
11
  end
@@ -11,7 +11,6 @@ require 'sys/proc/helper'
11
11
 
12
12
  # Provides access to helpers
13
13
  module Sys::Proc::Concern::Helper
14
- extend ActiveSupport::Concern
15
14
 
16
15
  protected
17
16
 
@@ -10,7 +10,11 @@ require 'sys/proc/concern'
10
10
 
11
11
  # Provides static accesses
12
12
  module Sys::Proc::Concern::StaticInstance
13
- extend ActiveSupport::Concern
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
- # Related concern is included recursively
20
- included { include system_concern }
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]
@@ -13,8 +13,6 @@ require 'sys/proc/system/freebsd/lib_c'
13
13
 
14
14
  # Provides specific Freebsd methods
15
15
  module Sys::Proc::Concern::System::Freebsd
16
- extend ActiveSupport::Concern
17
-
18
16
  include Sys::Proc::Concern::Helper
19
17
  include Sys::Proc::System::Freebsd
20
18
 
@@ -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``
@@ -13,8 +13,6 @@ require 'sys/proc/system/linux_gnu/prctl'
13
13
 
14
14
  # Provides specific Linux-GNU methods
15
15
  module Sys::Proc::Concern::System::LinuxGnu
16
- extend ActiveSupport::Concern
17
-
18
16
  include Sys::Proc::Concern::Helper
19
17
  include Sys::Proc::System::LinuxGnu
20
18
 
@@ -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
- included { version_info }
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 'active_support/inflector'
14
+ require 'dry/inflector'
14
15
 
15
- @inflector = ActiveSupport::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
4
+ patch: 5
5
5
  authors: ['Dimitri Arrigoni']
6
6
  email: 'dimitri@arrigoni.me'
7
- date: '2017-08-06'
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
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: 2017-08-06 00:00:00.000000000 Z
11
+ date: 2018-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: activesupport
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: '5.1'
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: '5.1'
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.5.1
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