sys-admin 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,10 @@
1
+ == 1.5.3 - 6-Oct-2010
2
+ * Refactored the Rakefile. The old installation tasks have been replaced
3
+ with gem build and install tasks. In addition, the platform handling has
4
+ been updated for MS Windows.
5
+ * Portions of the gemspec have been moved into the Rakefile gem tasks.
6
+ * Deploying the mingw gem by default for MS Windows now.
7
+
1
8
  == 1.5.2 - 2-Aug-2009
2
9
  * Now compatible with Ruby 1.9.x.
3
10
  * Added test-unit as a development dependency.
data/README CHANGED
@@ -1,161 +1,156 @@
1
1
  == Description
2
- The sys-admin library is a unified, cross platform replacement for the
3
- Etc module.
2
+ The sys-admin library is a unified, cross platform replacement for the Etc module.
4
3
 
5
4
  == Installation
6
- = Typical Gem Installation
7
- gem install sys-admin
8
- = Local installation
9
- rake test (optional)
10
- rake install
5
+ gem install sys-admin
11
6
 
12
7
  == Synopsis
13
- require 'sys/admin'
14
- include Sys
8
+ require 'sys/admin'
9
+ include Sys
15
10
 
16
- # Yields a User object for each user
17
- Admin.users{ |user|
18
- p user
19
- }
11
+ # Yields a User object for each user
12
+ Admin.users{ |user|
13
+ p user
14
+ }
20
15
 
21
- # Returns an Array of User objects
22
- a = Admin.users
16
+ # Returns an Array of User objects
17
+ a = Admin.users
23
18
 
24
- # Yields a Group object for each group
25
- Admin.groups{ |group|
26
- p group
27
- }
19
+ # Yields a Group object for each group
20
+ Admin.groups{ |group|
21
+ p group
22
+ }
28
23
 
29
- # Returns an Array of Group objects
30
- g = Admin.groups
24
+ # Returns an Array of Group objects
25
+ g = Admin.groups
31
26
 
32
- # Get information about a particular user
33
- p Admin.get_user("nobody")
27
+ # Get information about a particular user
28
+ p Admin.get_user("nobody")
34
29
 
35
- # Get information about a particular group
36
- p Admin.get_group("adm")
30
+ # Get information about a particular group
31
+ p Admin.get_group("adm")
37
32
 
38
33
  == Admin
39
34
  Admin.get_login
40
- Returns the user name (only) of the current login.
35
+ Returns the user name (only) of the current login.
41
36
 
42
37
  Admin.get_user(name, options = {})
43
38
  Admin.get_user(uid, options = {})
44
- Returns a User object based on +name+ or +uid+. The +options+ hash is
45
- for MS Windows only, and allows you to restrict the search based on the
46
- options you provide, e.g. 'domain' or 'localaccount'.
39
+ Returns a User object based on +name+ or +uid+. The +options+ hash is
40
+ for MS Windows only, and allows you to restrict the search based on the
41
+ options you provide, e.g. 'domain' or 'localaccount'.
47
42
 
48
43
  Admin.get_group(name, options = {})
49
44
  Admin.get_group(gid, options = {})
50
- Returns a Group object based on +name+ or +uid+. The +options+ hash is
51
- for MS Windows only, and allows you to restrict the search based on the
52
- options you provide, e.g. 'domain' or 'localaccount'.
45
+ Returns a Group object based on +name+ or +uid+. The +options+ hash is
46
+ for MS Windows only, and allows you to restrict the search based on the
47
+ options you provide, e.g. 'domain' or 'localaccount'.
53
48
 
54
49
  Admin.groups(options = {})
55
50
  Admin.groups(options = {}){ |group| ... }
56
- In block form, yields a Group object for each user on the system. In
57
- non-block form, returns an Array of Group objects.
51
+ In block form, yields a Group object for each user on the system. In
52
+ non-block form, returns an Array of Group objects.
58
53
 
59
- The +options+ hash is for MS Windows only, and allows you to restrict the
60
- search based on the options you provide, e.g. 'domain' or 'localaccount'.
54
+ The +options+ hash is for MS Windows only, and allows you to restrict the
55
+ search based on the options you provide, e.g. 'domain' or 'localaccount'.
61
56
 
62
57
  Admin.users(options = {})
63
58
  Admin.users(options = {}){ |user| ... }
64
- In block form, yields a User object for each user on the system. In
65
- non-block form, returns an Array of User objects.
59
+ In block form, yields a User object for each user on the system. In
60
+ non-block form, returns an Array of User objects.
66
61
 
67
- The +options+ hash is for MS Windows only, and allows you to restrict the
68
- search based on the options you provide, e.g. 'domain' or 'localaccount'.
62
+ The +options+ hash is for MS Windows only, and allows you to restrict the
63
+ search based on the options you provide, e.g. 'domain' or 'localaccount'.
69
64
 
70
65
  == User class
71
66
  === User (Windows)
72
- The User class has the following attributes on MS Windows systems:
67
+ The User class has the following attributes on MS Windows systems:
73
68
 
74
- * account_type
75
- * caption
76
- * description
77
- * domain
78
- * password
79
- * full_name
80
- * install_date
81
- * name
82
- * sid
83
- * status
84
- * disabled?
85
- * local?
86
- * lockout?
87
- * password_changeable?
88
- * password_expires?
89
- * password_required?
69
+ * account_type
70
+ * caption
71
+ * description
72
+ * domain
73
+ * password
74
+ * full_name
75
+ * install_date
76
+ * name
77
+ * sid
78
+ * status
79
+ * disabled?
80
+ * local?
81
+ * lockout?
82
+ * password_changeable?
83
+ * password_expires?
84
+ * password_required?
90
85
 
91
86
  === User (Unix)
92
- The User class has the following attributes on Unix systems:
87
+ The User class has the following attributes on Unix systems:
93
88
 
94
- * name
95
- * passwd
96
- * uid
97
- * gid
98
- * dir
99
- * shell
100
- * gecos
101
- * quota
102
- * age
103
- * class
104
- * comment
105
- * change
106
- * expire
89
+ * name
90
+ * passwd
91
+ * uid
92
+ * gid
93
+ * dir
94
+ * shell
95
+ * gecos
96
+ * quota
97
+ * age
98
+ * class
99
+ * comment
100
+ * change
101
+ * expire
107
102
 
108
103
  == Group Classes
109
104
  === Group (Windows)
110
- The Group class has the following attributes on MS Windows systems:
105
+ The Group class has the following attributes on MS Windows systems:
111
106
 
112
- * caption
113
- * description
114
- * domain
115
- * install_date
116
- * name
117
- * sid
118
- * status
119
- * gid
120
- * local?
107
+ * caption
108
+ * description
109
+ * domain
110
+ * install_date
111
+ * name
112
+ * sid
113
+ * status
114
+ * gid
115
+ * local?
121
116
 
122
117
  === Group (Unix)
123
- The Group class has the following attributes on Unix systems:
118
+ The Group class has the following attributes on Unix systems:
124
119
 
125
- * name
126
- * gid
127
- * members
128
- * passwd
120
+ * name
121
+ * gid
122
+ * members
123
+ * passwd
129
124
 
130
125
  == Error Classes
131
126
  Admin::Error < StandardError
132
- Raised if anything goes wrong with any of the above methods.
127
+ Raised if anything goes wrong with any of the above methods.
133
128
 
134
129
  == Developer's Notes
135
130
  === MS Windows
136
- The Windows version now uses a win32ole + WMI approach to getting
137
- information. This means that the WMI service must be running on the
138
- target machine in order to work (which it is, by default).
131
+ The Windows version now uses a win32ole + WMI approach to getting
132
+ information. This means that the WMI service must be running on the
133
+ target machine in order to work (which it is, by default).
139
134
 
140
135
  === UNIX
141
- The underlying implementation is similar to core Ruby's Etc implementation.
142
- But, in addition to the different interface, I use the re-entrant version
143
- of the appropriate functions when available.
136
+ The underlying implementation is similar to core Ruby's Etc implementation.
137
+ But, in addition to the different interface, I use the re-entrant version
138
+ of the appropriate functions when available.
144
139
 
145
140
  == Future Plans
146
- Make the User and Group objects comparable.
147
- Add ability to add, configure and delete users on Unix platforms.
141
+ Make the User and Group objects comparable.
142
+ Add ability to add, configure and delete users on Unix platforms.
148
143
 
149
144
  == Known Bugs
150
- None that I'm aware of. If you find any, please log them on the project
151
- page at http://www.rubyforge.org/projects/sysutils.
145
+ None that I'm aware of. If you find any, please log them on the project
146
+ page at http://www.rubyforge.org/projects/sysutils.
152
147
 
153
148
  == License
154
- Artistic 2.0
149
+ Artistic 2.0
155
150
 
156
151
  == Copyright
157
- (C) 2005-2009, Daniel J. Berger
158
- All Rights Reserved
152
+ (C) 2005-2010, Daniel J. Berger
153
+ All Rights Reserved
159
154
 
160
155
  == Author
161
- Daniel J. Berger
156
+ Daniel J. Berger
data/Rakefile CHANGED
@@ -2,60 +2,73 @@ require 'rake'
2
2
  require 'rake/clean'
3
3
  require 'rake/testtask'
4
4
  require 'rbconfig'
5
- include Config
5
+
6
+ WINDOWS = Config::CONFIG['host_os'] =~ /msdos|mswin|win32|mingw|cygwin/i
6
7
 
7
8
  desc "Clean the build files for the sys-admin source for UNIX systems"
8
9
  task :clean do
9
- Dir.chdir('ext') do
10
- unless RUBY_PLATFORM.match('mswin')
11
- build_file = 'admin.' + Config::CONFIG['DLEXT']
12
- sh 'make distclean' if File.exists?(build_file)
13
- File.delete("sys/#{build_file}") if File.exists?("sys/#{build_file}")
14
- end
15
- end
10
+ Dir['*.gem'].each{ |f| File.delete(f) } # Remove any .gem files
11
+ unless WINDOWS
12
+ Dir.chdir('ext') do
13
+ build_file = 'admin.' + Config::CONFIG['DLEXT']
14
+ sh 'make distclean' if File.exists?(build_file)
15
+ File.delete("sys/#{build_file}") if File.exists?("sys/#{build_file}")
16
+ end
17
+ end
16
18
  end
17
19
 
18
- desc "Build the sys-admin package on UNIX systems (but don't install it)"
20
+ desc "Build the sys-admin library on UNIX systems (but don't install it)"
19
21
  task :build => [:clean] do
20
- Dir.chdir('ext') do
21
- unless RUBY_PLATFORM.match('mswin')
22
- ruby 'extconf.rb'
23
- sh 'make'
24
- build_file = 'admin.' + Config::CONFIG['DLEXT']
25
- FileUtils.cp(build_file, 'sys')
26
- end
27
- end
22
+ unless WINDOWS
23
+ Dir.chdir('ext') do
24
+ ruby 'extconf.rb'
25
+ sh 'make'
26
+ build_file = 'admin.' + Config::CONFIG['DLEXT']
27
+ FileUtils.cp(build_file, 'sys')
28
+ end
29
+ end
28
30
  end
29
31
 
30
- if RUBY_PLATFORM.match('mswin')
31
- desc "Install the sys-admin package for MS Windows"
32
- task :install do
33
- install_dir = File.join(CONFIG['sitelibdir'], 'sys')
34
- Dir.mkdir(install_dir) unless File.exists?(install_dir)
35
- FileUtils.cp('lib/sys/admin.rb', install_dir, :verbose => true)
36
- end
37
- else
38
- desc "Install the sys-admin package for Unix platforms"
39
- task :install => [:build] do
40
- Dir.chdir('ext') do
41
- sh 'make install'
42
- end
43
- end
32
+ namespace :gem do
33
+ desc "Create a sys-admin gem file."
34
+ task :create => [:clean] do
35
+ spec = eval(IO.read('sys-admin.gemspec'))
36
+
37
+ if WINDOWS
38
+ spec.platform = Gem::Platform::CURRENT
39
+ spec.files = spec.files.reject{ |f| f.include?('ext') }
40
+ spec.add_dependency('win32-security', '>= 0.1.2')
41
+ else
42
+ spec.files = spec.files.reject{ |f| f.include?('lib') }
43
+ spec.extensions = ['ext/extconf.rb']
44
+ spec.extra_rdoc_files << 'ext/sys/admin.c'
45
+ end
46
+
47
+ Gem::Builder.new(spec).build
48
+ end
49
+
50
+ desc "Install the sys-admin gem."
51
+ task :install => [:create] do
52
+ gem = Dir['*.gem'].first
53
+ sh "gem install #{gem}"
54
+ end
44
55
  end
45
56
 
46
57
  desc "Run the test suite"
47
- Rake::TestTask.new("test") do |t|
48
- if RUBY_PLATFORM.match('mswin')
49
- t.libs << 'lib'
50
- else
51
- task :test => :build
52
- t.libs << 'ext'
53
- t.libs.delete('lib')
54
- end
55
- t.libs << 'test'
56
- t.test_files = FileList['test/test_sys_admin.rb']
58
+ Rake::TestTask.new('test') do |t|
59
+ if WINDOWS
60
+ t.libs << 'lib'
61
+ else
62
+ task :test => :build
63
+ t.libs << 'ext'
64
+ t.libs.delete('lib')
65
+ end
66
+ t.libs << 'test'
67
+ t.test_files = FileList['test/test_sys_admin.rb']
57
68
  end
58
69
 
59
70
  task :test do
60
- Rake.application[:clean].execute
71
+ Rake.application[:clean].execute
61
72
  end
73
+
74
+ task :default => :test
data/ext/sys/admin.h CHANGED
@@ -8,7 +8,7 @@
8
8
  #include <errno.h>
9
9
  #include <string.h>
10
10
 
11
- #define SYS_ADMIN_VERSION "1.5.2"
11
+ #define SYS_ADMIN_VERSION "1.5.3"
12
12
 
13
13
  #if defined(__MACH__) || defined(__APPLE__)
14
14
  #define __BSD__
@@ -69,32 +69,32 @@ VALUE cUser, cGroup, cAdminError;
69
69
  * Helper function that returns a User object based on user ID.
70
70
  */
71
71
  static VALUE get_user_by_num(VALUE v_uid){
72
- volatile VALUE v_user;
73
- uid_t uid = NUM2INT(v_uid);
72
+ volatile VALUE v_user;
73
+ uid_t uid = NUM2INT(v_uid);
74
74
 
75
75
  #ifdef HAVE_GETPWUID_R
76
- char buf[USER_BUF_SIZE];
77
- struct passwd pwd;
78
- struct passwd* pwdbuf;
76
+ char buf[USER_BUF_SIZE];
77
+ struct passwd pwd;
78
+ struct passwd* pwdbuf;
79
79
 
80
- if(getpwuid_r(uid, &pwd, buf, sizeof(buf), &pwdbuf) != 0)
81
- rb_raise(cAdminError, "%s", strerror(errno));
80
+ if(getpwuid_r(uid, &pwd, buf, sizeof(buf), &pwdbuf) != 0)
81
+ rb_raise(cAdminError, "%s", strerror(errno));
82
82
 
83
- if(!pwdbuf)
84
- rb_raise(cAdminError, "no user found for %i:", uid);
83
+ if(!pwdbuf)
84
+ rb_raise(cAdminError, "no user found for %i:", uid);
85
85
 
86
- v_user = get_user(pwdbuf);
86
+ v_user = get_user(pwdbuf);
87
87
  #elif HAVE_GETPWUID
88
- struct passwd* pwd;
89
- if( (pwd = getpwuid(uid)) == NULL)
90
- rb_raise(cAdminError, "no user found for: %i", uid);
88
+ struct passwd* pwd;
89
+ if( (pwd = getpwuid(uid)) == NULL)
90
+ rb_raise(cAdminError, "no user found for: %i", uid);
91
91
 
92
- v_user = get_user(pwd);
92
+ v_user = get_user(pwd);
93
93
  #else
94
- rb_raise(rb_eNotImpError, "getting user by user ID not supported");
94
+ rb_raise(rb_eNotImpError, "getting user by user ID not supported");
95
95
  #endif
96
96
 
97
- return v_user;
97
+ return v_user;
98
98
  }
99
99
 
100
100
  /*
@@ -459,8 +459,8 @@ int get_lastlog_info(struct passwd* pwd, VALUE v_user){
459
459
  * that endpwent() is called in the block form of Admin.groups.
460
460
  */
461
461
  static VALUE admin_groups_cleanup(){
462
- endgrent();
463
- return Qnil;
462
+ endgrent();
463
+ return Qnil;
464
464
  }
465
465
 
466
466
  /*
@@ -470,6 +470,6 @@ static VALUE admin_groups_cleanup(){
470
470
  * that endpwent() is called in the block form of Admin.users.
471
471
  */
472
472
  static VALUE admin_users_cleanup(){
473
- endpwent();
474
- return Qnil;
473
+ endpwent();
474
+ return Qnil;
475
475
  }
data/sys-admin.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+
3
+ # Do not use this file directly. Build the gem via the Rake tasks.
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'sys-admin'
7
+ spec.version = '1.5.3'
8
+ spec.author = 'Daniel J. Berger'
9
+ spec.license = 'Artistic 2.0'
10
+ spec.email = 'djberg96@gmail.com'
11
+ spec.homepage = 'http://www.github.com/djberg96/sysutils'
12
+ spec.summary = 'A unified, cross platform replacement for the "etc" library.'
13
+ spec.test_file = 'test/test_sys_admin.rb'
14
+ spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
15
+
16
+ spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST']
17
+ spec.rubyforge_project = 'sysutils'
18
+
19
+ spec.add_development_dependency('test-unit', '>= 2.1.1')
20
+
21
+ spec.description = <<-EOF
22
+ The sys-admin library is a unified, cross platform replacement for the
23
+ 'etc' library that ships as part of the Ruby standard library. It
24
+ provides a common interface for all platforms, including MS Windows. In
25
+ addition, it provides an interface for adding, deleting and configuring
26
+ users on MS Windows.
27
+ EOF
28
+ end
@@ -9,13 +9,13 @@ gem 'test-unit'
9
9
  require 'test/unit'
10
10
 
11
11
  if File::ALT_SEPARATOR
12
- require 'test_sys_admin_windows'
12
+ require 'test_sys_admin_windows'
13
13
  else
14
- require 'test_sys_admin_unix'
14
+ require 'test_sys_admin_unix'
15
15
  end
16
16
 
17
17
  class TC_Sys_Admin_All < Test::Unit::TestCase
18
- def test_version
19
- assert_equal('1.5.2', Sys::Admin::VERSION)
20
- end
18
+ def test_version
19
+ assert_equal('1.5.3', Sys::Admin::VERSION)
20
+ end
21
21
  end
@@ -9,238 +9,237 @@ require 'sys/admin'
9
9
  include Sys
10
10
 
11
11
  class TC_Sys_Admin_Unix < Test::Unit::TestCase
12
- def setup
13
- @user = 'nobody'
14
- @user_id = 0
15
-
16
- @group = 'sys'
17
- @group_id = 3
18
- end
19
-
20
- ## Admin singleton methods
21
-
22
- def test_get_login
23
- assert_respond_to(Admin, :get_login)
24
- assert_nothing_raised{ Admin.get_login }
25
- assert_kind_of(String, Admin.get_login)
26
- end
27
-
28
- def test_get_user_basic
29
- assert_respond_to(Admin, :get_user)
30
- assert_nothing_raised{ Admin.get_user(@user) }
31
- assert_nothing_raised{ Admin.get_user(@user_id) }
32
- end
33
-
34
- def test_get_user_by_name
35
- assert_kind_of(User, Admin.get_user(@user))
36
- end
37
-
38
- def test_get_user_by_id
39
- assert_kind_of(User, Admin.get_user(@user_id))
40
- end
41
-
42
- def test_get_user_expected_errors
43
- assert_raise(ArgumentError){ Admin.get_user }
44
- assert_raise(TypeError){ Admin.get_user([]) }
45
- assert_raise(Admin::Error){ Admin.get_user('foofoofoo') }
46
- end
47
-
48
- def test_users_basic
49
- assert_respond_to(Admin, :users)
50
- assert_nothing_raised{ Admin.users }
51
- end
52
-
53
- def test_users
54
- assert_kind_of(Array, Admin.users)
55
- assert_kind_of(User, Admin.users.first)
56
- end
57
-
58
- def test_users_block_form
59
- array = []
60
- assert_nothing_raised{ Admin.users{ |g| array << g } }
61
- assert_equal(true, Admin.users.length == array.length)
62
- assert_nothing_raised{ Admin.users{ |g| break } }
63
- end
64
-
65
- def test_users_expected_errors
66
- assert_raise(ArgumentError){ Admin.users(@user_id) }
67
- end
68
-
69
- def test_get_group_basic
70
- assert_respond_to(Admin, :get_group)
71
- assert_nothing_raised{ Admin.get_group(@group) }
72
- assert_nothing_raised{ Admin.get_group(@group_id) }
73
- end
74
-
75
- def test_get_group_by_name
76
- assert_kind_of(Group, Admin.get_group(@group))
77
- end
78
-
79
- def test_get_group_by_id
80
- assert_kind_of(Group, Admin.get_group(@group_id))
81
- end
82
-
83
- def test_get_group_expected_errors
84
- assert_raise(ArgumentError){ Admin.get_group }
85
- assert_raise(TypeError){ Admin.get_group([]) }
86
- assert_raise(Admin::Error){ Admin.get_group('foofoofoo') }
87
- end
88
-
89
- def test_groups_basic
90
- assert_respond_to(Admin, :groups)
91
- assert_nothing_raised{ Admin.groups }
92
- end
93
-
94
- def test_groups
95
- assert_kind_of(Array, Admin.groups)
96
- assert_kind_of(Group, Admin.groups.first)
97
- end
98
-
99
- def test_groups_expected_errors
100
- assert_raise(ArgumentError){ Admin.groups(@group_id) }
101
- end
102
-
103
- def test_groups_block_form
104
- array = []
105
- assert_nothing_raised{ Admin.groups{ |g| array << g } }
106
- assert_equal(true, Admin.groups.length == array.length)
107
- assert_nothing_raised{ Admin.groups{ |g| break } }
108
- end
109
-
110
- ## User Tests
111
-
112
- def test_user_name
113
- @user = Admin.users.first
114
- assert_respond_to(@user, :name)
115
- assert_kind_of(String, @user.name)
116
- end
117
-
118
- def test_user_passwd
119
- @user = Admin.users.first
120
- assert_respond_to(@user, :passwd)
121
- assert_kind_of(String, @user.passwd)
122
- end
123
-
124
- def test_user_uid
125
- @user = Admin.users.first
126
- assert_respond_to(@user, :uid)
127
- assert_kind_of(Fixnum, @user.uid)
128
- end
129
-
130
- def test_user_gid
131
- @user = Admin.users.first
132
- assert_respond_to(@user, :gid)
133
- assert_kind_of(Fixnum, @user.gid)
134
- end
135
-
136
- def test_user_dir
137
- @user = Admin.users.first
138
- assert_respond_to(@user, :dir)
139
- assert_kind_of(String, @user.dir)
140
- end
141
-
142
- def test_user_shell
143
- @user = Admin.users.first
144
- assert_respond_to(@user, :shell)
145
- assert_kind_of(String, @user.shell)
146
- end
147
-
148
- def test_user_gecos
149
- @user = Admin.users.first
150
- assert_respond_to(@user, :gecos)
151
- assert_kind_of(String, @user.gecos)
152
- end
153
-
154
- def test_user_quota
155
- @user = Admin.users.first
156
- assert_respond_to(@user, :quota)
157
- assert_true([Fixnum, NilClass].include?(@user.quota.class))
158
- end
159
-
160
- def test_user_age
161
- @user = Admin.users.first
162
- assert_respond_to(@user, :age)
163
- assert_true([Fixnum, NilClass].include?(@user.age.class))
164
- end
165
-
166
- def test_user_access_class
167
- @user = Admin.users.first
168
- assert_respond_to(@user, :access_class)
169
- assert_true([String, NilClass].include?(@user.access_class.class))
170
- end
171
-
172
- def test_user_comment
173
- @user = Admin.users.first
174
- assert_respond_to(@user, :comment)
175
- assert_true([String, NilClass].include?(@user.comment.class))
176
- end
177
-
178
- def test_user_expire
179
- @user = Admin.users.first
180
- assert_respond_to(@user, :expire)
181
- assert_true([Time, NilClass].include?(@user.expire.class))
182
- end
183
-
184
- def test_user_change
185
- @user = Admin.users.first
186
- assert_respond_to(@user, :change)
187
- assert_true([Time, NilClass].include?(@user.change.class))
188
- end
189
-
190
- def test_user_login_time
191
- @user = Admin.users.first
192
- assert_respond_to(@user, :login_time)
193
- assert_true([Time, NilClass].include?(@user.login_time.class))
194
- end
195
-
196
- def test_user_login_device
197
- @user = Admin.users.first
198
- assert_respond_to(@user, :login_device)
199
- assert_true([String, NilClass].include?(@user.login_device.class))
200
- end
201
-
202
- def test_user_login_host
203
- @user = Admin.users.first
204
- assert_respond_to(@user, :login_host)
205
- assert_true([String, NilClass].include?(@user.login_host.class))
206
- end
207
-
208
- def test_user_groups
209
- @user = Admin.users.first
210
- assert_respond_to(@user, :groups)
211
- assert_kind_of(Array, @user.groups)
212
- end
213
-
214
- ## Group Tests
215
-
216
- def test_group_name
217
- @group = Admin.groups.first
218
- assert_respond_to(@group, :name)
219
- assert_kind_of(String, @group.name)
220
- end
221
-
222
- def test_group_gid
223
- @group = Admin.groups.first
224
- assert_respond_to(@group, :gid)
225
- assert_kind_of(Fixnum, @group.gid)
226
- end
227
-
228
- def test_group_members
229
- @group = Admin.groups.first
230
- assert_respond_to(@group, :members)
231
- assert_kind_of(Array, @group.members)
232
- end
233
-
234
- def test_group_passwd
235
- @group = Admin.groups.first
236
- assert_respond_to(@group, :passwd)
237
- assert_kind_of(String, @group.passwd)
238
- end
239
-
240
- def teardown
241
- @user = nil
242
- @user_id = nil
243
- @group = nil
244
- @group_id = nil
245
- end
12
+ def setup
13
+ @user = 'nobody'
14
+ @user_id = 0
15
+ @group = 'sys'
16
+ @group_id = 3
17
+ end
18
+
19
+ ## Admin singleton methods
20
+
21
+ def test_get_login
22
+ assert_respond_to(Admin, :get_login)
23
+ assert_nothing_raised{ Admin.get_login }
24
+ assert_kind_of(String, Admin.get_login)
25
+ end
26
+
27
+ def test_get_user_basic
28
+ assert_respond_to(Admin, :get_user)
29
+ assert_nothing_raised{ Admin.get_user(@user) }
30
+ assert_nothing_raised{ Admin.get_user(@user_id) }
31
+ end
32
+
33
+ def test_get_user_by_name
34
+ assert_kind_of(User, Admin.get_user(@user))
35
+ end
36
+
37
+ def test_get_user_by_id
38
+ assert_kind_of(User, Admin.get_user(@user_id))
39
+ end
40
+
41
+ def test_get_user_expected_errors
42
+ assert_raise(ArgumentError){ Admin.get_user }
43
+ assert_raise(TypeError){ Admin.get_user([]) }
44
+ assert_raise(Admin::Error){ Admin.get_user('foofoofoo') }
45
+ end
46
+
47
+ def test_users_basic
48
+ assert_respond_to(Admin, :users)
49
+ assert_nothing_raised{ Admin.users }
50
+ end
51
+
52
+ def test_users
53
+ assert_kind_of(Array, Admin.users)
54
+ assert_kind_of(User, Admin.users.first)
55
+ end
56
+
57
+ def test_users_block_form
58
+ array = []
59
+ assert_nothing_raised{ Admin.users{ |g| array << g } }
60
+ assert_equal(true, Admin.users.length == array.length)
61
+ assert_nothing_raised{ Admin.users{ |g| break } }
62
+ end
63
+
64
+ def test_users_expected_errors
65
+ assert_raise(ArgumentError){ Admin.users(@user_id) }
66
+ end
67
+
68
+ def test_get_group_basic
69
+ assert_respond_to(Admin, :get_group)
70
+ assert_nothing_raised{ Admin.get_group(@group) }
71
+ assert_nothing_raised{ Admin.get_group(@group_id) }
72
+ end
73
+
74
+ def test_get_group_by_name
75
+ assert_kind_of(Group, Admin.get_group(@group))
76
+ end
77
+
78
+ def test_get_group_by_id
79
+ assert_kind_of(Group, Admin.get_group(@group_id))
80
+ end
81
+
82
+ def test_get_group_expected_errors
83
+ assert_raise(ArgumentError){ Admin.get_group }
84
+ assert_raise(TypeError){ Admin.get_group([]) }
85
+ assert_raise(Admin::Error){ Admin.get_group('foofoofoo') }
86
+ end
87
+
88
+ def test_groups_basic
89
+ assert_respond_to(Admin, :groups)
90
+ assert_nothing_raised{ Admin.groups }
91
+ end
92
+
93
+ def test_groups
94
+ assert_kind_of(Array, Admin.groups)
95
+ assert_kind_of(Group, Admin.groups.first)
96
+ end
97
+
98
+ def test_groups_expected_errors
99
+ assert_raise(ArgumentError){ Admin.groups(@group_id) }
100
+ end
101
+
102
+ def test_groups_block_form
103
+ array = []
104
+ assert_nothing_raised{ Admin.groups{ |g| array << g } }
105
+ assert_equal(true, Admin.groups.length == array.length)
106
+ assert_nothing_raised{ Admin.groups{ |g| break } }
107
+ end
108
+
109
+ ## User Tests
110
+
111
+ def test_user_name
112
+ @user = Admin.users.first
113
+ assert_respond_to(@user, :name)
114
+ assert_kind_of(String, @user.name)
115
+ end
116
+
117
+ def test_user_passwd
118
+ @user = Admin.users.first
119
+ assert_respond_to(@user, :passwd)
120
+ assert_kind_of(String, @user.passwd)
121
+ end
122
+
123
+ def test_user_uid
124
+ @user = Admin.users.first
125
+ assert_respond_to(@user, :uid)
126
+ assert_kind_of(Fixnum, @user.uid)
127
+ end
128
+
129
+ def test_user_gid
130
+ @user = Admin.users.first
131
+ assert_respond_to(@user, :gid)
132
+ assert_kind_of(Fixnum, @user.gid)
133
+ end
134
+
135
+ def test_user_dir
136
+ @user = Admin.users.first
137
+ assert_respond_to(@user, :dir)
138
+ assert_kind_of(String, @user.dir)
139
+ end
140
+
141
+ def test_user_shell
142
+ @user = Admin.users.first
143
+ assert_respond_to(@user, :shell)
144
+ assert_kind_of(String, @user.shell)
145
+ end
146
+
147
+ def test_user_gecos
148
+ @user = Admin.users.first
149
+ assert_respond_to(@user, :gecos)
150
+ assert_kind_of(String, @user.gecos)
151
+ end
152
+
153
+ def test_user_quota
154
+ @user = Admin.users.first
155
+ assert_respond_to(@user, :quota)
156
+ assert_true([Fixnum, NilClass].include?(@user.quota.class))
157
+ end
158
+
159
+ def test_user_age
160
+ @user = Admin.users.first
161
+ assert_respond_to(@user, :age)
162
+ assert_true([Fixnum, NilClass].include?(@user.age.class))
163
+ end
164
+
165
+ def test_user_access_class
166
+ @user = Admin.users.first
167
+ assert_respond_to(@user, :access_class)
168
+ assert_true([String, NilClass].include?(@user.access_class.class))
169
+ end
170
+
171
+ def test_user_comment
172
+ @user = Admin.users.first
173
+ assert_respond_to(@user, :comment)
174
+ assert_true([String, NilClass].include?(@user.comment.class))
175
+ end
176
+
177
+ def test_user_expire
178
+ @user = Admin.users.first
179
+ assert_respond_to(@user, :expire)
180
+ assert_true([Time, NilClass].include?(@user.expire.class))
181
+ end
182
+
183
+ def test_user_change
184
+ @user = Admin.users.first
185
+ assert_respond_to(@user, :change)
186
+ assert_true([Time, NilClass].include?(@user.change.class))
187
+ end
188
+
189
+ def test_user_login_time
190
+ @user = Admin.users.first
191
+ assert_respond_to(@user, :login_time)
192
+ assert_true([Time, NilClass].include?(@user.login_time.class))
193
+ end
194
+
195
+ def test_user_login_device
196
+ @user = Admin.users.first
197
+ assert_respond_to(@user, :login_device)
198
+ assert_true([String, NilClass].include?(@user.login_device.class))
199
+ end
200
+
201
+ def test_user_login_host
202
+ @user = Admin.users.first
203
+ assert_respond_to(@user, :login_host)
204
+ assert_true([String, NilClass].include?(@user.login_host.class))
205
+ end
206
+
207
+ def test_user_groups
208
+ @user = Admin.users.first
209
+ assert_respond_to(@user, :groups)
210
+ assert_kind_of(Array, @user.groups)
211
+ end
212
+
213
+ ## Group Tests
214
+
215
+ def test_group_name
216
+ @group = Admin.groups.first
217
+ assert_respond_to(@group, :name)
218
+ assert_kind_of(String, @group.name)
219
+ end
220
+
221
+ def test_group_gid
222
+ @group = Admin.groups.first
223
+ assert_respond_to(@group, :gid)
224
+ assert_kind_of(Fixnum, @group.gid)
225
+ end
226
+
227
+ def test_group_members
228
+ @group = Admin.groups.first
229
+ assert_respond_to(@group, :members)
230
+ assert_kind_of(Array, @group.members)
231
+ end
232
+
233
+ def test_group_passwd
234
+ @group = Admin.groups.first
235
+ assert_respond_to(@group, :passwd)
236
+ assert_kind_of(String, @group.passwd)
237
+ end
238
+
239
+ def teardown
240
+ @user = nil
241
+ @user_id = nil
242
+ @group = nil
243
+ @group_id = nil
244
+ end
246
245
  end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ hash: 5
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 5
9
+ - 3
10
+ version: 1.5.3
5
11
  platform: ruby
6
12
  authors:
7
13
  - Daniel J. Berger
@@ -9,20 +15,26 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-08-02 00:00:00 -06:00
18
+ date: 2010-10-06 00:00:00 -06:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: test-unit
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
23
- version: 2.0.3
24
- version:
25
- description: " The sys-admin library is a unified, cross platform replacement for the\n 'etc' library that ships as part of the Ruby standard library. It\n provides a common interface for all platforms, including MS Windows. In\n addition, it provides an interface for adding, deleting and configuring\n users on MS Windows.\n"
29
+ hash: 9
30
+ segments:
31
+ - 2
32
+ - 1
33
+ - 1
34
+ version: 2.1.1
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: " The sys-admin library is a unified, cross platform replacement for the\n 'etc' library that ships as part of the Ruby standard library. It\n provides a common interface for all platforms, including MS Windows. In\n addition, it provides an interface for adding, deleting and configuring\n users on MS Windows.\n"
26
38
  email: djberg96@gmail.com
27
39
  executables: []
28
40
 
@@ -34,21 +46,23 @@ extra_rdoc_files:
34
46
  - MANIFEST
35
47
  - ext/sys/admin.c
36
48
  files:
49
+ - Rakefile
50
+ - README
37
51
  - doc/sys-admin-unix.txt
38
52
  - doc/sys-admin-windows.txt
53
+ - sys-admin.gemspec
54
+ - CHANGES
39
55
  - examples/groups.rb
40
56
  - examples/users.rb
41
- - test/test_sys_admin.rb
42
- - test/test_sys_admin_unix.rb
43
57
  - test/test_sys_admin_windows.rb
44
- - CHANGES
58
+ - test/test_sys_admin_unix.rb
59
+ - test/test_sys_admin.rb
45
60
  - MANIFEST
46
- - Rakefile
47
- - README
48
61
  - ext/sys/admin.c
49
62
  - ext/sys/admin.h
63
+ - ext/extconf.rb
50
64
  has_rdoc: true
51
- homepage: http://www.rubyforge.org/projects/sysutils
65
+ homepage: http://www.github.com/djberg96/sysutils
52
66
  licenses:
53
67
  - Artistic 2.0
54
68
  post_install_message:
@@ -57,21 +71,27 @@ rdoc_options: []
57
71
  require_paths:
58
72
  - lib
59
73
  required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
60
75
  requirements:
61
76
  - - ">="
62
77
  - !ruby/object:Gem::Version
63
- version: 1.8.2
64
- version:
78
+ hash: 3
79
+ segments:
80
+ - 0
81
+ version: "0"
65
82
  required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
66
84
  requirements:
67
85
  - - ">="
68
86
  - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
69
90
  version: "0"
70
- version:
71
91
  requirements: []
72
92
 
73
93
  rubyforge_project: sysutils
74
- rubygems_version: 1.3.5
94
+ rubygems_version: 1.3.7
75
95
  signing_key:
76
96
  specification_version: 3
77
97
  summary: A unified, cross platform replacement for the "etc" library.