lshw 0.1.0
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 +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/Guardfile +13 -0
- data/LICENSE.txt +21 -0
- data/README.md +59 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/lshw.rb +15 -0
- data/lib/lshw/cpu.rb +23 -0
- data/lib/lshw/disk.rb +27 -0
- data/lib/lshw/memory.rb +17 -0
- data/lib/lshw/memory_bank.rb +27 -0
- data/lib/lshw/network_interface.rb +23 -0
- data/lib/lshw/system.rb +40 -0
- data/lib/lshw/version.rb +3 -0
- data/lshw.gemspec +30 -0
- metadata +160 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 420f0cfcaf1d87af44e4ce48b8907e1dd629f51d
|
4
|
+
data.tar.gz: d26017e37e53ec7111dacabff5dcbfbfe580a565
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 69af2f7c3d4c7a1e00330e7f8f4be3d4990fb1b0ca3b7dfcd5a742c25730a42061a9d2f3f4c44a15c710264146aa6344327dca8a51b16b45fbf5d5de23559fb8
|
7
|
+
data.tar.gz: 0fb593e518172f9d7ce62cc8420233d49f6e7a995036b75a0a2e1a359bc13e5d5cb326164f072563da78c00b919d1140ce68358814160843751c20e878b38d0b
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
clearing :on
|
2
|
+
|
3
|
+
guard :minitest do
|
4
|
+
# with Minitest::Unit
|
5
|
+
watch(%r{^test/(.*)\/?test_(.*)\.rb$})
|
6
|
+
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
7
|
+
watch(%r{^test/test_helper\.rb$}) { 'test' }
|
8
|
+
|
9
|
+
# with Minitest::Spec
|
10
|
+
# watch(%r{^spec/(.*)_spec\.rb$})
|
11
|
+
# watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
12
|
+
# watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
|
13
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Ben LeMasurier
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Lshw
|
2
|
+
|
3
|
+
[](https://travis-ci.org/benlemasurier/lshw)
|
4
|
+
|
5
|
+
A ruby gem for easy access to `lshw -xml` output.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'lshw'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install lshw
|
22
|
+
|
23
|
+
## Example
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'lshw'
|
27
|
+
|
28
|
+
f = File.open('lshw-output.xml')
|
29
|
+
lshw = Lshw::XML(f)
|
30
|
+
f.close
|
31
|
+
|
32
|
+
# view system disks
|
33
|
+
lshw.disks.legnth
|
34
|
+
=> 1
|
35
|
+
lshw.disks.first.vendor
|
36
|
+
=> "DELL"
|
37
|
+
|
38
|
+
lshw.disks.first.serial
|
39
|
+
=> "0092ba6d94a166641b00f667d320b782"
|
40
|
+
|
41
|
+
# cpu information
|
42
|
+
lshw.cpus.length
|
43
|
+
=> 2
|
44
|
+
|
45
|
+
lshw.cpus.first.bits
|
46
|
+
=> 64
|
47
|
+
|
48
|
+
# ram
|
49
|
+
lshw.memory.size
|
50
|
+
=> 137438953472
|
51
|
+
|
52
|
+
lshw.memory.banks.first.size
|
53
|
+
=> 17179869184
|
54
|
+
|
55
|
+
lshw.memory.banks.first.description
|
56
|
+
=> "DIMM DDR3 Synchronous 1866 MHz (0.5 ns)"
|
57
|
+
|
58
|
+
```
|
59
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'lshw'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require 'pry'
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/lshw.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'lshw/version'
|
2
|
+
require 'lshw/system'
|
3
|
+
require 'lshw/cpu'
|
4
|
+
require 'lshw/disk'
|
5
|
+
require 'lshw/memory'
|
6
|
+
require 'lshw/memory_bank'
|
7
|
+
require 'lshw/network_interface'
|
8
|
+
require 'nokogiri'
|
9
|
+
|
10
|
+
module Lshw
|
11
|
+
def self.XML(xml)
|
12
|
+
hw = Nokogiri::XML(xml)
|
13
|
+
Lshw::System.new(hw)
|
14
|
+
end
|
15
|
+
end
|
data/lib/lshw/cpu.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Lshw
|
2
|
+
class CPU
|
3
|
+
def initialize(node)
|
4
|
+
@node = node
|
5
|
+
end
|
6
|
+
|
7
|
+
def bits
|
8
|
+
@node.search("./width[@units='bits']").text.to_i
|
9
|
+
end
|
10
|
+
|
11
|
+
def product
|
12
|
+
@node.search('./product').text
|
13
|
+
end
|
14
|
+
|
15
|
+
def vendor
|
16
|
+
@node.search('./vendor').text
|
17
|
+
end
|
18
|
+
|
19
|
+
def flags
|
20
|
+
@node.search('.//capability').collect { |f| f.attr('id') }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/lshw/disk.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Lshw
|
2
|
+
class Disk
|
3
|
+
def initialize(node)
|
4
|
+
@node = node
|
5
|
+
end
|
6
|
+
|
7
|
+
def description
|
8
|
+
@node.search('./description').text
|
9
|
+
end
|
10
|
+
|
11
|
+
def product
|
12
|
+
@node.search('./product').text
|
13
|
+
end
|
14
|
+
|
15
|
+
def serial
|
16
|
+
@node.search('./serial').text
|
17
|
+
end
|
18
|
+
|
19
|
+
def size
|
20
|
+
@node.search("./size[@units='bytes']").text.to_i
|
21
|
+
end
|
22
|
+
|
23
|
+
def vendor
|
24
|
+
@node.search('./vendor').text
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/lshw/memory.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Lshw
|
2
|
+
class Memory
|
3
|
+
def initialize(node)
|
4
|
+
@node = node
|
5
|
+
end
|
6
|
+
|
7
|
+
def size
|
8
|
+
@node.search('./size').text.to_i
|
9
|
+
end
|
10
|
+
|
11
|
+
def banks
|
12
|
+
@node.search("./node[@class='memory']").collect do |b|
|
13
|
+
::Lshw::MemoryBank.new b
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Lshw
|
2
|
+
class MemoryBank
|
3
|
+
def initialize(node)
|
4
|
+
@node = node
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
@node.attr('id').split(':').last
|
9
|
+
end
|
10
|
+
|
11
|
+
def size
|
12
|
+
@node.search("./size[@units='bytes']").text.to_i
|
13
|
+
end
|
14
|
+
|
15
|
+
def description
|
16
|
+
@node.search('./description').text
|
17
|
+
end
|
18
|
+
|
19
|
+
def product
|
20
|
+
@node.search('./product').text
|
21
|
+
end
|
22
|
+
|
23
|
+
def slot
|
24
|
+
@node.search('./slot').text
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Lshw
|
2
|
+
class NetworkInterface
|
3
|
+
def initialize(node)
|
4
|
+
@node = node
|
5
|
+
end
|
6
|
+
|
7
|
+
def description
|
8
|
+
@node.search('./description').text
|
9
|
+
end
|
10
|
+
|
11
|
+
def mac
|
12
|
+
@node.search('./serial').text
|
13
|
+
end
|
14
|
+
|
15
|
+
def product
|
16
|
+
@node.search('./product').text
|
17
|
+
end
|
18
|
+
|
19
|
+
def speed
|
20
|
+
@node.search("./size[@units='bit/s']|./capacity").text.to_i
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/lshw/system.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Lshw
|
2
|
+
class System
|
3
|
+
CPU_PATH = "//node[@class='processor']"
|
4
|
+
DESCRIPTION_PATH = '/list/node/description'
|
5
|
+
DISKS_PATH = "//node[@id='disk']"
|
6
|
+
MEMORY_PATH = "//node[@id='memory']"
|
7
|
+
NETWORK_PATH = "//node[@class='network' and @handle!='']"
|
8
|
+
PRODUCT_PATH = '/list/node/product'
|
9
|
+
|
10
|
+
@hw = nil
|
11
|
+
|
12
|
+
def initialize(hw)
|
13
|
+
@hw = hw
|
14
|
+
end
|
15
|
+
|
16
|
+
def cpus
|
17
|
+
@hw.search(CPU_PATH).collect { |cpu| ::Lshw::CPU.new cpu }
|
18
|
+
end
|
19
|
+
|
20
|
+
def description
|
21
|
+
@hw.search(DESCRIPTION_PATH).text
|
22
|
+
end
|
23
|
+
|
24
|
+
def disks
|
25
|
+
@hw.search(DISKS_PATH).collect { |disk| ::Lshw::Disk.new disk }
|
26
|
+
end
|
27
|
+
|
28
|
+
def memory
|
29
|
+
::Lshw::Memory.new @hw.search(MEMORY_PATH)
|
30
|
+
end
|
31
|
+
|
32
|
+
def network_interfaces
|
33
|
+
@hw.search(NETWORK_PATH).collect { |i| ::Lshw::NetworkInterface.new i }
|
34
|
+
end
|
35
|
+
|
36
|
+
def product
|
37
|
+
@hw.search(PRODUCT_PATH).text
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/lshw/version.rb
ADDED
data/lshw.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lshw/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'lshw'
|
8
|
+
spec.version = Lshw::VERSION
|
9
|
+
spec.authors = ['Ben LeMasurier']
|
10
|
+
spec.email = ['ben.lemasurier@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'An `lshw` parsing rubygem'
|
13
|
+
spec.description = 'Parses `lshw` output for easy integration'
|
14
|
+
spec.homepage = 'https://github.com/benlemasurier/lshw'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
|
+
spec.add_development_dependency 'rubocop', '~> 0.30'
|
25
|
+
spec.add_development_dependency 'minitest', '~> 5.6'
|
26
|
+
spec.add_development_dependency 'guard', '~> 2.12'
|
27
|
+
spec.add_development_dependency 'guard-minitest', '~> 2.4'
|
28
|
+
|
29
|
+
spec.add_runtime_dependency 'nokogiri', '~> 1.6'
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lshw
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben LeMasurier
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-28 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.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
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: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.30'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.30'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '5.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '5.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.12'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.12'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.4'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.4'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: nokogiri
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.6'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.6'
|
111
|
+
description: Parses `lshw` output for easy integration
|
112
|
+
email:
|
113
|
+
- ben.lemasurier@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".travis.yml"
|
120
|
+
- Gemfile
|
121
|
+
- Guardfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- bin/console
|
126
|
+
- bin/setup
|
127
|
+
- lib/lshw.rb
|
128
|
+
- lib/lshw/cpu.rb
|
129
|
+
- lib/lshw/disk.rb
|
130
|
+
- lib/lshw/memory.rb
|
131
|
+
- lib/lshw/memory_bank.rb
|
132
|
+
- lib/lshw/network_interface.rb
|
133
|
+
- lib/lshw/system.rb
|
134
|
+
- lib/lshw/version.rb
|
135
|
+
- lshw.gemspec
|
136
|
+
homepage: https://github.com/benlemasurier/lshw
|
137
|
+
licenses:
|
138
|
+
- MIT
|
139
|
+
metadata: {}
|
140
|
+
post_install_message:
|
141
|
+
rdoc_options: []
|
142
|
+
require_paths:
|
143
|
+
- lib
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
requirements: []
|
155
|
+
rubyforge_project:
|
156
|
+
rubygems_version: 2.4.6
|
157
|
+
signing_key:
|
158
|
+
specification_version: 4
|
159
|
+
summary: An `lshw` parsing rubygem
|
160
|
+
test_files: []
|