LinuxSystemInfo 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 73d92283b612c6974d932ff743685a58d88cd83b
4
+ data.tar.gz: 0ce6cacfa0e87c0b5f4738b65ae771c2d8da767f
5
+ SHA512:
6
+ metadata.gz: be4e3174e0de0eb7a1e6b567a2c4ebc14f247fbee7a637ea2165fbd7733ff7ce907600d34be6c5d7eee7b7b95a03bafde66c997ee5fe1e72f4cc8e68974f0fd2
7
+ data.tar.gz: 605b366086fb81a807555740cad5aff4e0729c3c8e69fe6e975ab12fe6dee896614df78f8f9fec94dc8f96aca82839fa7af6f6b04b041416157ea76c2a9fd3e2
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .idea
16
+ Gemfile.lock
17
+ .ruby-version
18
+ Guardfile
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ - 2.1.5
5
+ - 2.0.0-p598
6
+ - 1.9.3-p551
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Saimon Lovell (from Zen)
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'LinuxSystemInfo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'LinuxSystemInfo'
8
+ spec.version = LinuxSystemInfo::VERSION
9
+ spec.authors = ['Saimon Lovell']
10
+ spec.email = ['staysynchronize@gmail.com']
11
+ spec.summary = %q{Get local linux hardware information.}
12
+ spec.description = %q{This gem gives information about RAM, CPU, HARD Drives and more. Works only on Linux OS.}
13
+ spec.homepage = 'https://github.com/SaimonL/linux-system-info'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.6'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'json', '>= 1.7'
24
+ spec.add_development_dependency 'rspec', '>= 3.0'
25
+ end
data/README.md ADDED
@@ -0,0 +1,292 @@
1
+ # LinuxSystemInfo
2
+
3
+ [![Dependency Status](https://gemnasium.com/SaimonL/linux-system-info.svg)](https://gemnasium.com/SaimonL/linux-system-info)
4
+
5
+ Linux System Info is a gem that allows you to get information about you're linux
6
+ computer. It retrieves information such as CPU, RAM, Hard drive etc. This works
7
+ only for your local computer and for Linux Debain or Redhat based operating system.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'LinuxSystemInfo'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install LinuxSystemInfo
24
+
25
+ ## Usage
26
+
27
+ #### CPU
28
+
29
+ LinuxSystemInfo.cpu
30
+
31
+ ```
32
+ {
33
+ :model=>
34
+ {
35
+ :name => "Intel(R) Core(TM) i7-3537U CPU @ 2.00GHz",
36
+ :number => "58"
37
+ },
38
+ :address_sizes => "36 bits physical, 48 bits virtual",
39
+ :architecture => "x86_64",
40
+ :threads => "2",
41
+ :cores => "2",
42
+ :socket => "1",
43
+ :family => "6",
44
+ :flags => "fpu vme de pse tsc msr pae mce cx8 apic ...",
45
+ :L1=>
46
+ {
47
+ :d => "32K",
48
+ :i => "32K"
49
+ },
50
+ :L2 => "256K",
51
+ :L3 => "4096K"
52
+ }
53
+ ```
54
+
55
+ #### RAM
56
+
57
+ LinuxSystemInfo.memory
58
+
59
+ ```
60
+ {
61
+ :unit => "Megabyte",
62
+ :total => "7431",
63
+ :used => "4550",
64
+ :free => "2881",
65
+ :shared => "493",
66
+ :buffers => "85",
67
+ :cached => "2036"
68
+ }
69
+ ```
70
+
71
+ #### Storage
72
+
73
+ LinuxSystemInfo.storage
74
+
75
+ ```
76
+ {
77
+ "/dev/sda1" =>
78
+ {
79
+ :size => "88G",
80
+ :used => "14G",
81
+ :available => "70G",
82
+ :used_percentage => "17%",
83
+ :mount => "/"
84
+ },
85
+ "/dev/sda8" =>
86
+ {
87
+ :size => "114G",
88
+ :used => "51G",
89
+ :available => "63G",
90
+ :used_percentage => "45%",
91
+ :mount => "/home"
92
+ },
93
+ "/dev/sda6" =>
94
+ {
95
+ :size => "12G",
96
+ :used => "2.0G",
97
+ :available => "9.3G",
98
+ :used_percentage => "18%",
99
+ :mount => "/repos"
100
+ },
101
+ "/dev/sda5" =>
102
+ {
103
+ :size => "23G",
104
+ :used => "3.1G",
105
+ :available => "20G",
106
+ :used_percentage => "14%",
107
+ :mount => "/virtualbox"
108
+ }
109
+ }
110
+ ```
111
+
112
+ #### Connection
113
+
114
+ LinuxSystemInfo.connection
115
+
116
+ ```
117
+ {
118
+ "eth0" =>
119
+ {
120
+ :mac => "80:2f:d5:6b:d5:88",
121
+ :ip => "192.168.1.23",
122
+ :mask => "255.255.255.0",
123
+ :broadcast => "192.168.1.255",
124
+ :ip6 => "fe80::c23f:d5ff:fe6b:d5c8/64"
125
+ }
126
+ }
127
+ ```
128
+
129
+ #### Video
130
+
131
+ LinuxSystemInfo.video
132
+
133
+ ```
134
+ "Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 09)"
135
+ ```
136
+
137
+ #### Audio
138
+
139
+ LinuxSystemInfo.audio
140
+
141
+ ```
142
+ [
143
+ "Intel Corporation Haswell-ULT HD Audio Controller (rev 09)",
144
+ "Intel Corporation Lynx Point-LP HD Audio Controller (rev 04)"
145
+ ]
146
+ ```
147
+
148
+ #### USB
149
+
150
+ LinuxSystemInfo.usb
151
+
152
+ ```
153
+ [
154
+ "Intel Corporation Lynx Point-LP USB xHCI HC (rev 04)",
155
+ "Intel Corporation Lynx Point-LP USB EHCI #1 (rev 04)"
156
+ ]
157
+ ```
158
+
159
+ #### Network
160
+
161
+ LinuxSystemInfo.network
162
+
163
+ ```
164
+ [
165
+ "Intel Corporation Ethernet Connection I218-V (rev 04)",
166
+ "Intel Corporation Wireless 7260 (rev 73)"
167
+ ]
168
+ ```
169
+
170
+ #### Host
171
+
172
+ LinuxSystemInfo.hostname
173
+
174
+ ```
175
+ "example.com"
176
+ ```
177
+
178
+ #### Hash
179
+
180
+ LinuxSystemInfo.to_hash
181
+
182
+ ```
183
+ {
184
+ :hostname => "example.com",
185
+ :cpu=>
186
+ {
187
+ :model=>
188
+ {
189
+ :name => "Intel(R) Core(TM) i5-4250U CPU @ 1.30GHz",
190
+ :number => "69"
191
+ },
192
+ :address_sizes => "39 bits physical, 48 bits virtual",
193
+ :architecture => "x86_64",
194
+ :threads => "2",
195
+ :cores => "2",
196
+ :socket => "1",
197
+ :family => "6",
198
+ :flags => "fpu vme de pse tsc msr pae mce cx8 apic ...",
199
+ :L1=>
200
+ {
201
+ :d => "32K",
202
+ :i => "32K"
203
+ },
204
+ :L2 => "256K",
205
+ :L3 => "3072K"
206
+ },
207
+ :ram=>
208
+ {
209
+ :unit => "Megabyte",
210
+ :total => "15001",
211
+ :used => "4419",
212
+ :free => "10582",
213
+ :shared => "330",
214
+ :buffers => "231",
215
+ :cached => "1836"
216
+ },
217
+ :storage=>
218
+ {
219
+ "/dev/sda1" =>
220
+ {
221
+ :size => "88G",
222
+ :used => "14G",
223
+ :available => "70G",
224
+ :used_percentage => "17%",
225
+ :mount => "/"
226
+ },
227
+ "/dev/sda8" =>
228
+ {
229
+ :size => "114G",
230
+ :used => "51G",
231
+ :available => "63G",
232
+ :used_percentage => "45%",
233
+ :mount => "/home"
234
+ },
235
+ "/dev/sda6" =>
236
+ {
237
+ :size => "12G",
238
+ :used => "2.0G",
239
+ :available => "9.3G",
240
+ :used_percentage => "18%",
241
+ :mount => "/repos"
242
+ },
243
+ "/dev/sda5" =>
244
+ {
245
+ :size => "23G",
246
+ :used => "3.1G",
247
+ :available => "20G",
248
+ :used_percentage => "14%",
249
+ :mount => "/virtualbox"
250
+ }
251
+ },
252
+ :network=>
253
+ [
254
+ "Intel Corporation Ethernet Connection I218-V (rev 04)",
255
+ "Intel Corporation Wireless 7260 (rev 73)"
256
+ ],
257
+ :connection=>
258
+ {
259
+ "eth0" =>
260
+ {
261
+ :mac => "80:2f:d5:6b:d5:88",
262
+ :ip => "192.168.1.23",
263
+ :mask => "255.255.255.0",
264
+ :broadcast => "192.168.1.255",
265
+ :ip6 => "fe80::c23f:d5ff:fe6b:d5c8/64"
266
+ }
267
+ },
268
+ :video => "Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 09)",
269
+ :audio =>
270
+ [
271
+ "Intel Corporation Haswell-ULT HD Audio Controller (rev 09)",
272
+ "Intel Corporation Lynx Point-LP HD Audio Controller (rev 04)"
273
+ ],
274
+ :usb =>
275
+ [
276
+ "Intel Corporation Lynx Point-LP USB xHCI HC (rev 04)",
277
+ "Intel Corporation Lynx Point-LP USB EHCI #1 (rev 04)"
278
+ ]
279
+ }
280
+ ```
281
+
282
+ Notice: to_s prints the hash as JSON what is for printing purpose only.
283
+ Example: LinuxSystemInfo.to_s
284
+
285
+
286
+ ## Contributing
287
+
288
+ 1. Fork it ( https://github.com/[my-github-username]/LinuxSystemInfo/fork )
289
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
290
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
291
+ 4. Push to the branch (`git push origin my-new-feature`)
292
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ Dir.glob('tasks/**/*.rake').each(&method(:import))
4
+
5
+ task default: :spec
@@ -0,0 +1,3 @@
1
+ module LinuxSystemInfo
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,148 @@
1
+ require 'LinuxSystemInfo/version'
2
+
3
+ module LinuxSystemInfo
4
+ class << self
5
+ def connection
6
+ output = Hash.new
7
+ network = `ifconfig`
8
+ network = network.split("\n\n")
9
+
10
+ network.each do |data|
11
+ interface = data.scan(/^[a-z]+\d?/).first
12
+ next if interface == 'lo'
13
+ next if data.match(/addr:(\d+\.)+\d+/).to_s.sub('addr:', '').empty?
14
+ output[interface] = {
15
+ :mac => data.match(/HWaddr [a-z0-9:]+/).to_s.sub('HWaddr ', ''),
16
+ :ip => data.match(/inet addr:(\d+\.)+\d+/).to_s.sub('inet addr:', ''),
17
+ :mask => data.match(/Mask:(\d+\.?)+/).to_s.sub('Mask:', ''),
18
+ :broadcast => data.match(/Bcast:(\d+\.?)+/).to_s.sub('Bcast:', ''),
19
+ :ip6 => data.match(/inet6 addr: (([a-z]|\d)+([a-z]|\d)+(:|::)+)+(([a-z]|\d)+(\/)*([a-z]|\d)+)/).to_s.sub('inet6 addr:', '').strip
20
+ }
21
+ end
22
+ output
23
+ end
24
+
25
+ def cpu
26
+ cpu = `lscpu`
27
+ cpu = cpu.split("\n")
28
+
29
+ cpu_detail = `cat /proc/cpuinfo`
30
+ cpu_detail = cpu_detail.split("\n")
31
+
32
+ {
33
+ :model => {
34
+ :name => cpu_detail.grep(/model name/).first.split(':').last,
35
+ :number => cpu.grep(/Model/).first.split.last
36
+ },
37
+ :address_sizes => cpu_detail.grep(/address sizes/).first.split(':').last,
38
+ :architecture => cpu.grep(/Architecture/).first.split.last,
39
+ :threads => cpu.grep(/Thread/).first.split.last,
40
+ :cores => cpu.grep(/Core/).first.split.last,
41
+ :socket => cpu.grep(/Socket/).first.split.last,
42
+ :family => cpu.grep(/family/).first.split.last,
43
+ :flags => cpu_detail.grep(/flags/).first.split(':').last,
44
+ :L1 => {
45
+ :d => cpu.grep(/L1d cache/).first.split.last,
46
+ :i => cpu.grep(/L1i cache/).first.split.last
47
+ },
48
+ :L2 => cpu.grep(/L2 cache/).first.split.last,
49
+ :L3 => cpu.grep(/L3 cache/).first.split.last
50
+ }
51
+ end
52
+
53
+ def memory
54
+ ram = `free -m`
55
+ ram = ram.split("\n")[1].split
56
+ {
57
+ :unit => 'Megabyte',
58
+ :total => ram[1],
59
+ :used => ram[2],
60
+ :free => ram[3],
61
+ :shared => ram[4],
62
+ :buffers => ram[5],
63
+ :cached => ram[6]
64
+ }
65
+ end
66
+
67
+ def storage
68
+ output = Hash.new
69
+ storage = `df -h`
70
+ storage = storage.split("\n")
71
+ storage.each do |file|
72
+ file = file.split
73
+ next if file[0][0..4] != '/dev/'
74
+ output[file[0]] = {
75
+ :size => file[1],
76
+ :used => file[2],
77
+ :available => file[3],
78
+ :used_percentage => file[4],
79
+ :mount => file[5]
80
+ }
81
+ end
82
+ output
83
+ end
84
+
85
+ def video
86
+ video = `lspci`
87
+ video = video.split("\n").find { |e| /VGA/ =~ e }
88
+ video.split(':')[2].strip
89
+ end
90
+
91
+ def audio
92
+ data = Array.new
93
+ audio = `lspci`
94
+ audios = audio.split("\n").grep /Audio/
95
+ audios.each do |audio|
96
+ audio = audio.split(':')
97
+ data.push audio[2].strip
98
+ end
99
+ data
100
+ end
101
+
102
+ def usb
103
+ data = Array.new
104
+ usb = `lspci`
105
+ usb = usb.split("\n")
106
+ usbs = usb.grep /USB/
107
+ usbs.each do |usb|
108
+ usb = usb.split(':')
109
+ data.push usb[2].strip
110
+ end
111
+ data
112
+ end
113
+
114
+ def network
115
+ data = Array.new
116
+ connection = `lspci`
117
+ connection = connection.split("\n")
118
+ connections = connection.grep /(Network|Ethernet)/
119
+ connections.each do |connection|
120
+ connection = connection.split(':')
121
+ data.push connection[2].strip
122
+ end
123
+ data
124
+ end
125
+
126
+ def hostname
127
+ `hostname`.strip
128
+ end
129
+
130
+ def to_hash
131
+ {
132
+ :hostname => hostname,
133
+ :cpu => cpu,
134
+ :ram => memory,
135
+ :storage => storage,
136
+ :network => network,
137
+ :connection => connection,
138
+ :video => video,
139
+ :audio => audio,
140
+ :usb => usb
141
+ }
142
+ end
143
+
144
+ def to_s
145
+ JSON.pretty_generate to_hash
146
+ end
147
+ end
148
+ end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'With connection info' do
4
+ before(:all) do
5
+ @connection = LinuxSystemInfo.connection
6
+ end
7
+
8
+ describe 'the returned value' do
9
+ it 'will have proper ips' do
10
+ expect(@connection.first.last.length).to eq 5
11
+ end
12
+
13
+ it 'will have proper mac address' do
14
+ expect(@connection.first.last[:mac]).to match /([a-z]|\d|:)+/
15
+ end
16
+
17
+ it 'will have proper ip address' do
18
+ expect(@connection.first.last[:ip]).to match /(\d|\.)+/
19
+ end
20
+
21
+ it 'will have proper mask' do
22
+ expect(@connection.first.last[:mask]).to match /(\d|\.)+/
23
+ end
24
+
25
+ it 'will have proper broadcast' do
26
+ expect(@connection.first.last[:broadcast]).to match /(\d|\.)+/
27
+ end
28
+ end
29
+ end
data/spec/cpu_spec.rb ADDED
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'With cpu info' do
4
+ before(:all) do
5
+ @cpu = LinuxSystemInfo.cpu
6
+ end
7
+
8
+ describe 'the returned value' do
9
+ it 'will have models' do
10
+ expect(@cpu[:model].length).to eq 2
11
+ end
12
+
13
+ it 'will have model name' do
14
+ expect(@cpu[:model][:name]).to_not be_empty
15
+ end
16
+
17
+ it 'will have model number' do
18
+ expect(@cpu[:model][:number]).to_not be_empty
19
+ end
20
+
21
+ it 'will have address size' do
22
+ expect(@cpu[:address_sizes]).to include 'bits'
23
+ end
24
+
25
+ it 'will have architecture' do
26
+ expect(@cpu[:architecture]).to_not be_empty
27
+ end
28
+
29
+ it 'will have threads' do
30
+ expect(@cpu[:threads].to_i).to be >= 0
31
+ end
32
+
33
+ it 'will have cores' do
34
+ expect(@cpu[:cores].to_i).to be > 0
35
+ end
36
+
37
+ it 'will have socket' do
38
+ expect(@cpu[:socket].to_i).to be > 0
39
+ end
40
+
41
+ it 'will have family' do
42
+ expect(@cpu[:family]).to_not be_nil
43
+ end
44
+
45
+ it 'will have flags' do
46
+ expect(@cpu[:flags]).to_not be_nil
47
+ end
48
+
49
+ it 'will have L1d' do
50
+ expect(@cpu[:L1][:d]).to match /\d+K/
51
+ end
52
+
53
+ it 'will have L1i' do
54
+ expect(@cpu[:L1][:i]).to match /\d+K/
55
+ end
56
+
57
+ it 'will have L2' do
58
+ expect(@cpu[:L2]).to match /\d+K/
59
+ end
60
+
61
+ it 'will have L3' do
62
+ expect(@cpu[:L3]).to match /\d+K/
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'With network info' do
4
+ before(:all) do
5
+ @network = LinuxSystemInfo.network
6
+ end
7
+
8
+ describe 'the returned value' do
9
+ it 'will have one or more network' do
10
+ expect(@network.length).to be > 0
11
+ end
12
+
13
+ it 'will have network indo' do
14
+ expect(@network.first).to_not be_nil
15
+ end
16
+ end
17
+ end
data/spec/ram_spec.rb ADDED
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'With memory info' do
4
+ before(:all) do
5
+ @ram = LinuxSystemInfo.memory
6
+ end
7
+
8
+ describe 'the returned value' do
9
+ it 'will have measurement unit' do
10
+ expect(@ram[:unit]).to eq 'Megabyte'
11
+ end
12
+
13
+ it 'will have valid total' do
14
+ expect(@ram[:total].to_i).to be > 64
15
+ end
16
+
17
+ it 'will have valid used' do
18
+ expect(@ram[:used].to_i).to be > 64
19
+ end
20
+
21
+ it 'will have valid free' do
22
+ expect(@ram[:free].to_i).to be >= 0
23
+ end
24
+
25
+ it 'will have valid shared' do
26
+ expect(@ram[:shared].to_i).to be >= 0
27
+ end
28
+
29
+ it 'will have valid buffers' do
30
+ expect(@ram[:buffers].to_i).to be >= 0
31
+ end
32
+
33
+ it 'will have valid cached' do
34
+ expect(@ram[:buffers].to_i).to be >= 0
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,4 @@
1
+ require 'LinuxSystemInfo'
2
+
3
+ RSpec.configure do |config|
4
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'With storage info' do
4
+ before(:all) do
5
+ @storage = LinuxSystemInfo.storage
6
+ end
7
+
8
+ describe 'the returned value' do
9
+ it 'will have hard drives' do
10
+ expect(@storage.length).to be >= 1
11
+ end
12
+
13
+ it 'will have 5 units per drive' do
14
+ expect(@storage.first.last.length).to eq 5
15
+ end
16
+
17
+ it 'will have valid size' do
18
+ expect(@storage.first.last[:size]).to match /\d+(G|M)/
19
+ end
20
+
21
+ it 'will have valid used' do
22
+ expect(@storage.first.last[:used]).to match /\d+(G|M)/
23
+ end
24
+
25
+ it 'will have valid available' do
26
+ expect(@storage.first.last[:available]).to match /\d+(G|M)/
27
+ end
28
+
29
+ it 'will have valid used_percentage' do
30
+ expect(@storage.first.last[:used_percentage]).to match /\d+%/
31
+ end
32
+
33
+ it 'will have valid mount point' do
34
+ expect(File.exist?(@storage.first.last[:mount])).to eq true
35
+ end
36
+
37
+ end
38
+ end
data/spec/usb_spec.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'With usb info' do
4
+ before(:all) do
5
+ @usb = LinuxSystemInfo.usb
6
+ end
7
+
8
+ describe 'the returned value' do
9
+ it 'will have one or more usb' do
10
+ expect(@usb.length).to be > 0
11
+ end
12
+
13
+ it 'will have usb indo' do
14
+ expect(@usb.first).to_not be_nil
15
+ end
16
+ end
17
+ end
data/tasks/rspec.rake ADDED
@@ -0,0 +1,3 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec)
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: LinuxSystemInfo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Saimon Lovell
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: This gem gives information about RAM, CPU, HARD Drives and more. Works
70
+ only on Linux OS.
71
+ email:
72
+ - staysynchronize@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - LinuxSystemInfo.gemspec
83
+ - README.md
84
+ - Rakefile
85
+ - lib/LinuxSystemInfo.rb
86
+ - lib/LinuxSystemInfo/version.rb
87
+ - spec/connection_spec.rb
88
+ - spec/cpu_spec.rb
89
+ - spec/network_spec.rb
90
+ - spec/ram_spec.rb
91
+ - spec/spec_helper.rb
92
+ - spec/storage_spec.rb
93
+ - spec/usb_spec.rb
94
+ - tasks/rspec.rake
95
+ homepage: https://github.com/SaimonL/linux-system-info
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.4.5
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: Get local linux hardware information.
119
+ test_files:
120
+ - spec/connection_spec.rb
121
+ - spec/cpu_spec.rb
122
+ - spec/network_spec.rb
123
+ - spec/ram_spec.rb
124
+ - spec/spec_helper.rb
125
+ - spec/storage_spec.rb
126
+ - spec/usb_spec.rb