sys-admin 1.8.0-universal-mingw32 → 1.8.1-universal-mingw32

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: da216caeef1d2038bbbeace7ed087e6835ec210870a34f89653945ffa2245b72
4
- data.tar.gz: 7c36e9ed782cb6be87cdc69cd94ff3c06894afb96cc54fa3db1af06fa48499dc
3
+ metadata.gz: 8f6b5f7c944fab6ef6ff02952eb74ec5e7fe5d5367cd85d10e82c1ece2340d6e
4
+ data.tar.gz: 1bec59ee54b35d84e1e46fc60bfa857ba4cf621796c223d1334cd84801080be6
5
5
  SHA512:
6
- metadata.gz: 6ad2079f20c0d05e4d9d6efac82e560d88f6c78a248131135c7e1455ef02d84bbf0dc628a5913a21689c888be614f5b30b7ce4ab61c63bb9a77c6c44a174420c
7
- data.tar.gz: b564a7e2cf651b86ecb08084b13813a33ac199707292fc56f7b3daad770cdd150358b7110dfb53c2913864ebb5d9ec25f1bcac30828c140748fcabfc59f8152f
6
+ metadata.gz: 5227fe5b8f35b3cef57b1cef90536ddff04d57bffb7ba3bc5e947a7feee78ebeb71204e1ec183bc7504aff2cf2c6779c20fef6c638a5325a2901fe1f2d6e24e7
7
+ data.tar.gz: 107ccc687e75a472945104e58bd9ac1afcaac0d58fb64d1303673f0f5d29d47329cae4801a7011080dd4d655cefe245ea1c43f37554c46d7a5621220d0043cbd
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,9 +1,15 @@
1
+ ## 1.8.1 - 25-Sep-2021
2
+ * The users and get_user methods on Darwin now take an optional :lastlog key
3
+ that you can set to false in order to significantly speed up those methods
4
+ at the expense of taking away lastlog information.
5
+ * Some internal rspec refactoring.
6
+
1
7
  ## 1.8.0 - 26-Aug-2021
2
8
  * Switched from test-unit to rspec, with some tests refactored. The Rakefile
3
9
  and gemspec files were updated accordingly.
4
10
  * The User and Group classes for the Windows implementation are now properly
5
11
  scoped under Sys::Admin instead of just Sys.
6
- * Fixed a bug in the get_user and get_group methods on Winodws where the WQL
12
+ * Fixed a bug in the get_user and get_group methods on Windows where the WQL
7
13
  it generates internally might not be correct.
8
14
 
9
15
  ## 1.7.6 - 24-Mar-2021
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Ruby](https://github.com/djberg96/sys-admin/actions/workflows/ruby.yml/badge.svg)](https://github.com/djberg96/sys-admin/actions/workflows/ruby.yml)
2
+
1
3
  ## Description
2
4
  The sys-admin library is a unified, cross platform replacement for the Etc module.
3
5
 
data/Rakefile CHANGED
@@ -23,7 +23,6 @@ end
23
23
 
24
24
  desc "Run the specs for the sys-admin library"
25
25
  RSpec::Core::RakeTask.new(:spec) do |t|
26
- t.pattern = 'spec/sys_admin_unix_spec.rb'
27
26
  case RbConfig::CONFIG['host_os']
28
27
  when /darwin|osx/i
29
28
  t.rspec_opts = '-Ilib/darwin'
@@ -35,7 +34,6 @@ RSpec::Core::RakeTask.new(:spec) do |t|
35
34
  t.rspec_opts = '-Ilib/bsd'
36
35
  when /windows|win32|mingw|cygwin|dos/i
37
36
  t.rspec_opts = '-Ilib/windows'
38
- t.pattern = 'spec/sys_admin_windows_spec.rb'
39
37
  else
40
38
  t.rspec_opts = '-Ilib/unix'
41
39
  end
@@ -80,8 +80,12 @@ module Sys
80
80
  #
81
81
  # Sys::Admin.get_user('joe')
82
82
  # Sys::Admin.get_user(501)
83
+ # Sys::Admin.get_user('joe', :lastlog => false) # Less info but faster
83
84
  #
84
- def self.get_user(uid)
85
+ # Set the :lastlog option to false if you want to ignore lastlog
86
+ # information and speed this method up considerably.
87
+ #
88
+ def self.get_user(uid, options = {})
85
89
  buf = FFI::MemoryPointer.new(:char, 1024)
86
90
  pbuf = FFI::MemoryPointer.new(PasswdStruct)
87
91
  temp = PasswdStruct.new
@@ -103,7 +107,7 @@ module Sys
103
107
  end
104
108
 
105
109
  pwd = PasswdStruct.new(ptr)
106
- get_user_from_struct(pwd)
110
+ get_user_from_struct(pwd, options)
107
111
  end
108
112
 
109
113
  # Returns a Group object for the given name or uid. Raises an error
@@ -148,11 +152,19 @@ module Sys
148
152
 
149
153
  # Returns an array of User objects for each user on the system.
150
154
  #
155
+ # Examples:
156
+ #
157
+ # Sys::Admin.users
158
+ # Sys::Admin.users(:lastlog => false) # Less info but faster
159
+ #
160
+ # Note that on Darwin this method can be very slow. If you want to
161
+ # speed it up considerably by ignoring lastlog information then set
162
+ # the :lastlog option to false as part of the +options+ hash.
151
163
  #--
152
164
  # This method is somewhat slow on OSX because of the call to get
153
165
  # lastlog information. I'm not sure why.
154
166
  #
155
- def self.users
167
+ def self.users(options = {})
156
168
  users = []
157
169
 
158
170
  begin
@@ -160,7 +172,7 @@ module Sys
160
172
 
161
173
  until (ptr = getpwent()).null?
162
174
  pwd = PasswdStruct.new(ptr)
163
- users << get_user_from_struct(pwd)
175
+ users << get_user_from_struct(pwd, options)
164
176
  end
165
177
  ensure
166
178
  endpwent()
@@ -201,7 +213,7 @@ module Sys
201
213
  private_class_method :get_group_from_struct
202
214
 
203
215
  # Takes a UserStruct and converts it to a User object.
204
- def self.get_user_from_struct(pwd)
216
+ def self.get_user_from_struct(pwd, options)
205
217
  user = User.new do |u|
206
218
  u.name = pwd[:pw_name]
207
219
  u.passwd = pwd[:pw_passwd]
@@ -215,12 +227,14 @@ module Sys
215
227
  u.expire = Time.at(pwd[:pw_expire])
216
228
  end
217
229
 
218
- log = get_lastlog_info(user.uid)
230
+ unless options[:lastlog] == false
231
+ log = get_lastlog_info(user.uid)
219
232
 
220
- if log
221
- user.login_time = Time.at(log[:tv_sec])
222
- user.login_device = log[:ll_line].to_s
223
- user.login_host = log[:ll_host].to_s
233
+ if log
234
+ user.login_time = Time.at(log[:tv_sec])
235
+ user.login_device = log[:ll_line].to_s
236
+ user.login_host = log[:ll_host].to_s
237
+ end
224
238
  end
225
239
 
226
240
  user
data/lib/sys/admin.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Sys
2
2
  class Admin
3
3
  # The version of the sys-admin library.
4
- VERSION = '1.8.0'.freeze
4
+ VERSION = '1.8.1'.freeze
5
5
  end
6
6
  end
7
7
 
@@ -0,0 +1,13 @@
1
+ require 'rspec'
2
+ require 'sys-admin'
3
+
4
+ RSpec.configure do |config|
5
+ config.filter_run_excluding(:darwin) if Gem::Platform.local.os != 'darwin'
6
+ config.filter_run_excluding(:windows) unless Gem.win_platform?
7
+
8
+ if Gem.win_platform?
9
+ config.filter_run_excluding(:unix)
10
+ require 'win32-security'
11
+ require 'socket'
12
+ end
13
+ end
@@ -4,8 +4,7 @@
4
4
  # Test suite for the Unix version of sys-admin. This test should be run
5
5
  # via the 'rake spec' task.
6
6
  ###############################################################################
7
- require 'rspec'
8
- require 'sys/admin'
7
+ require 'spec_helper'
9
8
 
10
9
  RSpec.describe Sys::Admin, :unix do
11
10
  let(:user) { 'nobody' }
@@ -41,9 +40,8 @@ RSpec.describe Sys::Admin, :unix do
41
40
  expect(described_class.get_user(user_id)).to be_kind_of(Sys::Admin::User)
42
41
  end
43
42
 
44
- example "get_user requires one argument only" do
43
+ example "get_user requires at least one argument" do
45
44
  expect{ described_class.get_user }.to raise_error(ArgumentError)
46
- expect{ described_class.get_user(user, user) }.to raise_error(ArgumentError)
47
45
  end
48
46
 
49
47
  example "get_user requires a string or integer argument" do
@@ -67,8 +65,11 @@ RSpec.describe Sys::Admin, :unix do
67
65
  expect(users).to all(be_kind_of(Sys::Admin::User))
68
66
  end
69
67
 
70
- example "users does not accept any arguments" do
71
- expect{ described_class.users(user_id) }.to raise_error(ArgumentError)
68
+ example "users accepts an optional lastlog argument on darwin", :darwin => true do
69
+ users = described_class.users(:lastlog => false)
70
+ expect(users).to be_kind_of(Array)
71
+ expect(users).to all(be_kind_of(Sys::Admin::User))
72
+ expect(users.first.login_time).to be_nil
72
73
  end
73
74
  end
74
75
 
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Sys::Admin do
4
+ example "version is set to expected value" do
5
+ expect(described_class::VERSION).to eq('1.8.1')
6
+ end
7
+
8
+ example "version constant is frozen" do
9
+ expect(described_class::VERSION).to be_frozen
10
+ end
11
+ end
@@ -7,10 +7,7 @@
7
7
  #
8
8
  # It is assumed that these specs will be run via the 'rake spec' task.
9
9
  ###############################################################################
10
- require 'rspec'
11
- require 'sys/admin'
12
- require 'win32/security'
13
- require 'socket'
10
+ require 'spec_helper'
14
11
 
15
12
  RSpec.describe Sys::Admin, :windows do
16
13
  let(:host) { Socket.gethostname }
data/sys-admin.gemspec CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'sys-admin'
6
- spec.version = '1.8.0'
6
+ spec.version = '1.8.1'
7
7
  spec.author = 'Daniel J. Berger'
8
8
  spec.license = 'Apache-2.0'
9
9
  spec.email = 'djberg96@gmail.com'
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.8.1
5
5
  platform: universal-mingw32
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -35,7 +35,7 @@ cert_chain:
35
35
  ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
36
  WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
37
37
  -----END CERTIFICATE-----
38
- date: 2021-08-26 00:00:00.000000000 Z
38
+ date: 2021-09-25 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: ffi
@@ -125,7 +125,9 @@ files:
125
125
  - lib/sys/admin/custom.rb
126
126
  - lib/unix/sys/admin.rb
127
127
  - lib/windows/sys/admin.rb
128
+ - spec/spec_helper.rb
128
129
  - spec/sys_admin_unix_spec.rb
130
+ - spec/sys_admin_version_spec.rb
129
131
  - spec/sys_admin_windows_spec.rb
130
132
  - sys-admin.gemspec
131
133
  homepage: http://www.github.com/djberg96/sys-admin
@@ -158,5 +160,7 @@ signing_key:
158
160
  specification_version: 4
159
161
  summary: A unified, cross platform replacement for the "etc" library.
160
162
  test_files:
163
+ - spec/spec_helper.rb
161
164
  - spec/sys_admin_unix_spec.rb
165
+ - spec/sys_admin_version_spec.rb
162
166
  - spec/sys_admin_windows_spec.rb
metadata.gz.sig CHANGED
Binary file