louis 2.0.6 → 2.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 815efeb0963298718c4d7d20b24c90869ac88855
4
- data.tar.gz: 4bddbc7c4bd64cd127fdce911fcbd1317869d9e1
3
+ metadata.gz: 7090e2ccc5dc371c32ba14b4f1a614493b751f30
4
+ data.tar.gz: 4beb1e00fe0a15adddc8a3b81a15f9464c8a0d5d
5
5
  SHA512:
6
- metadata.gz: ea8f89ca4f8a4b54dee5b9ef94098bfcd34c16a8c88a8726b2ce18bfcb3685941d458af73da813382781ceabab434aa97978e7e0425011193d23efda588dfba9
7
- data.tar.gz: 3b3ce0dbee1cb514c754126843e7fa1d199837cda85541f397a35e787ebdca25d56ba2df9d46c1d34c1b06c4497da65dac64efa6150ee8feec4a282392024931
6
+ metadata.gz: 757c160bb189fecddf2b7a6355afb947abe2380b5d3ae63bdca8b82442ee88264c116d516ef841fc6920379429d2b1d2fa00295860888d1efec4f857f148b92d
7
+ data.tar.gz: 47503685ccdf6cba569d9dc27a8561dbeb0c92e7a02417bbcfd3a808ec3487758f542dd2b47fda5d9594d69e4c13d059e2f79a1e317f49b3f05a9822e8eb6465
@@ -1,4 +1,2 @@
1
1
  language: ruby
2
2
  cache: bundler
3
- rvm:
4
- - 2.1.5
@@ -14,16 +14,14 @@ module Louis
14
14
 
15
15
  # Loads the lookup table, parsing out the uncommented non-blank lines into
16
16
  # objects we can compare MACs against to find their vendor.
17
- def self.lookup_table
18
- @lookup_table ||= JSON.parse(File.read(Louis::PARSED_DATA_FILE))
19
- end
17
+ LOOKUP_TABLE = JSON.parse(File.read(Louis::PARSED_DATA_FILE))
20
18
 
21
19
  # Collect the recorded mask and order it appropriately from most specific to
22
20
  # least.
23
21
  #
24
22
  # @param [Array<Fixnum>]
25
23
  def self.mask_keys
26
- @mask_keys ||= lookup_table.keys.map(&:to_i).sort.reverse
24
+ @mask_keys ||= LOOKUP_TABLE.keys.map(&:to_i).sort.reverse
27
25
  end
28
26
 
29
27
  # Returns the name of the vendor that has the most specific prefix
@@ -47,11 +45,11 @@ module Louis
47
45
  end
48
46
 
49
47
  def self.search_table(encoded_mac)
50
- lookup_table.each do |mask, table|
48
+ mask_keys.each{|mask|
49
+ table = LOOKUP_TABLE[mask.to_s]
51
50
  prefix = (encoded_mac & calculate_mask(nil, mask)).to_s
52
51
  return table[prefix] if table.include?(prefix)
53
- end
54
-
52
+ }
55
53
  nil
56
54
  end
57
55
  end
@@ -1,3 +1,3 @@
1
1
  module Louis
2
- VERSION = "2.0.6"
2
+ VERSION = "2.0.7"
3
3
  end
@@ -33,6 +33,9 @@ RSpec.describe Louis do
33
33
  let(:unknown_mac) { 'c5:00:00:00:00:00' }
34
34
  let(:local_mac) { '3e:97:0e' }
35
35
  let(:multicast_mac) { '3d:97:0e' }
36
+ let(:multi_match_mac) { 'E4:95:6E:40:00:00'}
37
+ let(:most_specific_match) { 'Guang Lian Zhi Tong Technology Limited'}
38
+ let(:least_specific_match) { 'IEEE Registration Authority'}
36
39
 
37
40
  it 'should return a hash' do
38
41
  expect(Louis.lookup(base_mac)).to be_a(Hash)
@@ -73,6 +76,11 @@ RSpec.describe Louis do
73
76
  it 'should return "Unknown" as the long vendor string for unknown MAC prefixes' do
74
77
  expect(Louis.lookup(unknown_mac)['long_vendor']).to eq('Unknown')
75
78
  end
79
+
80
+ it 'should return the most specific vendor match for MAC prefixes that match multiple mask keys' do
81
+ expect(Louis.lookup(multi_match_mac)['long_vendor']).to_not eq(least_specific_match)
82
+ expect(Louis.lookup(multi_match_mac)['long_vendor']).to eq(most_specific_match)
83
+ end
76
84
  end
77
85
 
78
86
  # For future reference, these may change and are depedent on the
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: louis
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stelfox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-09 00:00:00.000000000 Z
11
+ date: 2017-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler