machineid 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f543f2c6853d73fcf8c80cf1081010f8df0d27986ed8c1a945d294c04fc48ed0
4
+ data.tar.gz: a61b7cdafdc1112a9c37ea292feadd0f98f3681445932df19d91a78f3147091e
5
+ SHA512:
6
+ metadata.gz: 4dae7049822c2194cc0b119eca69aa0bb54bdc9f6ab31a481988db97af3fea07a0dad10f41f37c2411cfc743187cf334b6dfb22816000577b12aca7ca910b59e
7
+ data.tar.gz: 234213c70b9a9986786190c6651601142e00b3061738e025e33e53d24b7436b9e06de34f3018e89eaf2d19bf35a19e15543f385b38af50d7f34934deea04ff5c
data/CHANGELOG.md ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+
2
+ ## MachineID
data/Rakefile ADDED
File without changes
@@ -0,0 +1,23 @@
1
+ module Utils
2
+ class OS
3
+ def windows?
4
+ (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
5
+ end
6
+
7
+ def mac?
8
+ (/darwin/ =~ RUBY_PLATFORM) != nil
9
+ end
10
+
11
+ def unix?
12
+ self.windows?
13
+ end
14
+
15
+ def linux?
16
+ self.unix? and not self.mac?
17
+ end
18
+
19
+ def jruby?
20
+ RUBY_ENGINE == 'jruby'
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module MachineID
2
+ VERSION = '1.0.0'
3
+ end
data/lib/machineid.rb ADDED
@@ -0,0 +1,79 @@
1
+ require 'digest'
2
+
3
+
4
+ module MachineID
5
+ class << self
6
+ def host_os
7
+ RbConfig::CONFIG['host_os']
8
+ end
9
+
10
+ def windows?
11
+ (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
12
+ end
13
+
14
+ def bsd?
15
+ self.host_os =~ /bsd/
16
+ end
17
+
18
+ def windows64?
19
+ self.windows? && (/x64/ =~ self.host_os) != nil
20
+ end
21
+
22
+ def mac?
23
+ self.host_os =~ /mac|darwin/
24
+ end
25
+
26
+ def unix?
27
+ self.host_os =~ /mswin|mingw/
28
+ end
29
+
30
+ def linux?
31
+ self.host_os =~ /linux|cygwin/
32
+ end
33
+
34
+
35
+ def ID?(original = false)
36
+ self.getMachineId?(original)
37
+ end
38
+
39
+ def hash?(guid)
40
+ Digest::SHA256.hexdigest(guid)
41
+ end
42
+
43
+ def windowCmd
44
+ cmd = '\\REG.exe QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography /v MachineGuid'
45
+ return cmd if self.win64?
46
+ return "%windir%\\System32#{cmd}"
47
+ end
48
+
49
+ def getCommand
50
+ return 'ioreg -rd1 -c IOPlatformExpertDevice' if self.mac?
51
+ return self.windowCmd if self.mac?
52
+ return 'kenv -q smbios.system.uuid || sysctl -n kern.hostuuid' if self.bsd?
53
+ return '( cat /var/lib/dbus/machine-id /etc/machine-id 2> /dev/null || hostname ) | head -n 1 || :' if self.linux?
54
+
55
+ end
56
+
57
+ def expose?(result)
58
+ if self.mac?
59
+ result.split('IOPlatformUUID')[1].split("\n")[0].gsub(/\=|\s+|\"/i, '')
60
+ elsif self.windows?
61
+ result.split('REG_SZ')[1].replace(/\r+|\n+|\s+/i, '')
62
+ elsif self.linux?
63
+ result.replace(/\r+|\n+|\s+/i, '')
64
+ elsif self.bsd?
65
+ result.replace(/\r+|\n+|\s+/i, '')
66
+ else
67
+ 'Platform not supported. Please report your platform and architecture in a new Github issue'
68
+ exit(1)
69
+ end
70
+ end
71
+
72
+ def getMachineId?(original = false)
73
+ cmd = self.getCommand
74
+ result = self.expose?(`#{cmd}`)
75
+ return result if original == true
76
+ self.hash?(result)
77
+ end
78
+ end
79
+ end
data/machineid.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ require File.expand_path('lib/machineid/version', __dir__)
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'machineid'
5
+ spec.version = MachineID::VERSION
6
+ spec.authors = ['Aleem Isiaka']
7
+ spec.email = ['aleemisiaka@gmail.com']
8
+ spec.description = "Ruby GEM to Get a machine's ID"
9
+ spec.summary = "Use machineid in your Ruby projects"
10
+ spec.homepage= 'https://github.com/limistah/machineid'
11
+ spec.license = 'MIT'
12
+ spec.platform = Gem::Platform::RUBY
13
+ spec.required_ruby_version = '>= 2.5.0'
14
+
15
+ spec.files = Dir['README.md', 'LICENSE', 'CHANGELOG.md', 'lib/**/*.rb', 'lib/**/*.rake', 'machineid.gemspec', '.github/*.md', 'Gemfile', 'Rakefile']
16
+
17
+ spec.extra_rdoc_files = ['README.md']
18
+
19
+ spec.add_dependency 'rubyzip', '~> 2.3'
20
+
21
+ spec.add_development_dependency 'rubocop', '~> 0.60'
22
+ spec.add_development_dependency 'rubocop-performance', '~> 1.5'
23
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.37'
24
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: machineid
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Aleem Isiaka
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-02-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubyzip
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.60'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.60'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop-performance
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.37'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.37'
69
+ description: Ruby GEM to Get a machine's ID
70
+ email:
71
+ - aleemisiaka@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files:
75
+ - README.md
76
+ files:
77
+ - CHANGELOG.md
78
+ - Gemfile
79
+ - README.md
80
+ - Rakefile
81
+ - lib/machineid.rb
82
+ - lib/machineid/OS.rb
83
+ - lib/machineid/version.rb
84
+ - machineid.gemspec
85
+ homepage: https://github.com/limistah/machineid
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: 2.5.0
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubygems_version: 3.0.3.1
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Use machineid in your Ruby projects
108
+ test_files: []