sys-uptime 0.7.1 → 0.7.4

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: c8910d9d6c47f4115fa0fd05d20c8d1ce4f7f5a5
4
- data.tar.gz: d611a20b013cc367f1672d2f37e11167583fc906
2
+ SHA256:
3
+ metadata.gz: 8bf1eb6f4cd27a729aaa980cbf240ffc981fbab03cf25e7cc1e14a01d2a980ae
4
+ data.tar.gz: 97b84f93298523a7449fd61097dc791ee9d89c573afa4e67ec5521705ff03303
5
5
  SHA512:
6
- metadata.gz: e241b2b7fce39af5831175f02c443fb661cbca0964450440b5b1efc4265f7b8cabd1cd6041271f1b63f191460ea481037ff4185af75bc9801622f855a31061e8
7
- data.tar.gz: 83dff6f51136751671eb5ae1c1b4a6a7721902d962258ca1a535bd7ade4c016629043621e1b3f7bff91a84cc481bde5af90bf63e37ce98901a157938c4f025f7
6
+ metadata.gz: 5eff9d33d6c1d85181a1f888f62840013884a9e5f72bdc20a0fd64ca92933645a8384b3181bf884f17e9f4b066abcd4c3510e7289583ca2d975ec1cb897c7cd5
7
+ data.tar.gz: '09a624b51158caf2b4e2d38583cd853455c761ea5e99aa8ae28a3be1fb93591708975d84e7afb27da95e52bc5b87edd56ffb1bee25eb0118bc512f9f41423e1d'
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,17 @@
1
+ == 0.7.3 - 31-Dec-2019
2
+ * Attempting to call Sys::Uptime.new will now raise an error. I thought
3
+ this was already the case, but apparently one of the tests was bad.
4
+ * Added explicit .rdoc extensions to various text files so that github
5
+ will display them nicely.
6
+ * Switched from test-unit to rspec as the testing framework of choice.
7
+ * Updated the gemspec to reflect the filename updates, as well as the
8
+ added development dependency.
9
+
10
+ == 0.7.2 - 4-Nov-2018
11
+ * Added metadata to the gemspec.
12
+ * The VERSION constant is now frozen.
13
+ * Updated cert.
14
+
1
15
  == 0.7.1 - 14-May-2016
2
16
  * Altered internal layout, which also fixed a require bug. Thanks go
3
17
  to jkburges for the spot.
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
data/README.rdoc ADDED
@@ -0,0 +1,67 @@
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
+ require 'sys-uptime'
13
+ include Sys
14
+
15
+ # Get everything
16
+ p Uptime.uptime
17
+ p Uptime.dhms.join(', ')
18
+
19
+ # Get individual units
20
+ p Uptime.days
21
+ p Uptime.hours
22
+ p Uptime.minutes
23
+ p Uptime.seconds
24
+
25
+ # Get the boot time
26
+ p Uptime.boot_time
27
+
28
+ == Notes
29
+ On MS Windows the +Uptime.uptime+ and +Uptime.boot_time+ methods optionally
30
+ takes a host name as a single argument. The default is localhost.
31
+
32
+ The current time, users and load average are not included in this library
33
+ module, even though you may be used to seeing them with the command
34
+ line version of +uptime+.
35
+
36
+ == Known Bugs
37
+ None that I am aware of. Please log any bugs you find on the project
38
+ website at https://github.com/djberg96/sys-uptime.
39
+
40
+ == Questions
41
+ "Doesn't Struct::Tms do this?" - No.
42
+
43
+ == License
44
+ Apache-2.0
45
+
46
+ == Copyright
47
+ Copyright 2002-2019, Daniel J. Berger
48
+
49
+ All Rights Reserved. This module is free software. It may be used,
50
+ redistributed and/or modified under the same terms as Ruby itself.
51
+
52
+ == Warranty
53
+ This library is provided "as is" and without any express or
54
+ implied warranties, including, without limitation, the implied
55
+ warranties of merchantability and fitness for a particular purpose.
56
+
57
+ == Acknowledgements
58
+ Andrea Fazzi for help with the FFI version.
59
+
60
+ Mike Hall for help with the BSD side of things for the original C code.
61
+
62
+ Ola Eriksson, whose source code I shamelessly plagiarized to get a better
63
+ implementation for systems that have the utmpx.h header file for the
64
+ original C code.
65
+
66
+ == Author
67
+ Daniel J. Berger
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rake'
2
2
  require 'rake/clean'
3
3
  require 'rake/testtask'
4
+ require 'rspec/core/rake_task'
4
5
 
5
6
  CLEAN.include("**/*.gem", "**/*.rbx", "**/*.rbc")
6
7
 
@@ -12,9 +13,7 @@ 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.platform = Gem::Platform::CURRENT
16
- spec.platform.cpu = 'universal'
17
- spec.platform.version = nil
16
+ spec.platform = Gem::Platform.new(['universal','mingw32'])
18
17
  else
19
18
  spec.add_dependency('ffi', '>= 1.0.0')
20
19
  end
@@ -30,15 +29,6 @@ namespace 'gem' do
30
29
  end
31
30
 
32
31
  desc "Run the test suite"
33
- Rake::TestTask.new do |t|
34
- if File::ALT_SEPARATOR
35
- t.libs << 'lib/windows'
36
- else
37
- t.libs << 'lib/unix'
38
- end
39
-
40
- t.warning = true
41
- t.verbose = true
42
- end
32
+ RSpec::Core::RakeTask.new(:spec)
43
33
 
44
- 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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Nl9oTjJNv+7/jM
25
+ WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
21
26
  -----END CERTIFICATE-----
@@ -26,7 +26,7 @@ module Sys
26
26
  attach_function :time, [:pointer], :time_t
27
27
  attach_function :times, [:pointer], :clock_t
28
28
 
29
- private_class_method :strerror, :sysconf, :time, :times
29
+ private_class_method :strerror, :sysconf, :time, :times, :new
30
30
 
31
31
  begin
32
32
  attach_function :sysctl, [:pointer, :uint, :pointer, :pointer, :pointer, :size_t], :int
data/lib/sys/uptime.rb CHANGED
@@ -7,6 +7,6 @@ end
7
7
  module Sys
8
8
  class Uptime
9
9
  # The version of the sys-uptime library
10
- VERSION = '0.7.1'
10
+ VERSION = '0.7.4'.freeze
11
11
  end
12
12
  end
@@ -13,6 +13,9 @@ module Sys
13
13
  # Error typically raised in one of the Uptime methods should fail.
14
14
  class Error < StandardError; end
15
15
 
16
+ # You cannot instantiate an instance of Sys::Uptime.
17
+ private_class_method :new
18
+
16
19
  # Returns the boot time as a Time object.
17
20
  #
18
21
  # Example:
@@ -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 'test-unit'
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.4')
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
data/sys-uptime.gemspec CHANGED
@@ -2,17 +2,27 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'sys-uptime'
5
- spec.version = '0.7.1'
5
+ spec.version = '0.7.4'
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.extra_rdoc_files = Dir["*.rdoc"]
16
+ spec.add_development_dependency 'rspec', '~> 3'
17
+
18
+ spec.metadata = {
19
+ 'homepage_uri' => 'https://github.com/djberg96/sys-uptime',
20
+ 'bug_tracker_uri' => 'https://github.com/djberg96/sys-uptime/issues',
21
+ 'changelog_uri' => 'https://github.com/djberg96/sys-uptime/blob/ffi/CHANGES',
22
+ 'documentation_uri' => 'https://github.com/djberg96/sys-uptime/wiki',
23
+ 'source_code_uri' => 'https://github.com/djberg96/sys-uptime',
24
+ 'wiki_uri' => 'https://github.com/djberg96/sys-uptime/wiki'
25
+ }
16
26
 
17
27
  spec.description = <<-EOF
18
28
  The sys-uptime library is a simple interface for gathering uptime
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sys-uptime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -10,28 +10,47 @@ 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/hMxJpotYMgJVHHWrmDcC5Dye2PbnXjTkKf266Zw0PtT9h+lI
19
- S3ts9HO+vaCFSMwFFZmnWJSpQ3CNw2RcHxjWkk9yF7imEM8Kz9ojhiDXzBetdV6M
20
- gr0lV/alUr7TNVBDngbXEfTWscyXh1qd7xZ4EcOdsDktCe5G45N/o3662tPQvJsi
21
- FOF0CM/KuBsa/HL1/eoEmF4B3EKIRfTHrQ3hu20Kv3RJ88QM4ec2+0dd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yrMZXCedutvXNjUolD5r9KGBFSWH1R9u2I3n3SAyFF2yzv/7idQHLJJq
24
+ 74BMnx0FIq6fCpu5slAipvxZ3ZkZpEXZFr3cIBtO1gFvQWW7E/Y3ijliWJS1GQFq
25
+ 058qERadHGu1yu1dojmFRo6W2KZvY9al2yIlbkpDrD5MYQIDAQABo3cwdTAJBgNV
26
+ HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUFZsMapgzJimzsbaBG2Tm8j5e
27
+ AzgwHQYDVR0RBBYwFIESZGpiZXJnOTZAZ21haWwuY29tMB0GA1UdEgQWMBSBEmRq
28
+ YmVyZzk2QGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAW2tnYixXQtKxgGXq
29
+ /3iSWG2bLwvxS4go3srO+aRXZHrFUMlJ5W0mCxl03aazxxKTsVVpZD8QZxvK91OQ
30
+ h9zr9JBYqCLcCVbr8SkmYCi/laxIZxsNE5YI8cC8vvlLI7AMgSfPSnn/Epq1GjGY
31
+ 6L1iRcEDtanGCIvjqlCXO9+BmsnCfEVehqZkQHeYczA03tpOWb6pon2wzvMKSsKH
32
+ ks0ApVdstSLz1kzzAqem/uHdG9FyXdbTAwH1G4ZPv69sQAFAOCgAqYmdnzedsQtE
33
+ 1LQfaQrx0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf
34
+ DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
35
+ ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
36
+ WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
32
37
  -----END CERTIFICATE-----
33
- date: 2016-05-14 00:00:00.000000000 Z
38
+ date:
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'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3'
35
54
  - !ruby/object:Gem::Dependency
36
55
  name: ffi
37
56
  requirement: !ruby/object:Gem::Requirement
@@ -54,35 +73,42 @@ email: djberg96@gmail.com
54
73
  executables: []
55
74
  extensions: []
56
75
  extra_rdoc_files:
57
- - CHANGES
58
- - README
59
- - MANIFEST
76
+ - CHANGES.rdoc
77
+ - MANIFEST.rdoc
78
+ - README.rdoc
60
79
  files:
80
+ - LICENSE
81
+ - sys-uptime.gemspec
82
+ - spec
83
+ - spec/sys_uptime_spec.rb
84
+ - Rakefile
61
85
  - certs
62
86
  - certs/djberg96_pub.pem
63
- - CHANGES
64
87
  - examples
65
88
  - examples/uptime_test.rb
66
89
  - lib
90
+ - lib/sys-uptime.rb
67
91
  - lib/sys
92
+ - lib/sys/uptime.rb
68
93
  - lib/sys/unix
69
94
  - lib/sys/unix/sys
70
95
  - lib/sys/unix/sys/uptime.rb
71
- - lib/sys/uptime.rb
72
96
  - lib/sys/windows
73
97
  - lib/sys/windows/sys
74
98
  - lib/sys/windows/sys/uptime.rb
75
- - lib/sys-uptime.rb
76
- - MANIFEST
77
- - Rakefile
78
- - README
79
- - sys-uptime.gemspec
80
- - test
81
- - test/test_sys_uptime.rb
99
+ - CHANGES.rdoc
100
+ - MANIFEST.rdoc
101
+ - README.rdoc
82
102
  homepage: https://github.com/djberg96/sys-uptime
83
103
  licenses:
84
- - Apache 2.0
85
- metadata: {}
104
+ - Apache-2.0
105
+ metadata:
106
+ homepage_uri: https://github.com/djberg96/sys-uptime
107
+ bug_tracker_uri: https://github.com/djberg96/sys-uptime/issues
108
+ changelog_uri: https://github.com/djberg96/sys-uptime/blob/ffi/CHANGES
109
+ documentation_uri: https://github.com/djberg96/sys-uptime/wiki
110
+ source_code_uri: https://github.com/djberg96/sys-uptime
111
+ wiki_uri: https://github.com/djberg96/sys-uptime/wiki
86
112
  post_install_message:
87
113
  rdoc_options: []
88
114
  require_paths:
@@ -98,10 +124,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
124
  - !ruby/object:Gem::Version
99
125
  version: '0'
100
126
  requirements: []
101
- rubyforge_project:
102
- rubygems_version: 2.6.4
127
+ rubygems_version: 3.0.6
103
128
  signing_key:
104
129
  specification_version: 4
105
130
  summary: A Ruby interface for getting system uptime information.
106
131
  test_files:
107
- - test/test_sys_uptime.rb
132
+ - 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.1', 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