sys-uptime 0.7.0 → 0.7.5

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
- SHA1:
3
- metadata.gz: 4fb2b350ac33649154689cab59e6a6be3990bb88
4
- data.tar.gz: d0b9d228376f30f6cf204f52f9af9902374cb018
2
+ SHA256:
3
+ metadata.gz: 559d060a4c5cb7ef11471f1e079d53e6e758fbece095ceca8cb5906d1f9aaa93
4
+ data.tar.gz: 857205d6d793b0db9b3756cab8c22a85d0a02a3fd397eb6a483bc7820ae13054
5
5
  SHA512:
6
- metadata.gz: ab51211b12dd86d2a3ed46e4885279685154af70a89ee16824a05aee644053c27f6e1062a43df177c0fa71c4bc21f6877add34e42000b4e77518fa9570b05ff3
7
- data.tar.gz: 77bcdef1132f60190e5f0eb6a64a0ea3b8c3cd48c35f488afd989bbcb02f4be60d9b797e0c8cf77c04a0adf6ba4d3419b2652c15acfd369fb111daac05f1675f
6
+ metadata.gz: 7e5ed8ebd668466adb8277a8fd397ff248ef4ca7e8353eb5f558ad147a07dafc288f7db8767ac1500e66732cedcad9af681c7369bd13fcd5461f68656bb18a00
7
+ data.tar.gz: 4b2f55fe62abfce0a863dd096e03dba42b6dcb85e34f1fa82f87beff20e70f49dc3bcf93059de52eee223a89745d7d53d9f9d670058d9ac61cb35319908f8dd6
@@ -1,2 +1,3 @@
1
- *Q��T�qf�$�#+�`H.������IH���82�L�ZH;%Zk��4�R�,�
2
- ]��w���eV��7��@�B[,���y{�|5�I��$ZԷ2$o������et��8��Еg7⎑�zv���0�ӳ�ï}�D���̀&>�tW�1Jj& Q�}ջ+��U��m*�s`�&k2�$��
1
+ ~���J����
2
+ �/��N3
3
+ ùQ��LXc���$�N�p��㱧���לa�d|F�/�@֋�N�����3�Ʊ�,A|�y�IW
data.tar.gz.sig CHANGED
Binary file
@@ -1,35 +1,61 @@
1
- == 0.7.0 - 3-Oct-2015
1
+ ## 0.7.5 - 29-Oct-2020
2
+ * Switched docs to markdown format.
3
+ * Added a Gemfile.
4
+
5
+ ## 0.7.4 - 18-Mar-2020
6
+ * Added a LICENSE file as per the requirements of the Apache-2.0 license.
7
+
8
+ ## 0.7.3 - 31-Dec-2019
9
+ * Attempting to call Sys::Uptime.new will now raise an error. I thought
10
+ this was already the case, but apparently one of the tests was bad.
11
+ * Added explicit .rdoc extensions to various text files so that github
12
+ will display them nicely.
13
+ * Switched from test-unit to rspec as the testing framework of choice.
14
+ * Updated the gemspec to reflect the filename updates, as well as the
15
+ added development dependency.
16
+
17
+ ## 0.7.2 - 4-Nov-2018
18
+ * Added metadata to the gemspec.
19
+ * The VERSION constant is now frozen.
20
+ * Updated cert.
21
+
22
+ ## 0.7.1 - 14-May-2016
23
+ * Altered internal layout, which also fixed a require bug. Thanks go
24
+ to jkburges for the spot.
25
+ * Moved the VERSION constant into a single file shared by all platforms.
26
+
27
+ ## 0.7.0 - 3-Oct-2015
2
28
  * Changed license to Apache 2.0.
3
29
  * Added a cert. This gem is now signed.
4
30
  * Added a sys-uptime.rb file for convenience.
5
31
  * Gem related tasks in the Rakefile now assume Rubygems 2.x.
6
32
 
7
- == 0.6.2 - 8-Nov-2014
33
+ ## 0.6.2 - 8-Nov-2014
8
34
  * Minor updates to gemspec and Rakefile.
9
35
 
10
- == 0.6.1 - 22-Oct-2012
36
+ ## 0.6.1 - 22-Oct-2012
11
37
  * Refactored a private method in the MS Windows source.
12
38
  * Minor fix for one private method test.
13
39
  * Fixed an RbConfig vs Config warning. Thanks Pedro Carrico.
14
40
 
15
- == 0.6.0 - 11-Dec-2011
41
+ ## 0.6.0 - 11-Dec-2011
16
42
  * Switched Unix code to use FFI.
17
43
  * Removed all of the C related tasks from the Rakefile and added the gem:build
18
44
  and gem:install tasks.
19
45
  * Internal directory layout changes, with appropriate changes to the gemspec.
20
46
 
21
- == 0.5.3 - 7-May-2009
47
+ ## 0.5.3 - 7-May-2009
22
48
  * Altered the Uptime.seconds implementation on Linux so that it works with
23
49
  both Ruby 1.8.x and 1.9.x. Thanks go to Alexey Chebotar for the spot.
24
50
 
25
- == 0.5.2 - 13-Dec-2008
51
+ ## 0.5.2 - 13-Dec-2008
26
52
  * Fixed a date/time issue in the Windows version caused by Ruby itself.
27
53
  * Fixed the Uptime.seconds, Uptime.minutes and Uptime.hours methods on MS
28
54
  Windows.
29
55
  * Renamed the test file to 'test_sys_uptime.rb'.
30
56
  * Some minor updates to the Rakefile.
31
57
 
32
- == 0.5.1 - 26-Jul-2007
58
+ ## 0.5.1 - 26-Jul-2007
33
59
  * Fixed bug in the MS Windows version caused by incorrect parsing of an
34
60
  MS specific date format (caused by a bug in Ruby 1.8.6). Thanks go to
35
61
  Robert H. for the spot.
@@ -38,7 +64,7 @@
38
64
  * Added an 'install_gem' Rake task, and updated the README installation
39
65
  instructions.
40
66
 
41
- == 0.5.0 - 30-Mar-2007
67
+ ## 0.5.0 - 30-Mar-2007
42
68
  * For platforms that use C code, the code now always uses the sysctl()
43
69
  function if supported by your system. This replaces the platform specific
44
70
  checks I was doing for the various BSD flavors.
@@ -48,20 +74,20 @@
48
74
  * Added a Rakefile - users should now use the 'test' and 'install' rake tasks.
49
75
  * Updates to the MANIFEST, README and uptime.txt files.
50
76
 
51
- == 0.4.5 - 19-Nov-2006
77
+ ## 0.4.5 - 19-Nov-2006
52
78
  * Internal layout changes, minor doc updates and gemspec improvements.
53
79
  * No code changes.
54
80
 
55
- == 0.4.4 - 30-Jun-2006
81
+ ## 0.4.4 - 30-Jun-2006
56
82
  * Added inline rdoc documentation to the source files.
57
83
  * Added a gemspec.
58
84
 
59
- == 0.4.3 - 18-Dec-2005
85
+ ## 0.4.3 - 18-Dec-2005
60
86
  * Changed the Linux version to pure Ruby. The current method of determining
61
87
  uptime in unix.c does not work in Linux kernel 2.6+. So, from now on it
62
88
  reads out of /proc/uptime.
63
89
 
64
- == 0.4.2 - 6-May-2005
90
+ ## 0.4.2 - 6-May-2005
65
91
  * Fixed a potential boot_time bug.
66
92
  * Removed the version.h file. It's no longer needed since the Windows
67
93
  version is pure Ruby.
@@ -73,13 +99,13 @@
73
99
  * Made most documents rdoc friendly.
74
100
  * Moved project to RubyForge.
75
101
 
76
- == 0.4.1 - 14-Dec-2004
102
+ ## 0.4.1 - 14-Dec-2004
77
103
  * Moved freebsd code into unix.c file.
78
104
  * Should now work past 249 days (2**31) on systems that have utmpx.h.
79
105
  * Fixed a bug with regards to boot_time, where it was possible that it would
80
106
  simply be empty.
81
107
 
82
- == 0.4.0 - 8-Jul-2004
108
+ ## 0.4.0 - 8-Jul-2004
83
109
  * Removed all reference to the CLK_TCK constant, as per documentation from
84
110
  Richard Stevens that it is deprecated and that sysconf() should be used
85
111
  instead (well, I knew about this, but ignored it until now).
@@ -99,18 +125,18 @@
99
125
  * Removed the uptime.html file - you may generate that on your own.
100
126
  * Added warranty and license info.
101
127
 
102
- == 0.3.2 - 30-Dec-2003
128
+ ## 0.3.2 - 30-Dec-2003
103
129
  * Cleaned up some warnings that showed up with -Wall on some unix platforms
104
130
  (int vs long format, explicit include)
105
131
  * Minor test suite and extconf.rb changes
106
132
 
107
- == 0.3.1 - 25-Jun-2003
133
+ ## 0.3.1 - 25-Jun-2003
108
134
  * Modified test files to handle HP-UX extensions
109
135
  * Minor doc updates
110
136
  * Added the dhms() method. Actually, this was in the 0.3.0
111
137
  release, I just forgot to mention it in this file :)
112
138
 
113
- == 0.3.0 - 22-Jun-2003
139
+ ## 0.3.0 - 22-Jun-2003
114
140
  * Added OS X support - thanks go to Mike Hall for the patch
115
141
  * Fixed incorrect values in FreeBSD (again Mike Hall)
116
142
  * Modified tc_unix.rb test suite to handle OS X, along with a bit
@@ -119,7 +145,7 @@
119
145
  * Separated FreeBSD/OS X source into its own file (freebsd.c).
120
146
  The #ifdefs were starting to get too ugly for me
121
147
 
122
- == 0.2.1 - 13-May-2003
148
+ ## 0.2.1 - 13-May-2003
123
149
  * Fixed bug in extconf.rb file, and made some major changes
124
150
  * Modified test.rb for those without TestUnit
125
151
  * Modified TestUnit tests - some bogus tests were removed
@@ -129,7 +155,7 @@
129
155
  * Docs automatically included in doc directory (i.e. no more interactive
130
156
  document creation)
131
157
 
132
- == 0.2.0 - 13-Mar-2003
158
+ ## 0.2.0 - 13-Mar-2003
133
159
  * Added MS Windows support
134
160
  * Added a VERSION constant
135
161
  * Added a test suite (for those with TestUnit installed)
@@ -138,7 +164,7 @@
138
164
  * Changelog and Manifest are now CHANGES and MANIFEST, respectively
139
165
  * Many changes to extconf.rb
140
166
 
141
- == 0.1.3 - 6-Jan-2003
167
+ ## 0.1.3 - 6-Jan-2003
142
168
  * Added a VERSION class method
143
169
  * Added a copyright notice
144
170
  * Fixed up the docs a bit and moved them to the doc directory
@@ -146,14 +172,14 @@
146
172
  * Modified test.rb script to make it better
147
173
  * Changed install instructions slightly
148
174
 
149
- == 0.1.2 - 25-Aug-2002
175
+ ## 0.1.2 - 25-Aug-2002
150
176
  * Slight change to preprocessor commands to avoid redefining CLK_TCK on
151
177
  those systems that define it in time.h
152
178
  * Added an INSTALL file
153
179
 
154
- == 0.1.1 - 21-Jun-2002
180
+ ## 0.1.1 - 21-Jun-2002
155
181
  * The CLK_TCK constant wasn't necessarily being set correctly, which could
156
182
  lead to some odd results. This has been fixed.
157
183
 
158
- == 0.1.0 - 17-Jun-2002
184
+ ## 0.1.0 - 17-Jun-2002
159
185
  * Initial release
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org' do
2
+ gem 'rake'
3
+
4
+ platforms :ruby do
5
+ gem 'ffi', '~> 1.1'
6
+ end
7
+
8
+ group 'test' do
9
+ gem 'rspec', '~> 3.9'
10
+ end
11
+ end
data/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -1,11 +1,12 @@
1
- * CHANGES
2
- * MANIFEST
1
+ * CHANGES.rdoc
2
+ * LICENSE
3
+ * MANIFEST.rdoc
3
4
  * Rakefile
4
- * README
5
+ * README.rdoc
5
6
  * sys-uptime.gemspec
6
7
  * certs/djberg96_pub.pem
7
8
  * examples/test.rb
8
9
  * lib/sys-uptime.rb
9
10
  * lib/unix/sys/uptime.rb
10
11
  * lib/windows/sys/uptime.rb
11
- * test/test_sys_uptime.rb
12
+ * spec/sys_uptime_spec.rb
@@ -0,0 +1,69 @@
1
+ ## Description
2
+ A Ruby interface for getting system uptime information.
3
+
4
+ ## Prerequisites
5
+ ffi 0.1.0 or later on Unixy platforms.
6
+
7
+ ## Installation
8
+
9
+ `gem install sys-uptime`
10
+
11
+ ## Synopsis
12
+ ```
13
+ require 'sys-uptime'
14
+ include Sys
15
+
16
+ # Get everything
17
+ p Uptime.uptime
18
+ p Uptime.dhms.join(', ')
19
+
20
+ # Get individual units
21
+ p Uptime.days
22
+ p Uptime.hours
23
+ p Uptime.minutes
24
+ p Uptime.seconds
25
+
26
+ # Get the boot time
27
+ p Uptime.boot_time
28
+ ```
29
+
30
+ ## Notes
31
+ On MS Windows the +Uptime.uptime+ and +Uptime.boot_time+ methods optionally
32
+ takes a host name as a single argument. The default is localhost.
33
+
34
+ The current time, users and load average are not included in this library
35
+ module, even though you may be used to seeing them with the command
36
+ line version of +uptime+.
37
+
38
+ ## Known Bugs
39
+ None that I am aware of. Please log any bugs you find on the project
40
+ website at https://github.com/djberg96/sys-uptime.
41
+
42
+ ## Questions
43
+ "Doesn't Struct::Tms do this?" - No.
44
+
45
+ ## License
46
+ Apache-2.0
47
+
48
+ ## Copyright
49
+ Copyright 2002-2019, Daniel J. Berger
50
+
51
+ All Rights Reserved. This module is free software. It may be used,
52
+ redistributed and/or modified under the same terms as Ruby itself.
53
+
54
+ ## Warranty
55
+ This library is provided "as is" and without any express or
56
+ implied warranties, including, without limitation, the implied
57
+ warranties of merchantability and fitness for a particular purpose.
58
+
59
+ ## Acknowledgements
60
+ Andrea Fazzi for help with the FFI version.
61
+
62
+ Mike Hall for help with the BSD side of things for the original C code.
63
+
64
+ Ola Eriksson, whose source code I shamelessly plagiarized to get a better
65
+ implementation for systems that have the utmpx.h header file for the
66
+ original C code.
67
+
68
+ ## Author
69
+ Daniel J. Berger
data/Rakefile CHANGED
@@ -1,8 +1,9 @@
1
1
  require 'rake'
2
2
  require 'rake/clean'
3
3
  require 'rake/testtask'
4
+ require 'rspec/core/rake_task'
4
5
 
5
- CLEAN.include("**/*.gem", "**/*.rbx", "**/*.rbc")
6
+ CLEAN.include("**/*.gem", "**/*.rbx", "**/*.rbc", "**/*.lock")
6
7
 
7
8
  namespace 'gem' do
8
9
  desc 'Build the sys-uptime gem'
@@ -12,13 +13,9 @@ namespace 'gem' do
12
13
  spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
13
14
 
14
15
  if File::ALT_SEPARATOR
15
- spec.require_paths = ['lib', 'lib/windows']
16
- spec.platform = Gem::Platform::CURRENT
17
- spec.platform.cpu = 'universal'
18
- spec.platform.version = nil
16
+ spec.platform = Gem::Platform.new(['universal', 'mingw32'])
19
17
  else
20
- spec.require_paths = ['lib', 'lib/unix']
21
- spec.add_dependency('ffi', '>= 1.0.0')
18
+ spec.add_dependency('ffi', '~> 1.1')
22
19
  end
23
20
 
24
21
  Gem::Package.build(spec)
@@ -32,15 +29,6 @@ namespace 'gem' do
32
29
  end
33
30
 
34
31
  desc "Run the test suite"
35
- Rake::TestTask.new do |t|
36
- if File::ALT_SEPARATOR
37
- t.libs << 'lib/windows'
38
- else
39
- t.libs << 'lib/unix'
40
- end
41
-
42
- t.warning = true
43
- t.verbose = true
44
- end
32
+ RSpec::Core::RakeTask.new(:spec)
45
33
 
46
- task :default => :test
34
+ task :default => :spec
@@ -1,21 +1,26 @@
1
1
  -----BEGIN CERTIFICATE-----
2
- MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhkamJl
2
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
3
3
  cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
4
- MB4XDTE1MDkwMjIwNDkxOFoXDTE2MDkwMTIwNDkxOFowPzERMA8GA1UEAwwIZGpi
4
+ MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
5
5
  ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
6
- bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMyTkvXqRp6hLs9eoJOS
7
- Hmi8kRYbq9Vkf15/hMxJpotYMgJVHHWrmDcC5Dye2PbnXjTkKf266Zw0PtT9h+lI
8
- S3ts9HO+vaCFSMwFFZmnWJSpQ3CNw2RcHxjWkk9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O/Dkqq7hGaiHpwKY76wQ1+8xAh
21
26
  -----END CERTIFICATE-----
@@ -1,5 +1 @@
1
- if File::ALT_SEPARATOR
2
- require_relative 'windows/sys/uptime'
3
- else
4
- require_relative 'unix/sys/uptime'
5
- end
1
+ require_relative 'sys/uptime'
@@ -12,9 +12,6 @@ module Sys
12
12
  # Error typically raised in one of the Uptime methods should fail.
13
13
  class Error < StandardError; end
14
14
 
15
- # The version of the sys-uptime library
16
- VERSION = '0.7.0'
17
-
18
15
  private
19
16
 
20
17
  # Hit this issue on Linux, not sure why
@@ -29,7 +26,7 @@ module Sys
29
26
  attach_function :time, [:pointer], :time_t
30
27
  attach_function :times, [:pointer], :clock_t
31
28
 
32
- private_class_method :strerror, :sysconf, :time, :times
29
+ private_class_method :strerror, :sysconf, :time, :times, :new
33
30
 
34
31
  begin
35
32
  attach_function :sysctl, [:pointer, :uint, :pointer, :pointer, :pointer, :size_t], :int
@@ -0,0 +1,12 @@
1
+ if File::ALT_SEPARATOR
2
+ require_relative 'windows/sys/uptime'
3
+ else
4
+ require_relative 'unix/sys/uptime'
5
+ end
6
+
7
+ module Sys
8
+ class Uptime
9
+ # The version of the sys-uptime library
10
+ VERSION = '0.7.5'.freeze
11
+ end
12
+ end
@@ -13,8 +13,8 @@ module Sys
13
13
  # Error typically raised in one of the Uptime methods should fail.
14
14
  class Error < StandardError; end
15
15
 
16
- # The version of the sys-uptime library.
17
- VERSION = '0.7.0'
16
+ # You cannot instantiate an instance of Sys::Uptime.
17
+ private_class_method :new
18
18
 
19
19
  # Returns the boot time as a Time object.
20
20
  #
@@ -0,0 +1,103 @@
1
+ #####################################################################
2
+ # sys_uptime_spec.rb
3
+ #
4
+ # Test suite for sys-uptime. This should generally be run via the
5
+ # 'rake test' task, since it handles the pre-setup code for you.
6
+ #####################################################################
7
+ require 'sys/uptime'
8
+ require 'rspec'
9
+ require 'socket'
10
+
11
+ describe Sys::Uptime do
12
+ example "version is set to expected value" do
13
+ expect(Sys::Uptime::VERSION).to eql('0.7.5')
14
+ expect(Sys::Uptime::VERSION.frozen?).to be(true)
15
+ end
16
+
17
+ example "seconds method basic functionality" do
18
+ expect(Sys::Uptime).to respond_to(:seconds)
19
+ expect{ Sys::Uptime.seconds }.not_to raise_error
20
+ end
21
+
22
+ example "seconds method returns a plausible value" do
23
+ expect(Sys::Uptime.seconds).to be_kind_of(Integer)
24
+ expect(Sys::Uptime.seconds).to be > 300
25
+ end
26
+
27
+ example "minutes method basic functionality" do
28
+ expect(Sys::Uptime).to respond_to(:minutes)
29
+ expect{ Sys::Uptime.minutes }.not_to raise_error
30
+ end
31
+
32
+ example "minutes method returns a plausible value" do
33
+ expect(Sys::Uptime.minutes).to be_kind_of(Integer)
34
+ expect(Sys::Uptime.minutes).to be > 5
35
+ end
36
+
37
+ example "hours method basic functionality" do
38
+ expect(Sys::Uptime).to respond_to(:hours)
39
+ expect{ Sys::Uptime.hours }.not_to raise_error
40
+ end
41
+
42
+ example "hours method returns a plausible value" do
43
+ expect(Sys::Uptime.hours).to be_kind_of(Integer)
44
+ expect(Sys::Uptime.hours).to be > 0
45
+ end
46
+
47
+ example "days method basic functionality" do
48
+ expect(Sys::Uptime).to respond_to(:days)
49
+ expect{ Sys::Uptime.days }.not_to raise_error
50
+ end
51
+
52
+ example "days method returns a plausible value" do
53
+ expect(Sys::Uptime.days).to be_kind_of(Integer)
54
+ expect(Sys::Uptime.days).to be >= 0
55
+ end
56
+
57
+ example "uptime method basic functionality" do
58
+ expect(Sys::Uptime).to respond_to(:uptime)
59
+ expect{ Sys::Uptime.uptime }.not_to raise_error
60
+ end
61
+
62
+ example "uptime method returns a non-empty string" do
63
+ expect(Sys::Uptime.uptime).to be_kind_of(String)
64
+ expect(Sys::Uptime.uptime.empty?).to be(false)
65
+ end
66
+
67
+ example "uptime method does not accept any arguments", :unless => File::ALT_SEPARATOR do
68
+ expect{ Sys::Uptime.uptime(1) }.to raise_error(ArgumentError)
69
+ end
70
+
71
+ example "uptime accepts a host name on Windows", :if => File::ALT_SEPARATOR do
72
+ expect{ Sys::Uptime.uptime(Socket.gethostname) }.not_to raise_error
73
+ end
74
+
75
+ example "dhms method basic functionality" do
76
+ expect(Sys::Uptime).to respond_to(:dhms)
77
+ expect{ Sys::Uptime.dhms }.not_to raise_error
78
+ expect(Sys::Uptime.dhms).to be_kind_of(Array)
79
+ end
80
+
81
+ example "dhms method returns an array of four elements" do
82
+ expect(Sys::Uptime.dhms).not_to be_empty
83
+ expect(Sys::Uptime.dhms.length).to eql(4)
84
+ end
85
+
86
+ example "boot_time method basic functionality" do
87
+ expect(Sys::Uptime).to respond_to(:boot_time)
88
+ expect{ Sys::Uptime.boot_time }.not_to raise_error
89
+ end
90
+
91
+ example "boot_time method returns a Time object" do
92
+ expect(Sys::Uptime.boot_time).to be_kind_of(Time)
93
+ end
94
+
95
+ example "Uptime class cannot be instantiated" do
96
+ expect{ Sys::Uptime.new }.to raise_error(StandardError)
97
+ end
98
+
99
+ example "Ensure that ffi functions are private" do
100
+ methods = Sys::Uptime.methods(false).map{ |e| e.to_s }
101
+ expect(methods).not_to include('time', 'times')
102
+ end
103
+ end
@@ -2,17 +2,26 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'sys-uptime'
5
- spec.version = '0.7.0'
5
+ spec.version = '0.7.5'
6
6
  spec.author = 'Daniel J. Berger'
7
- spec.license = 'Apache 2.0'
7
+ spec.license = 'Apache-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
9
9
  spec.homepage = 'https://github.com/djberg96/sys-uptime'
10
10
  spec.summary = 'A Ruby interface for getting system uptime information.'
11
- spec.test_file = 'test/test_sys_uptime.rb'
11
+ spec.test_file = 'spec/sys_uptime_spec.rb'
12
12
  spec.files = Dir["**/*"].reject{ |f| f.include?('git') }
13
13
  spec.cert_chain = ['certs/djberg96_pub.pem']
14
14
 
15
- spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST']
15
+ spec.add_development_dependency 'rspec', '~> 3.9'
16
+
17
+ spec.metadata = {
18
+ 'homepage_uri' => 'https://github.com/djberg96/sys-uptime',
19
+ 'bug_tracker_uri' => 'https://github.com/djberg96/sys-uptime/issues',
20
+ 'changelog_uri' => 'https://github.com/djberg96/sys-uptime/blob/ffi/CHANGES.md',
21
+ 'documentation_uri' => 'https://github.com/djberg96/sys-uptime/wiki',
22
+ 'source_code_uri' => 'https://github.com/djberg96/sys-uptime',
23
+ 'wiki_uri' => 'https://github.com/djberg96/sys-uptime/wiki'
24
+ }
16
25
 
17
26
  spec.description = <<-EOF
18
27
  The sys-uptime library is a simple interface for gathering uptime
metadata CHANGED
@@ -1,51 +1,70 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-uptime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhkamJl
13
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
14
14
  cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
15
- MB4XDTE1MDkwMjIwNDkxOFoXDTE2MDkwMTIwNDkxOFowPzERMA8GA1UEAwwIZGpi
15
+ MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
16
16
  ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
17
- bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMyTkvXqRp6hLs9eoJOS
18
- Hmi8kRYbq9Vkf15/hMxJpotYMgJVHHWrmD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mqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
+ WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
32
37
  -----END CERTIFICATE-----
33
- date: 2015-10-03 00:00:00.000000000 Z
38
+ date: 2020-10-29 00:00:00.000000000 Z
34
39
  dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: rspec
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.9'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.9'
35
54
  - !ruby/object:Gem::Dependency
36
55
  name: ffi
37
56
  requirement: !ruby/object:Gem::Requirement
38
57
  requirements:
39
- - - ">="
58
+ - - "~>"
40
59
  - !ruby/object:Gem::Version
41
- version: 1.0.0
60
+ version: '1.1'
42
61
  type: :runtime
43
62
  prerelease: false
44
63
  version_requirements: !ruby/object:Gem::Requirement
45
64
  requirements:
46
- - - ">="
65
+ - - "~>"
47
66
  - !ruby/object:Gem::Version
48
- version: 1.0.0
67
+ version: '1.1'
49
68
  description: |2
50
69
  The sys-uptime library is a simple interface for gathering uptime
51
70
  information. You can retrieve data in seconds, minutes, days, hours,
@@ -53,31 +72,36 @@ description: |2
53
72
  email: djberg96@gmail.com
54
73
  executables: []
55
74
  extensions: []
56
- extra_rdoc_files:
57
- - CHANGES
58
- - README
59
- - MANIFEST
75
+ extra_rdoc_files: []
60
76
  files:
61
- - CHANGES
62
- - MANIFEST
63
- - README
77
+ - CHANGES.md
78
+ - Gemfile
79
+ - LICENSE
80
+ - MANIFEST.md
81
+ - README.md
64
82
  - Rakefile
65
83
  - certs/djberg96_pub.pem
66
84
  - examples/uptime_test.rb
67
85
  - lib/sys-uptime.rb
68
- - lib/unix/sys/uptime.rb
69
- - lib/windows/sys/uptime.rb
86
+ - lib/sys/unix/sys/uptime.rb
87
+ - lib/sys/uptime.rb
88
+ - lib/sys/windows/sys/uptime.rb
89
+ - spec/sys_uptime_spec.rb
70
90
  - sys-uptime.gemspec
71
- - test/test_sys_uptime.rb
72
91
  homepage: https://github.com/djberg96/sys-uptime
73
92
  licenses:
74
- - Apache 2.0
75
- metadata: {}
76
- post_install_message:
93
+ - Apache-2.0
94
+ metadata:
95
+ homepage_uri: https://github.com/djberg96/sys-uptime
96
+ bug_tracker_uri: https://github.com/djberg96/sys-uptime/issues
97
+ changelog_uri: https://github.com/djberg96/sys-uptime/blob/ffi/CHANGES.md
98
+ documentation_uri: https://github.com/djberg96/sys-uptime/wiki
99
+ source_code_uri: https://github.com/djberg96/sys-uptime
100
+ wiki_uri: https://github.com/djberg96/sys-uptime/wiki
101
+ post_install_message:
77
102
  rdoc_options: []
78
103
  require_paths:
79
104
  - lib
80
- - lib/unix
81
105
  required_ruby_version: !ruby/object:Gem::Requirement
82
106
  requirements:
83
107
  - - ">="
@@ -89,10 +113,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
113
  - !ruby/object:Gem::Version
90
114
  version: '0'
91
115
  requirements: []
92
- rubyforge_project:
93
- rubygems_version: 2.4.5
94
- signing_key:
116
+ rubygems_version: 3.1.4
117
+ signing_key:
95
118
  specification_version: 4
96
119
  summary: A Ruby interface for getting system uptime information.
97
120
  test_files:
98
- - test/test_sys_uptime.rb
121
+ - spec/sys_uptime_spec.rb
metadata.gz.sig CHANGED
Binary file
data/README DELETED
@@ -1,66 +0,0 @@
1
- = Description
2
- A Ruby interface for getting system uptime information.
3
-
4
- = Prerequisites
5
- ffi 0.1.0 or later on Unixy platforms.
6
-
7
- = Installation
8
- gem install sys-uptime
9
-
10
- = Synopsis
11
- require 'sys/uptime'
12
- include Sys
13
-
14
- # Get everything
15
- p Uptime.uptime
16
- p Uptime.dhms.join(', ')
17
-
18
- # Get individual units
19
- p Uptime.days
20
- p Uptime.hours
21
- p Uptime.minutes
22
- p Uptime.seconds
23
-
24
- # Get the boot time
25
- p Uptime.boot_time
26
-
27
- = Notes
28
- On MS Windows the Uptime.uptime and Uptime_boot_time methods optionally
29
- takes a host name as a single argument. The default is localhost.
30
-
31
- The current time, users and load average are not included in this library
32
- module, even though you may be used to seeing them with the command
33
- line version of 'uptime'.
34
-
35
- == Known Bugs
36
- None that I am aware of. Please log any bugs you find on the project
37
- website at https://github.com/djberg96/sys-uptime.
38
-
39
- == Questions
40
- "Doesn't Struct::Tms do this?" - No.
41
-
42
- == License
43
- Apache 2.0
44
-
45
- == Copyright
46
- Copyright 2002-2015, Daniel J. Berger
47
-
48
- All Rights Reserved. This module is free software. It may be used,
49
- redistributed and/or modified under the same terms as Ruby itself.
50
-
51
- == Warranty
52
- This library is provided "as is" and without any express or
53
- implied warranties, including, without limitation, the implied
54
- warranties of merchantability and fitness for a particular purpose.
55
-
56
- == Acknowledgements
57
- Andrea Fazzi for help with the FFI version.
58
-
59
- Mike Hall for help with the BSD side of things for the original C code.
60
-
61
- Ola Eriksson, whose source code I shamelessly plagiarized to get a better
62
- implementation for systems that have the utmpx.h header file for the
63
- original C code.
64
-
65
- == Author
66
- Daniel J. Berger
@@ -1,106 +0,0 @@
1
- #####################################################################
2
- # test_sys_uptime.rb
3
- #
4
- # Test suite for sys-uptime. This should generally be run via the
5
- # 'rake test' task, since it handles the pre-setup code for you.
6
- #####################################################################
7
- require 'sys/uptime'
8
- require 'test-unit'
9
- require 'socket'
10
- include Sys
11
-
12
- class TC_Sys_Uptime < Test::Unit::TestCase
13
- test "version is set to expected value" do
14
- assert_equal('0.7.0', Uptime::VERSION)
15
- end
16
-
17
- test "seconds method basic functionality" do
18
- assert_respond_to(Uptime, :seconds)
19
- assert_nothing_raised{ Uptime.seconds }
20
- end
21
-
22
- test "seconds method returns a plausible value" do
23
- assert_kind_of(Integer, Uptime.seconds)
24
- assert_true(Uptime.seconds > 300)
25
- end
26
-
27
- test "minutes method basic functionality" do
28
- assert_respond_to(Uptime, :minutes)
29
- assert_nothing_raised{ Uptime.minutes }
30
- end
31
-
32
- test "minutes method returns a plausible value" do
33
- assert_kind_of(Integer, Uptime.minutes)
34
- assert_true(Uptime.minutes > 5)
35
- end
36
-
37
- test "hours method basic functionality" do
38
- assert_respond_to(Uptime, :hours)
39
- assert_nothing_raised{ Uptime.hours }
40
- end
41
-
42
- test "hours method returns a plausible value" do
43
- assert_kind_of(Integer, Uptime.hours)
44
- assert_true(Uptime.hours > 0)
45
- end
46
-
47
- test "days method basic functionality" do
48
- assert_respond_to(Uptime, :days)
49
- assert_nothing_raised{ Uptime.days }
50
- end
51
-
52
- test "days method returns a plausible value" do
53
- assert_kind_of(Fixnum, Uptime.days)
54
- assert_true(Uptime.days >= 0)
55
- end
56
-
57
- test "uptime method basic functionality" do
58
- assert_respond_to(Uptime, :uptime)
59
- assert_nothing_raised{ Uptime.uptime }
60
- end
61
-
62
- test "uptime method returns a non-empty string" do
63
- assert_kind_of(String, Uptime.uptime)
64
- assert_false(Uptime.uptime.empty?)
65
- end
66
-
67
- test "uptime method does not accept any arguments" do
68
- omit_if(File::ALT_SEPARATOR)
69
- assert_raise(ArgumentError){ Uptime.uptime(1) }
70
- end
71
-
72
- test "uptime accepts a host name on Windows" do
73
- omit_unless(File::ALT_SEPARATOR, "MS Windows only")
74
- assert_nothing_raised{ Uptime.uptime(Socket.gethostname) }
75
- end
76
-
77
- test "dhms method basic functionality" do
78
- assert_respond_to(Uptime, :dhms)
79
- assert_nothing_raised{ Uptime.dhms }
80
- assert_kind_of(Array, Uptime.dhms)
81
- end
82
-
83
- test "dhms method returns an array of four elements" do
84
- assert_false(Uptime.dhms.empty?)
85
- assert_equal(4, Uptime.dhms.length)
86
- end
87
-
88
- test "boot_time method basic functionality" do
89
- assert_respond_to(Uptime, :boot_time)
90
- assert_nothing_raised{ Uptime.boot_time }
91
- end
92
-
93
- test "boot_time method returns a Time object" do
94
- assert_kind_of(Time, Uptime.boot_time)
95
- end
96
-
97
- test "Uptime class cannot be instantiated" do
98
- assert_kind_of(StandardError, Uptime::Error.new)
99
- end
100
-
101
- test "Ensure that ffi functions are private" do
102
- methods = Uptime.methods(false).map{ |e| e.to_s }
103
- assert_false(methods.include?('time'))
104
- assert_false(methods.include?('times'))
105
- end
106
- end