sys-proc 1.1.0 → 1.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1c2cdf6c827f4aea36a948b1b7cd2e872e430ae64fa164705f5dc6e5e276bbb
4
- data.tar.gz: b0ad47a922f9f5f64dde8fe6bd33d5aec98116d4a22923aa6d6032597f69e3c9
3
+ metadata.gz: 956f8100d4f060efacede7c157a281ebfd3ec785febae681444d014975ce4d30
4
+ data.tar.gz: 7d1453f8d9727faf06f8bbaee69894a3cb06e6acb1ce62b71a68f12c46aaf6e6
5
5
  SHA512:
6
- metadata.gz: 83ba2d092b49c79076f0d9ce2bfd3737c440ada78342b0ef0234552b386ab0683016fb84e8e30c0475aa645004ad35bb42764224d8d3e2be85ce89f8ee8e0c63
7
- data.tar.gz: 6e9f71aa3f610082174da4dfbd479b41792b642a482160fcfe3b2052db91c6f3a791b11de94732341c14d68ae21cadef2177b0581840eb981942afca03763d3b
6
+ metadata.gz: fd4e575ec661aa0225f7c189e14ba5873c6476d6f930ac9186496ed2e3215f69841fd5c3622f0f718b48a9a7c5a2cf3a02f17d636ba7e4594b04b40d3defc329
7
+ data.tar.gz: 65e8517deb397f2ad0301bb0e1b2104673d934c83c60c69ac2f0b590709a84370bad5dd719803cc40f285c6e05ab5b2f8c465c94b0f838b9706d9b6155cb0e8c
@@ -1,6 +1,4 @@
1
- # rubocop:disable Style/FileName
2
1
  # frozen_string_literal: true
3
- # rubocop:enable Style/FileName
4
2
 
5
3
  # Copyright (C) 2017-2018 Dimitri Arrigoni <dimitri@arrigoni.me>
6
4
  # License GPLv3+: GNU GPL version 3 or later
@@ -27,8 +27,8 @@ end
27
27
  # @see http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/proc.html
28
28
  class Sys::Proc
29
29
  require 'singleton'
30
- %i{system static_instance}.each do |req|
31
- require "sys/proc/concern/#{req}"
30
+ %i[system static_instance].each do |req|
31
+ require_relative "proc/concern/#{req}"
32
32
  end
33
33
 
34
34
  include Concern::StaticInstance
@@ -6,6 +6,8 @@
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
- module Sys::Proc::Concern
9
+ require_relative '../proc'
10
10
 
11
+ # Concern namespace
12
+ module Sys::Proc::Concern
11
13
  end
@@ -6,12 +6,11 @@
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 'sys/proc/concern'
10
- require 'sys/proc/helper'
9
+ require_relative '../concern'
10
+ require_relative '../helper'
11
11
 
12
12
  # Provides access to helpers
13
13
  module Sys::Proc::Concern::Helper
14
-
15
14
  protected
16
15
 
17
16
  # @return [Sys::Proc::Helper]
@@ -6,7 +6,7 @@
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 'sys/proc/concern'
9
+ require_relative '../concern'
10
10
 
11
11
  # Provides static accesses
12
12
  module Sys::Proc::Concern::StaticInstance
@@ -16,6 +16,7 @@ module Sys::Proc::Concern::StaticInstance
16
16
  end
17
17
  end
18
18
 
19
+ # Class methods
19
20
  module ClassMethods
20
21
  # Provides access to instance methods
21
22
  def method_missing(method, *args, &block)
@@ -6,8 +6,8 @@
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 'sys/proc/concern'
10
- require 'sys/proc/concern/helper'
9
+ require_relative '../concern'
10
+ require_relative 'helper'
11
11
 
12
12
  # Provides Operating System related methods
13
13
  #
@@ -42,9 +42,8 @@ module Sys::Proc::Concern::System
42
42
 
43
43
  begin
44
44
  inflector.resolve("sys/proc/concern/system/#{system}")
45
- rescue LoadError => e
45
+ rescue LoadError
46
46
  # m = /^cannot load such file -- #{Regexp.quote(system)}/ =~ e.to_s
47
-
48
47
  inflector.resolve('sys/proc/concern/system/generic')
49
48
  end
50
49
  end
@@ -6,10 +6,9 @@
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 'sys/proc/concern/helper'
10
- require 'sys/proc/concern/system'
11
- require 'sys/proc/concern/system/generic'
12
- require 'sys/proc/system/freebsd/lib_c'
9
+ require_relative '../../helper'
10
+ require_relative '../system/generic'
11
+ require_relative '../../system/freebsd/lib_c'
13
12
 
14
13
  # Provides specific Freebsd methods
15
14
  module Sys::Proc::Concern::System::Freebsd
@@ -6,7 +6,7 @@
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 'sys/proc/concern/system'
9
+ require_relative '../system'
10
10
 
11
11
  # Provides generic methods
12
12
  #
@@ -23,8 +23,6 @@ module Sys::Proc::Concern::System::Generic
23
23
  def progname=(progname)
24
24
  progname ||= default_progname
25
25
  $PROGRAM_NAME = progname.to_s
26
-
27
- progname
28
26
  end
29
27
 
30
28
  # Get program name
@@ -38,7 +36,9 @@ module Sys::Proc::Concern::System::Generic
38
36
  #
39
37
  # @return [String]
40
38
  def default_progname
41
- file = caller[-1].split(/:[0-9]+:in\s/).fetch(0)
39
+ file = caller.grep(/in `<main>'$/)
40
+ .fetch(0)
41
+ .split(/:[0-9]+:in\s/).fetch(0)
42
42
 
43
43
  File.basename(file, '.rb')
44
44
  end
@@ -6,10 +6,9 @@
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 'sys/proc/concern/helper'
10
- require 'sys/proc/concern/system'
11
- require 'sys/proc/concern/system/generic'
12
- require 'sys/proc/system/linux_gnu/prctl'
9
+ require_relative '../../helper'
10
+ require_relative '../system/generic'
11
+ require_relative '../../system/linux_gnu/prctl'
13
12
 
14
13
  # Provides specific Linux-GNU methods
15
14
  module Sys::Proc::Concern::System::LinuxGnu
@@ -6,7 +6,7 @@
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 'sys/proc'
9
+ require_relative '../proc'
10
10
 
11
11
  # Provides access to helper classes
12
12
  class Sys::Proc::Helper
@@ -15,7 +15,7 @@ class Sys::Proc::Helper
15
15
  protected def initialize
16
16
  @items = {
17
17
  inflector: proc do
18
- require 'sys/proc/helper/inflector'
18
+ require_relative 'helper/inflector'
19
19
 
20
20
  Inflector.new
21
21
  end.call
@@ -6,7 +6,7 @@
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 'sys/proc/helper'
9
+ require_relative '../helper'
10
10
 
11
11
  # Inflector built on top of ``Dry::Inflector``
12
12
  class Sys::Proc::Helper::Inflector
@@ -7,7 +7,7 @@
7
7
  # There is NO WARRANTY, to the extent permitted by law.
8
8
 
9
9
  require 'fiddle'
10
- require 'sys/proc/helper'
10
+ require_relative '../helper'
11
11
 
12
12
  # System helper
13
13
  class Sys::Proc::Helper::LibC
@@ -6,7 +6,8 @@
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 'sys/proc/helper/system'
9
+ require_relative '../system'
10
+ require_relative '../../concern/system/generic'
10
11
 
11
12
  # Provides access to ``Sys::Proc::Concerns::System::Generic`` methods
12
13
  class Sys::Proc::Helper::System::Generic
@@ -34,8 +35,6 @@ class Sys::Proc::Helper::System::Generic
34
35
  protected
35
36
 
36
37
  def system
37
- require 'sys/proc/concern/system/generic'
38
-
39
38
  (Class.new { include Sys::Proc::Concern::System::Generic }).new
40
39
  end
41
40
  end
@@ -6,9 +6,8 @@
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 'sys/proc'
9
+ require_relative '../proc'
10
10
 
11
11
  # OS specific namespace
12
12
  module Sys::Proc::System
13
-
14
13
  end
@@ -6,9 +6,8 @@
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 'sys/proc/system'
9
+ require_relative '../system'
10
10
 
11
11
  # Freebsd specific namespace
12
12
  module Sys::Proc::System::Freebsd
13
-
14
13
  end
@@ -7,8 +7,8 @@
7
7
  # There is NO WARRANTY, to the extent permitted by law.
8
8
 
9
9
  require 'fiddle'
10
- require 'sys/proc/system/freebsd'
11
- require 'sys/proc/concern/helper'
10
+ require_relative '../freebsd'
11
+ require_relative '../../concern/helper'
12
12
 
13
13
  # The ``getprogname()`` and ``setprogname()`` functions manipulate
14
14
  # the name of the current program.
@@ -6,9 +6,8 @@
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 'sys/proc/system'
9
+ require_relative '../system'
10
10
 
11
11
  # GNU/Linux specific namespace
12
12
  module Sys::Proc::System::LinuxGnu
13
-
14
13
  end
@@ -7,8 +7,8 @@
7
7
  # There is NO WARRANTY, to the extent permitted by law.
8
8
 
9
9
  require 'fiddle'
10
- require 'sys/proc/system/linux_gnu'
11
- require 'sys/proc/concern/helper'
10
+ require_relative '../linux_gnu'
11
+ require_relative '../../helper'
12
12
 
13
13
  # Operations on a process
14
14
  #
@@ -22,7 +22,6 @@ require 'sys/proc/concern/helper'
22
22
  # ~~~~
23
23
  class Sys::Proc::System::LinuxGnu::Prctl
24
24
  include Sys::Proc::Concern::Helper
25
- attr_reader :function
26
25
 
27
26
  # Set the name of the calling threadThe attribute is
28
27
  # likewise accessible via /proc/self/task/[tid]/comm, where tid
@@ -24,10 +24,8 @@ class Sys::Proc::Version
24
24
  # @param [String] file_name
25
25
  def initialize(file_name = self.class.file_name)
26
26
  @file_name = file_name.freeze
27
-
28
- self.load_file
29
- .map { |k, v| self.attr_set(k, v) }
30
- .yield_self { |loaded| @data_loaded = loaded.to_h }
27
+ @data_loaded = self.load_file
28
+ .map { |k, v| self.attr_set(k, v) }.to_h
31
29
  end
32
30
 
33
31
  # Denote version has enough (mninimal) attributes defined.
@@ -71,13 +69,12 @@ class Sys::Proc::Version
71
69
 
72
70
  protected
73
71
 
72
+ # @return [Hash]
74
73
  attr_reader :data_loaded
75
74
 
76
75
  # @return [Hash]
77
76
  def load_file
78
- YAML.load_file(file_name).yield_self do |data|
79
- data == false ? {} : data
80
- end
77
+ YAML.load_file(file_name) || {}
81
78
  rescue Errno::ENOENT
82
79
  {}
83
80
  end
@@ -0,0 +1,17 @@
1
+ ---
2
+ major: 1
3
+ minor: 1
4
+ patch: 1
5
+ authors: ['Dimitri Arrigoni']
6
+ email: 'dimitri@arrigoni.me'
7
+ date: '2018-06-01'
8
+ summary: 'Cross-platform interface to customize process name'
9
+ description: 'A cross-platform interface to customize process name'
10
+ licenses: ['GPL-3.0']
11
+ license_header: |
12
+ Copyright (C) 2017-2018 Dimitri Arrigoni <dimitri@arrigoni.me>
13
+ License GPLv3+: GNU GPL version 3 or later
14
+ <http://www.gnu.org/licenses/gpl.html>.
15
+ This is free software: you are free to change and redistribute it.
16
+ There is NO WARRANTY, to the extent permitted by law.
17
+ homepage: 'https://github.com/SwagDevOps/sys-proc'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-proc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitri Arrigoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-30 00:00:00.000000000 Z
11
+ date: 2018-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-inflector
@@ -51,6 +51,7 @@ files:
51
51
  - lib/sys/proc/system/linux_gnu.rb
52
52
  - lib/sys/proc/system/linux_gnu/prctl.rb
53
53
  - lib/sys/proc/version.rb
54
+ - lib/sys/proc/version.yml
54
55
  homepage: https://github.com/SwagDevOps/sys-proc
55
56
  licenses:
56
57
  - GPL-3.0