sys-uname 1.2.2 → 1.2.3

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
  SHA256:
3
- metadata.gz: e5cbd8721570c3681f05f66562a956b366d7839da185a309acc136fceab2f9b8
4
- data.tar.gz: 315ba4bc84cbfb0e1201a78062858218f6652148a37d9e62f90a7200c70d3d50
3
+ metadata.gz: da53561b44caf45c227aad7130b9b120e9bbdd3cd35b665ecf527b8a7ad51996
4
+ data.tar.gz: ce041695020d00b6eeacb5861fc39268a84a6bc4f586f3c2576f2b4e599816d7
5
5
  SHA512:
6
- metadata.gz: 5c22800edea9dfd5b9057fb3fae10a76e88ecbead21e02b8d66ce7b1105294f01efe661d9ae9e9fe9653293acd8966aabd667296c40d1891225fd54289422845
7
- data.tar.gz: 10cad4749fee0e1e6fcd5f531e046ba8f9ce9af354401d065b8d786365aa7e87d6691745e84f164cf3ef87f1a5849b52f815d7c9a517ec839005963c5ca75d7b
6
+ metadata.gz: dd826360df12898bb135c2a442c475cbf209c1dae207b290214af3ae8130eaaed41800c2744942908ac11469c4ec9c7d2bebbd25bf112041148c629b502431d3
7
+ data.tar.gz: bd9cdeff9d5459e7c66e86b280c6f19f046812bfdb3abb05b8c874cfd535df3895f8ad3198026df3ac2f845690bc85dd0b9ab939212b6563c95071215e011453
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 1.2.3 - 9-Apr-2023
2
+ * Added rubygems_mfa_required and github_repo to metadata.
3
+ * Miscellaneous rubocop related updates.
4
+ * Fixed one test for Windows.
5
+ * The rubocop and rubocop-rspec gems are now development dependencies.
6
+ * Now assumes Ruby 2.0 or later.
7
+
1
8
  ## 1.2.2 - 30-Oct-2020
2
9
  * Added a Gemfile.
3
10
  * The ffi dependency is now slightly more restrictive.
data/Gemfile CHANGED
@@ -1,7 +1,2 @@
1
- source 'https://rubygems.org' do
2
- gem 'ffi', '~> 1.1'
3
- group 'test' do
4
- gem 'rake'
5
- gem 'rspec', '~> 3.9'
6
- end
7
- end
1
+ source 'https://rubygems.org'
2
+ gemspec
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Ruby](https://github.com/djberg96/sys-uname/actions/workflows/ruby.yml/badge.svg)](https://github.com/djberg96/sys-uname/actions/workflows/ruby.yml)
2
+
1
3
  ## Description
2
4
  A cross-platform Ruby interface for getting operating system information. The name
3
5
  comes from the Unix 'uname' command, but this library works on MS Windows as well.
@@ -8,8 +10,11 @@ ffi 1.0 or later
8
10
  ## Installation
9
11
  `gem install sys-uname`
10
12
 
13
+ ## Adding the trusted cert
14
+ `gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/sys-uname/main/certs/djberg96_pub.pem)`
15
+
11
16
  ## Synopsis
12
- ```
17
+ ```ruby
13
18
  require 'sys/uname' # require 'sys-uname' works, too
14
19
 
15
20
  # You now have Sys::Uname and Sys::Platform classes available.
@@ -23,21 +28,31 @@ p Sys::Platform::ARCH # => :x86_64
23
28
  ```
24
29
 
25
30
  ## Solaris Notes
26
- Users on SunOS get several extra methods: architecture, platform,
27
- hw_serial, hw_provider, srpc_domain, isa_list, and dhcp_cache.
31
+ Users on SunOS get several extra methods:
32
+
33
+ * architecture
34
+ * platform
35
+ * hw_serial
36
+ * hw_provider
37
+ * srpc_domain
38
+ * isa_list
39
+ * dhcp_cache
40
+
41
+ Note that Solaris is essentially a dead OS at this point, so it will not be
42
+ supported going forward, and will likely be dropped in the next major release.
28
43
 
29
44
  ## BSD flavors, including OS X
30
- Users on BSD platforms get the extra Uname.model method.
45
+ Users on BSD platforms get the extra `Uname.model` method.
31
46
 
32
47
  ## HP-UX Notes
33
- HP-UX users get the extra Uname.id_number method. This is actually a
48
+ HP-UX users get the extra `Uname.id_number` method. This is actually a
34
49
  String, not a Fixnum, because that's how it's defined in the utsname
35
50
  struct.
36
51
 
37
52
  ## MS Windows Notes
38
53
  The C version for Windows has been completely scrapped in favor of an OLE
39
54
  plus WMI approach. It is pure Ruby. Please see the MSDN documentation for
40
- the Win32_OperatingSystem class for a complete list of what each of the
55
+ the `Win32_OperatingSystem` class for a complete list of what each of the
41
56
  UnameStruct members mean.
42
57
 
43
58
  ## The Platform Class
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
1
  require 'rake'
2
- require 'rake/testtask'
3
2
  require 'rake/clean'
4
3
  require 'rbconfig'
5
4
  require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
6
6
 
7
7
  CLEAN.include("**/*.rbc", "**/*.rbx", "**/*.gem", "**/*.lock")
8
8
 
@@ -19,7 +19,7 @@ namespace :gem do
19
19
  desc "Create the sys-uname gem"
20
20
  task :create => [:clean] do
21
21
  require 'rubygems/package'
22
- spec = eval(IO.read('sys-uname.gemspec'))
22
+ spec = Gem::Specification.load('sys-uname.gemspec')
23
23
  spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
24
24
  Gem::Package.build(spec)
25
25
  end
@@ -31,6 +31,8 @@ namespace :gem do
31
31
  end
32
32
  end
33
33
 
34
+ RuboCop::RakeTask.new
35
+
34
36
  desc "Run the test suite"
35
37
  RSpec::Core::RakeTask.new(:spec)
36
38
 
data/doc/uname.rdoc CHANGED
@@ -112,7 +112,7 @@ Add additional info for Linux, Solaris, BSD.
112
112
  Apache-2.0
113
113
 
114
114
  == Copyright
115
- (C) 2002-2020 Daniel J. Berger
115
+ (C) 2002-2023 Daniel J. Berger
116
116
  All Rights Reserved
117
117
 
118
118
  == Warranty
data/lib/sys/platform.rb CHANGED
@@ -1,4 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # The Sys module is a namespace only.
1
4
  module Sys
5
+ # The Platform class provides singleton methods to tell you what OS you're on.
2
6
  class Platform
3
7
  # The CPU architecture
4
8
  ARCH = File::ALT_SEPARATOR ? Uname.architecture.to_sym : Uname.machine.to_sym
@@ -8,18 +12,18 @@ module Sys
8
12
 
9
13
  # Returns the OS type, :macosx, :linux, :mingw32, etc
10
14
  IMPL = case Uname.sysname
11
- when /darwin|mac/i
12
- :macosx
13
- when /mingw|windows/i
14
- require 'rbconfig'
15
- RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase.to_sym
16
- when /linux/i
17
- :linux
18
- when /sunos|solaris/i
19
- :solaris
20
- when /bsd/i
21
- :bsd
22
- end
15
+ when /darwin|mac/i
16
+ :macosx
17
+ when /mingw|windows/i
18
+ require 'rbconfig'
19
+ RbConfig::CONFIG['host_os'].split('_').first[/[a-z]+/i].downcase.to_sym
20
+ when /linux/i
21
+ :linux
22
+ when /sunos|solaris/i
23
+ :solaris
24
+ when /bsd/i
25
+ :bsd
26
+ end
23
27
 
24
28
  # Returns whether or not you're on a Windows OS
25
29
  def self.windows?
@@ -28,7 +32,7 @@ module Sys
28
32
 
29
33
  # Returns whether or not you're on a Unixy (non-Windows) OS
30
34
  def self.unix?
31
- Uname.sysname !~ /microsoft/i ? true : false
35
+ Uname.sysname =~ /microsoft/i ? false : true
32
36
  end
33
37
 
34
38
  # Returns whether or not you're on a mac, i.e. OSX
data/lib/sys/uname.rb CHANGED
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Sys
2
4
  class Uname
3
5
  # The version of the sys-uname gem.
4
- VERSION = '1.2.2'.freeze
6
+ VERSION = '1.2.3'
5
7
  end
6
8
 
7
9
  class Platform
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ffi'
2
4
  require 'rbconfig'
3
5
  require 'ostruct'
@@ -30,7 +32,7 @@ module Sys
30
32
  private_class_method :uname_c
31
33
 
32
34
  begin
33
- attach_function :sysctl, [:pointer, :uint, :pointer, :pointer, :pointer, :size_t], :int
35
+ attach_function :sysctl, %i[pointer uint pointer pointer pointer size_t], :int
34
36
  private_class_method :sysctl
35
37
 
36
38
  CTL_HW = 6 # Generic hardware/cpu
@@ -40,7 +42,7 @@ module Sys
40
42
  end
41
43
 
42
44
  begin
43
- attach_function :sysinfo, [:int, :pointer, :long], :long
45
+ attach_function :sysinfo, %i[int pointer long], :long
44
46
  private_class_method :sysinfo
45
47
 
46
48
  SI_SYSNAME = 1 # OS name
@@ -59,6 +61,7 @@ module Sys
59
61
  # Ignore. Not suppored.
60
62
  end
61
63
 
64
+ # FFI class passed to the underlying C uname function.
62
65
  class UnameFFIStruct < FFI::Struct
63
66
  members = [
64
67
  :sysname, [:char, BUFSIZE],
@@ -68,13 +71,8 @@ module Sys
68
71
  :machine, [:char, BUFSIZE]
69
72
  ]
70
73
 
71
- if RbConfig::CONFIG['host_os'] =~ /linux/i
72
- members.push(:domainname, [:char, BUFSIZE])
73
- end
74
-
75
- if RbConfig::CONFIG['host_os'] =~ /hpux/i
76
- members.push(:__id_number, [:char, BUFSIZE])
77
- end
74
+ members.push(:domainname, [:char, BUFSIZE]) if RbConfig::CONFIG['host_os'] =~ /linux/i
75
+ members.push(:__id_number, [:char, BUFSIZE]) if RbConfig::CONFIG['host_os'] =~ /hpux/i
78
76
 
79
77
  layout(*members)
80
78
  end
@@ -87,13 +85,8 @@ module Sys
87
85
  machine
88
86
  ]
89
87
 
90
- if RbConfig::CONFIG['host_os'] =~ /linux/i
91
- fields.push('domainname')
92
- end
93
-
94
- if RbConfig::CONFIG['host_os'] =~ /hpux/i
95
- fields.push('id_number')
96
- end
88
+ fields.push('domainname') if RbConfig::CONFIG['host_os'] =~ /linux/i
89
+ fields.push('id_number') if RbConfig::CONFIG['host_os'] =~ /hpux/i
97
90
 
98
91
  if RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i
99
92
  fields.push(
@@ -107,13 +100,13 @@ module Sys
107
100
  )
108
101
  end
109
102
 
110
- if RbConfig::CONFIG['host_os'] =~ /darwin|bsd/i
111
- fields.push('model')
112
- end
103
+ fields.push('model') if RbConfig::CONFIG['host_os'] =~ /darwin|bsd/i
104
+
105
+ private_constant :UnameFFIStruct
113
106
 
114
107
  # :startdoc:
115
108
 
116
- UnameStruct = Struct.new("UnameStruct", *fields)
109
+ UnameStruct = Struct.new('UnameStruct', *fields)
117
110
 
118
111
  # Returns a struct that contains the sysname, nodename, machine, version
119
112
  # and release of your system.
@@ -133,9 +126,7 @@ module Sys
133
126
  def self.uname
134
127
  utsname = UnameFFIStruct.new
135
128
 
136
- if uname_c(utsname) < 0
137
- raise Error, "uname() function call failed"
138
- end
129
+ raise Error, 'uname() function call failed' if uname_c(utsname) < 0
139
130
 
140
131
  struct = UnameStruct.new
141
132
  struct[:sysname] = utsname[:sysname].to_s
@@ -144,9 +135,7 @@ module Sys
144
135
  struct[:version] = utsname[:version].to_s
145
136
  struct[:machine] = utsname[:machine].to_s
146
137
 
147
- if RbConfig::CONFIG['host_os'] =~ /darwin|bsd/i
148
- struct[:model] = get_model()
149
- end
138
+ struct[:model] = get_model() if RbConfig::CONFIG['host_os'] =~ /darwin|bsd/i
150
139
 
151
140
  if RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i
152
141
  struct[:architecture] = get_si(SI_ARCHITECTURE)
@@ -165,21 +154,17 @@ module Sys
165
154
  struct[:machine] = get_si(SI_MACHINE) if struct.machine.empty?
166
155
  end
167
156
 
168
- if RbConfig::CONFIG['host_os'] =~ /hpux/i
169
- struct[:id_number] = utsname[:__id_number].to_s
170
- end
157
+ struct[:id_number] = utsname[:__id_number].to_s if RbConfig::CONFIG['host_os'] =~ /hpux/i
171
158
 
172
- if RbConfig::CONFIG['host_os'] =~ /linux/i
173
- struct[:domainname] = utsname[:domainname].to_s
174
- end
159
+ struct[:domainname] = utsname[:domainname].to_s if RbConfig::CONFIG['host_os'] =~ /linux/i
175
160
 
176
161
  # Let's add a members method that works for testing and compatibility
177
162
  if struct.members.nil?
178
- struct.instance_eval(%Q{
163
+ struct.instance_eval <<-RUBY, __FILE__, __LINE__ + 1
179
164
  def members
180
- @table.keys.map{ |k| k.to_s }
165
+ @table.keys.map(&:to_s)
181
166
  end
182
- })
167
+ RUBY
183
168
  end
184
169
 
185
170
  struct.freeze