macvendors 0.0.1 → 0.0.2
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 +4 -4
- data/CHANGELOG +5 -1
- data/LICENSE +21 -0
- data/README.md +2 -0
- data/example.rb +15 -0
- data/lib/macvendors.rb +27 -14
- data/lib/macvendors/version.rb +1 -1
- data/macvendors.gif +0 -0
- data/tests/test.rb +2 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be531cefa8236a693899463d3529ecd50a423571
|
4
|
+
data.tar.gz: 5540d0154345e146786462357cff3f62c0944942
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f934904db785a6b550686b090ac173a50ff0d572acd6ae5147da78ec54e4ede20b6108046aae4c78d28669e0caf5211a760f105e4daf4bbb9f676f144a0383b
|
7
|
+
data.tar.gz: 9bc68c81a4a2029ab612dd16026f86ce74c81e9c76147f02a06c50d195fd73c2e15e08e31dbb37a981bb15616b244dc7d4dfe95a0a4cb524e351c0c330ca655e
|
data/CHANGELOG
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 Bryan Lim
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
data/example.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'macvendors'
|
2
|
+
|
3
|
+
input = ""
|
4
|
+
output = ""
|
5
|
+
|
6
|
+
#take in the csv
|
7
|
+
data = CSV.read(input)
|
8
|
+
mac_addresses = data["mac"]
|
9
|
+
puts "This csv contains no mac address column named 'mac'" if mac_addresses.count == 0
|
10
|
+
MacVendors.setup
|
11
|
+
|
12
|
+
#output
|
13
|
+
mac_addresses.times.each_with_index do |index, row|
|
14
|
+
csv << MacVendors.find(row)
|
15
|
+
end
|
data/lib/macvendors.rb
CHANGED
@@ -12,15 +12,17 @@ module MacVendors
|
|
12
12
|
|
13
13
|
desc :find, "find the vendor for this mac address"
|
14
14
|
def find value
|
15
|
-
MacVendors.
|
15
|
+
MacVendors.setup
|
16
|
+
puts MacVendors.find2(value)
|
16
17
|
end
|
17
18
|
|
18
19
|
desc :update, "update/replace the mac address csv from ieee"
|
19
20
|
def update
|
21
|
+
MacVendors.setup
|
20
22
|
MacVendors.update()
|
21
23
|
end
|
22
24
|
|
23
|
-
desc :install, "install your first
|
25
|
+
desc :install, "install your first vendors"
|
24
26
|
def install
|
25
27
|
MacVendors.download()
|
26
28
|
end
|
@@ -30,33 +32,44 @@ module MacVendors
|
|
30
32
|
private
|
31
33
|
|
32
34
|
def self.update
|
33
|
-
path_to_file = "
|
35
|
+
path_to_file = "#{Dir.home}/.macvendors/oui.csv"
|
34
36
|
File.delete(path_to_file) if File.exist?(path_to_file)
|
35
|
-
puts "
|
37
|
+
puts "vendors removed."
|
36
38
|
MacVendors.download()
|
37
39
|
end
|
38
40
|
|
39
41
|
|
40
42
|
def self.download
|
41
|
-
Dir.mkdir ".macvendors" if Dir
|
42
|
-
open("
|
43
|
+
Dir.mkdir "#{Dir.home}/.macvendors" if File.directory?("#{Dir.home}/.macvendors") == false
|
44
|
+
open("#{Dir.home}/.macvendors/oui.csv", 'wb') do |file|
|
43
45
|
file << open('http://standards-oui.ieee.org/oui/oui.csv').read
|
44
46
|
end
|
45
|
-
puts "downloaded
|
47
|
+
puts "downloaded vendors"
|
46
48
|
end
|
47
49
|
|
48
50
|
def self.search value
|
49
|
-
|
50
|
-
|
51
|
-
column = answer["Assignment"]
|
52
|
-
name = answer["Organization Name"]
|
51
|
+
column = @answer["Assignment"]
|
52
|
+
name = @answer["Organization Name"]
|
53
53
|
hash = Hash[column.map.with_index.to_a]
|
54
|
+
final_answer = ""
|
54
55
|
if hash[value] != nil
|
55
|
-
|
56
|
+
final_answer = name[hash[value]]
|
56
57
|
else
|
57
|
-
|
58
|
+
final_answer = nil # "something went wrong."
|
58
59
|
end
|
59
|
-
return
|
60
|
+
return final_answer
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.setup
|
64
|
+
path = "#{Dir.home}/.macvendors/oui.csv"
|
65
|
+
@answer = CSV.read(path,:headers=> true, :encoding => "ISO8859-1:utf-8") #TODO: is this a data
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.find2 string
|
69
|
+
MacVendors.setup
|
70
|
+
string = string.gsub(":", "")
|
71
|
+
string = string.gsub("-", "")
|
72
|
+
return search(string[0..5].upcase)
|
60
73
|
end
|
61
74
|
|
62
75
|
def self.find string
|
data/lib/macvendors/version.rb
CHANGED
data/macvendors.gif
ADDED
Binary file
|
data/tests/test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: macvendors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Lim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -50,15 +50,18 @@ files:
|
|
50
50
|
- CHANGELOG
|
51
51
|
- CODE_OF_CONDUCT.md
|
52
52
|
- Gemfile
|
53
|
+
- LICENSE
|
53
54
|
- LICENSE.txt
|
54
55
|
- README.md
|
55
56
|
- Rakefile
|
56
57
|
- bin/console
|
57
58
|
- bin/macvendors
|
58
59
|
- bin/setup
|
60
|
+
- example.rb
|
59
61
|
- lib/macvendors.rb
|
60
62
|
- lib/macvendors/version.rb
|
61
63
|
- macvendors.gemspec
|
64
|
+
- macvendors.gif
|
62
65
|
- tests/test.rb
|
63
66
|
homepage: https://github.com/ytbryan/macvendors
|
64
67
|
licenses:
|