Created
March 17, 2014 19:58
-
-
Save mikz/9607003 to your computer and use it in GitHub Desktop.
Fetches awesome namesgenerator from docker & runs it in ruby.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
class NamesGenerator | |
def self.load | |
go = open('https://raw.github.com/dotcloud/docker/master/pkg/namesgenerator/names-generator.go') | |
left, right = go.read.scan(/\[\.\.\.\]string{(?<strings>.+)}/) | |
left = left.first.scan(/"(.+?)"/) | |
right = right.first.scan(/"(.+?)"/) | |
[left, right] | |
end | |
def initialize | |
@left, @right = self.class.load | |
end | |
def generate | |
[@left.sample, @right.sample].join('_') | |
end | |
end | |
if __FILE__ == $0 | |
puts NamesGenerator.new.generate | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment