macker 0.1.0 → 0.1.1

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: 3345ba78a64ef11813ffb3c882c6121a7424b201
4
- data.tar.gz: 5932cb24ba0b384b2427ac23be31167c517dcc4e
3
+ metadata.gz: e470b678db144594ba3d9f1b6bbe364604184da3
4
+ data.tar.gz: c4a79a52c78a08699c27033f6cc04acf7de3581a
5
5
  SHA512:
6
- metadata.gz: 22f361008a20f33c591574ddf727130ac3dd6d009784b93132f2aa02bda095e73ee384dd6bcc9ef0dd025ec7d927e75d4128c9c36dea4e7e9b78a8034d6f1bf2
7
- data.tar.gz: b136c91fd4487d7feda49763ffc397a993efd252d96d31faffc8092b98139c5415282b61e8452d9d2ae1fab1582372610ebab4fd9dca89249aba663bbcafb7cd
6
+ metadata.gz: 9c1cb71bae8c6ba81f37f13e9fafe284ac12f292e34b199c6a15daea4131603c457ef8ed372d97255230a4c2c7b9597ee29e2398b788dc8daa4a5fc553a6392d
7
+ data.tar.gz: 45fd38ba9cbf223cb97b61841322014b68deb5f46c45dc4b8381af2036cff73e08a7f231429f3b33c20464566b5bcad9af6dd3b301e732a06b18e83f966fe31b
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Macker
1
+ # Macker (The Mac Maker)
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/macker.svg)](https://rubygems.org/gems/macker)
4
4
  [![Gem](https://img.shields.io/gem/dt/macker.svg?maxAge=2592000)](https://rubygems.org/gems/macker)
@@ -44,10 +44,10 @@ Rails users can create a file `macker.rb` in `config/initializers` to load the o
44
44
 
45
45
  ```ruby
46
46
  Maker.configure do |config|
47
- config.oui_full_url = 'http://standards-oui.ieee.org/oui.txt', # Full URL of OUI text file
47
+ config.oui_full_url = 'http://linuxnet.ca/ieee/oui.txt', # Full URL of OUI text file
48
48
  config.user_agent = 'Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0', # A common user agent
49
49
  config.ttl_in_seconds = 86_400, # Will expire the vendors in one day
50
- config.cache: = File.expand_path(File.dirname(__FILE__) + '/../../data/oui_*.txt'), # Can be a string, pathname or proc
50
+ config.cache = File.expand_path(File.dirname(__FILE__) + '/../../data/oui_*.txt'), # Can be a string, pathname or proc
51
51
  config.auto_expiration = true # Expiration can be checked manually
52
52
  end
53
53
  ```
@@ -84,6 +84,9 @@ mac.to_s
84
84
 
85
85
  mac = Macker.generate(iso_code: 'US')
86
86
  # => #<Macker::Address:0x000000046b86f0 @val=161304050786, @name="The Weather Channel", @address=["Mail Stop 500", "Atlanta Ga 30339", "Us"], @iso_code="US">
87
+
88
+ # Raise an exception
89
+ Macker.generate!(iso_code: 'HELLO')
87
90
  ```
88
91
 
89
92
  ### Lookup MAC address
@@ -99,6 +102,7 @@ Macker.lookup(mac)
99
102
  Macker.lookup('64-E6-82-E5-CC-58')
100
103
  Macker.lookup('64E682E5CC58')
101
104
  Macker.lookup(110941201353816)
105
+ Macker.lookup!(110941201353816)
102
106
  ```
103
107
 
104
108
  ### MAC address
@@ -107,7 +111,7 @@ mymac = Macker.lookup('64-E6-82-E5-CC-58')
107
111
  mymac.class
108
112
  # => Macker::Address
109
113
 
110
- # Some method of the class
114
+ # Some methods of the address class
111
115
  mymac.name
112
116
  mymac.address
113
117
  mymac.iso_code
@@ -129,6 +133,46 @@ mymac.prefix
129
133
  mymac.full_address
130
134
  ```
131
135
 
136
+ ### Cache control
137
+
138
+ ```ruby
139
+ # Update OUI from cache (careful)
140
+ Macker.update
141
+ # => 2017-07-03 13:03:00 +0200
142
+
143
+ # Update OUI from remote (straight)
144
+ Macker.update(true)
145
+ # => 2017-07-03 13:04:00 +0200
146
+
147
+ # Vendor table with all base16 MAC prefixes as keys
148
+ Macker.prefix_table
149
+ # => "F8DA0C"=>{:name=>"Hon Hai..."}, ...
150
+
151
+ # Vendor table with all country iso codes as keys
152
+ Macker.iso_code_table
153
+ # => "CN"=>[{:name=>"Hon Hai..."} ... ]
154
+
155
+ # Vendor table with all country vendor names as keys
156
+ Macker.vendor_table
157
+ # => "Apple, Inc."=>[{:prefix=>...} ... ]
158
+
159
+ Macker.expire!
160
+ # => false
161
+
162
+ Macker.expired?
163
+ # => false
164
+
165
+ Macker.stale?
166
+ # => false
167
+
168
+ Macker.vendors_expiration
169
+ # => 2017-07-04 13:04:00 +0200
170
+
171
+ # Get configuration of Macker
172
+ Macker.config
173
+ # => #<Macker::Config:0x0000000124ff30 @config=#...>>
174
+ ```
175
+
132
176
  ## Contributors
133
177
 
134
178
  * Inspired by MacVendor [github.com/uceem/mac_vendor](https://github.com/uceem/mac_vendor).
@@ -101,7 +101,7 @@ module Macker
101
101
  # @return [Address] MAC address with data
102
102
  def generate(opts = {})
103
103
  expire! if config.auto_expiration
104
- return generate_by_iso_code(opts.delete(:iso_code), opts) if opts[:iso_code] && opts[:iso_code].length == 2
104
+ return generate_by_iso_code(opts.delete(:iso_code), opts) if opts[:iso_code]
105
105
  vendor = opts.delete(:vendor)
106
106
  case vendor
107
107
  when nil, false
@@ -257,6 +257,7 @@ module Macker
257
257
  base16_fields = vendor.strip.split("\n")[1].split("\t")
258
258
  mac_prefix = Address.new(base16_fields[0].strip[0..5]).prefix
259
259
  address = vendor.strip.delete("\t").split("\n")
260
+ iso_code = address[-1].strip
260
261
  next unless @prefix_table[mac_prefix].nil?
261
262
  @prefix_table[mac_prefix] = { name: base16_fields[-1]
262
263
  .strip
@@ -273,7 +274,7 @@ module Macker
273
274
  .map(&:capitalize)
274
275
  .join(' ')
275
276
  },
276
- iso_code: address[-1].strip.upcase
277
+ iso_code: iso_code.length == 2 ? iso_code.upcase : nil
277
278
  }
278
279
  end
279
280
  @iso_code_table = @prefix_table.each_with_object({}) { |(key, value), out| (out[value[:iso_code]] ||= []) << value.merge(prefix: key) }
@@ -3,5 +3,5 @@
3
3
  # Macker namespace
4
4
  module Macker
5
5
  # Macker version
6
- VERSION = '0.1.0'.freeze
6
+ VERSION = '0.1.1'.freeze
7
7
  end
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "https://github.com/phlegx/#{spec.name}"
14
14
 
15
15
  spec.summary = 'Real MAC addresses maker.'
16
- spec.description = 'Real MAC addresses generator and vendor lookup.'
16
+ spec.description = 'Real MAC addresses generator and vendor lookup with MAC address handling.'
17
17
  spec.license = 'MIT'
18
18
 
19
19
  spec.files = `git ls-files -z`.split("\x0")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: macker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Egon Zemmer
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.7.1
69
- description: Real MAC addresses generator and vendor lookup.
69
+ description: Real MAC addresses generator and vendor lookup with MAC address handling.
70
70
  email:
71
71
  - office@phlegx.com
72
72
  executables: []
@@ -106,9 +106,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 2.4.8
109
+ rubygems_version: 2.5.2
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: Real MAC addresses maker.
113
113
  test_files:
114
114
  - test/maker_test.rb
115
+ has_rdoc: