AutoNic 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +2 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +52 -0
- data/Guardfile +5 -0
- data/autonic.gemspec +21 -0
- data/init.rb +1 -0
- data/lib/autonic.rb +68 -0
- data/spec/autonic.spec.rb +32 -0
- data/spec/spec_helper.rb +1 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZWRkNTgxZmYwMWIzOWJmMmViMzNkY2QwZjJkYzNhM2M5YzkxNDg5Mg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YzlkYTRhOTAxMzU3MDYwMzBhMTYxYzI4M2RiMzUwNzMxODUxNTg5Yg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NjU0ZmY0Mjk5NTc2MzRiNGVjYjg4ZDBhYjI0MjBjODY3YjhhZjYwZTZjZTBj
|
10
|
+
MGYxNjdjNGQyODI1ODk1OTdkZTNlZDllODU2M2Q2ZjYxMjk0MTg5ZGQzMjJi
|
11
|
+
MTZlMDA3OTdjODY3MGIyMjVjNTQ3M2IyN2VkMzRlNGFlN2M2OTY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MzQ4YzY3MTUzYzFhNzk5ZTA3NmNiOGViNDA5ZTJkN2JiMjgzYjJkZjU0ZTkw
|
14
|
+
ZWNjMDZkZTA5OTNhY2UyM2JlNWM3OWIwYTMwZDI0NTk3OWZiMmM5YWI5NzUw
|
15
|
+
YTNkODQ4MWU4NmUwMmMzMThhZjgwZGQ3MTcwYzJkNTA3ZTE5YWM=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
coderay (1.0.9)
|
5
|
+
diff-lcs (1.2.4)
|
6
|
+
ffi (1.8.1)
|
7
|
+
formatador (0.2.4)
|
8
|
+
guard (1.8.0)
|
9
|
+
formatador (>= 0.2.4)
|
10
|
+
listen (>= 1.0.0)
|
11
|
+
lumberjack (>= 1.0.2)
|
12
|
+
pry (>= 0.9.10)
|
13
|
+
thor (>= 0.14.6)
|
14
|
+
guard-rspec (3.0.0)
|
15
|
+
guard (>= 1.8)
|
16
|
+
rspec (~> 2.13)
|
17
|
+
listen (1.0.3)
|
18
|
+
rb-fsevent (>= 0.9.3)
|
19
|
+
rb-inotify (>= 0.9)
|
20
|
+
rb-kqueue (>= 0.2)
|
21
|
+
lumberjack (1.0.3)
|
22
|
+
macaddr (1.6.1)
|
23
|
+
systemu (~> 2.5.0)
|
24
|
+
method_source (0.8.1)
|
25
|
+
pry (0.9.12.2)
|
26
|
+
coderay (~> 1.0.5)
|
27
|
+
method_source (~> 0.8)
|
28
|
+
slop (~> 3.4)
|
29
|
+
rb-fsevent (0.9.3)
|
30
|
+
rb-inotify (0.9.0)
|
31
|
+
ffi (>= 0.5.0)
|
32
|
+
rb-kqueue (0.2.0)
|
33
|
+
ffi (>= 0.5.0)
|
34
|
+
rspec (2.13.0)
|
35
|
+
rspec-core (~> 2.13.0)
|
36
|
+
rspec-expectations (~> 2.13.0)
|
37
|
+
rspec-mocks (~> 2.13.0)
|
38
|
+
rspec-core (2.13.1)
|
39
|
+
rspec-expectations (2.13.0)
|
40
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
41
|
+
rspec-mocks (2.13.1)
|
42
|
+
slop (3.4.5)
|
43
|
+
systemu (2.5.2)
|
44
|
+
thor (0.18.1)
|
45
|
+
|
46
|
+
PLATFORMS
|
47
|
+
ruby
|
48
|
+
|
49
|
+
DEPENDENCIES
|
50
|
+
guard-rspec
|
51
|
+
macaddr
|
52
|
+
rspec
|
data/Guardfile
ADDED
data/autonic.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "AutoNic"
|
7
|
+
gem.version = '1.0.0'
|
8
|
+
gem.authors = ["whoojemaflip"]
|
9
|
+
gem.email = ["whoojemaflip@gmail.com"]
|
10
|
+
gem.description = %q{Create a silly name for your server automatically from it's Mac address}
|
11
|
+
gem.summary = %q{Create a silly name for your server automatically from it's Mac address}
|
12
|
+
gem.homepage = "http://github.com/whoojemaflip/autonic"
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split($/)
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
|
19
|
+
gem.add_runtime_dependency "macaddr", "~> 1.6.1"
|
20
|
+
gem.add_development_dependency "rspec"
|
21
|
+
end
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative 'lib/autonic'
|
data/lib/autonic.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# init.rb
|
2
|
+
|
3
|
+
require 'macaddr'
|
4
|
+
|
5
|
+
class AutoNic
|
6
|
+
attr_accessor :macaddr
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@consonants = "bcdfghjklmnpqrstvwxyz"
|
10
|
+
@vowels = "aeiou"
|
11
|
+
|
12
|
+
@combos = []
|
13
|
+
@consonants.each_char do |con|
|
14
|
+
@vowels.each_char do |vow|
|
15
|
+
@combos << con+vow
|
16
|
+
end
|
17
|
+
end
|
18
|
+
@macaddr = Mac.addr
|
19
|
+
end
|
20
|
+
|
21
|
+
def name
|
22
|
+
macAddrToName
|
23
|
+
end
|
24
|
+
|
25
|
+
def popHexPair(s)
|
26
|
+
if s.length < 3
|
27
|
+
num = s.to_i(16)
|
28
|
+
rest = ""
|
29
|
+
else
|
30
|
+
num = s[0..1].to_i(16)
|
31
|
+
rest = s[2..s.length]
|
32
|
+
end
|
33
|
+
return :num => num, :rest => rest
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def cleanName(n)
|
38
|
+
return n.gsub("- ", '-').gsub(" -", ' ').gsub("--", '-').strip().gsub(/-$/, '')
|
39
|
+
end
|
40
|
+
|
41
|
+
def macAddrToName
|
42
|
+
name = " "
|
43
|
+
x = @macaddr.gsub(/[-: ]/, '')
|
44
|
+
while x.length > 0 do
|
45
|
+
tup = popHexPair(x)
|
46
|
+
n = tup[:num]
|
47
|
+
syllable = ''
|
48
|
+
if(n < @combos.length)
|
49
|
+
syllable = @combos[n]
|
50
|
+
else
|
51
|
+
if (n/2 < @combos.length)
|
52
|
+
if (n%3 == 0)
|
53
|
+
syllable = @combos[n/2] + ' '
|
54
|
+
elsif (n%2 == 0)
|
55
|
+
syllable = @combos[n/2]
|
56
|
+
end
|
57
|
+
else
|
58
|
+
syllable = ' '
|
59
|
+
end
|
60
|
+
end
|
61
|
+
name = name + syllable
|
62
|
+
x = tup[:rest]
|
63
|
+
end
|
64
|
+
sname = name.upcase.split /\s+/
|
65
|
+
capname = sname.join(' ')
|
66
|
+
return cleanName(capname)
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'spec_helper.rb'
|
3
|
+
|
4
|
+
describe 'AutoNic' do
|
5
|
+
before :each do
|
6
|
+
@macr = AutoNic.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'gives your server a cute name' do
|
10
|
+
@macr.macaddr = "00:B0:D0:86:BB:F7"
|
11
|
+
@macr.name.should eq "BAWOZURI"
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'makes no promises that it will be prouncable' do
|
15
|
+
@macr.macaddr = "00:1b:63:84:45:e6"
|
16
|
+
@macr.name.should eq "BAHIYURE RU"
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'probably sounds like baby noises' do
|
20
|
+
@macr.macaddr = "00:A0:C9:14:C8:29"
|
21
|
+
@macr.name.should eq "BAVAZA GAZALE"
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'does not create unique names' do
|
25
|
+
@macr.macaddr = "14:10:9f:d8:6e:f7"
|
26
|
+
@macr.name.should eq "GAFETU PA"
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative '../init.rb'
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: AutoNic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- whoojemaflip
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-05-22 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.1
|
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.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Create a silly name for your server automatically from it's Mac address
|
42
|
+
email:
|
43
|
+
- whoojemaflip@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- Gemfile.lock
|
51
|
+
- Guardfile
|
52
|
+
- autonic.gemspec
|
53
|
+
- init.rb
|
54
|
+
- lib/autonic.rb
|
55
|
+
- spec/autonic.spec.rb
|
56
|
+
- spec/spec_helper.rb
|
57
|
+
homepage: http://github.com/whoojemaflip/autonic
|
58
|
+
licenses: []
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.0.3
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: Create a silly name for your server automatically from it's Mac address
|
80
|
+
test_files:
|
81
|
+
- spec/autonic.spec.rb
|
82
|
+
- spec/spec_helper.rb
|