cornflake 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/cornflake.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'cornflake'
3
- s.version = '0.0.1'
3
+ s.version = '0.0.2'
4
4
  s.authors = ["Vicent Martí"]
5
5
  s.date = Time.now.utc.strftime("%Y-%m-%d")
6
6
  s.email = %q{vmg@github.com}
@@ -12,6 +12,4 @@ Gem::Specification.new do |s|
12
12
  s.summary = %q{K-ordered id generation, brought to you by Unix (TM)}
13
13
  s.description = "This does the thing with the ID generation and all that"
14
14
  s.license = "MIT"
15
-
16
- s.add_dependency "macaddr", "~> 1.6"
17
15
  end
@@ -0,0 +1,27 @@
1
+ require 'securerandom'
2
+
3
+ class Cornflake
4
+ module MacAddress
5
+ RE = %r/(?:[^:\-]|\A)(?:[0-9A-F][0-9A-F][:\-]){5}[0-9A-F][0-9A-F](?:[^:\-]|\Z)/io
6
+
7
+ def self.find
8
+ cmds = '/sbin/ifconfig', '/bin/ifconfig', 'ifconfig', 'cat /sys/class/net/*/address'
9
+
10
+ cmds.each do |cmd|
11
+ mac = parse_mac_output(`#{cmd}`)
12
+ return mac if mac
13
+ end
14
+
15
+ # Not found; randomize a mac address
16
+ SecureRandom.hex(6).scan(/.{2}/).join(':')
17
+ end
18
+
19
+ private
20
+ def self.parse_mac_output(output)
21
+ output.split(/\n/).each do |line|
22
+ mac = line[RE]
23
+ return mac.strip if mac
24
+ end
25
+ end
26
+ end
27
+ end
data/lib/cornflake.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  require 'cornflake.so'
2
- require 'macaddr'
3
-
4
- Cornflake.macaddr = Mac.addr
2
+ require 'cornflake/mac'
5
3
 
6
4
  class Cornflake
7
5
  module Base62
@@ -24,3 +22,4 @@ class Cornflake
24
22
  end
25
23
  end
26
24
 
25
+ Cornflake.macaddr = Cornflake::MacAddress.find
metadata CHANGED
@@ -1,29 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cornflake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Vicent Martí
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-09-02 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: macaddr
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '1.6'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ~>
25
- - !ruby/object:Gem::Version
26
- version: '1.6'
12
+ date: 2014-01-15 00:00:00.000000000 Z
13
+ dependencies: []
27
14
  description: This does the thing with the ID generation and all that
28
15
  email: vmg@github.com
29
16
  executables: []
@@ -42,6 +29,7 @@ files:
42
29
  - ext/cornflake/cornflake.rb.c
43
30
  - ext/cornflake/extconf.rb
44
31
  - lib/cornflake.rb
32
+ - lib/cornflake/mac.rb
45
33
  - nginx/README.md
46
34
  - nginx/cornflake.c
47
35
  - nginx/cornflake.h
@@ -49,25 +37,26 @@ files:
49
37
  homepage: http://github.com/github/cornflake
50
38
  licenses:
51
39
  - MIT
52
- metadata: {}
53
40
  post_install_message:
54
41
  rdoc_options: []
55
42
  require_paths:
56
43
  - lib
57
44
  required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
58
46
  requirements:
59
47
  - - ! '>='
60
48
  - !ruby/object:Gem::Version
61
49
  version: '0'
62
50
  required_rubygems_version: !ruby/object:Gem::Requirement
51
+ none: false
63
52
  requirements:
64
53
  - - ! '>='
65
54
  - !ruby/object:Gem::Version
66
55
  version: '0'
67
56
  requirements: []
68
57
  rubyforge_project:
69
- rubygems_version: 2.0.7
58
+ rubygems_version: 1.8.23
70
59
  signing_key:
71
- specification_version: 4
60
+ specification_version: 3
72
61
  summary: K-ordered id generation, brought to you by Unix (TM)
73
62
  test_files: []
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YjAyM2YwYzNkY2RiMDlmOTZkNjVkZTZiYmE1MWRlYjBjNzM2ODAyYg==
5
- data.tar.gz: !binary |-
6
- MjhkNjRhZTYxYjNhY2IxZjZlNTdmZmZlYTUyY2FlZmE0NGZiMzc5Ng==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- ZDRlNjJhMWQ2ODY1YTgyNTQ4ZGUxNTBmOTVjMjlmZjZjYjkxN2ZjZjI4NThk
10
- ZWIxYzY1MGY1YWU0YzczMjM1NTFhMjQzYjhlYThhMWQ4ZGMyZjYzNjAxY2Zj
11
- NTA5ZGRjZTdlY2M4ZTVmZmRlMThmMDAyOTlkZjUwMzk1Mjk3YTk=
12
- data.tar.gz: !binary |-
13
- MmIzNDEzNjkxNWFmMTZmMDQxMjU1MzU1YjUwZDI3Mzk3NGY1YmFmMTNkNjJl
14
- YjNkNjM5OTMwMDkwM2Q5ZWUxMDkzNjQxMjIxMDRhZDE3N2FmM2E5NzE5Mzkw
15
- YWEwNzIxN2ZjMWEyMzk2MDYxMzFmNTk0YzVjZjA4MzhkNTA2ODg=