Add a UUID generator
3 files changed, 25 insertions(+), 10 deletions(-)

M gem.deps.rb
M lib/assemblage.rb
M spec/assemblage_spec.rb
M gem.deps.rb +10 -9
@@ 1,19 1,20 @@ 
 source 'https://rubygems.org'
 
-gem 'loggability', "~> 0.11"
 gem 'configurability', "~> 3.2"
-gem 'hglib', "~> 0.1"
+gem 'cztop-reactor', "~> 0.7"
 gem 'git', "~> 1.3"
 gem 'gli', "~> 2.18"
+gem 'hglib', "~> 0.1"
+gem 'loggability', "~> 0.11"
+gem 'msgpack', "~> 1.2"
+gem 'pg', "~> 1.1"
+gem 'pluggability', "~> 0.6"
+gem 'rb-readline', "~> 0.5"
+gem 'sequel', "~> 5.6"
+gem 'state_machines', "~> 0.5"
 gem 'tty-prompt', "~> 0.18"
 gem 'tty-table', "~> 0.10"
-gem 'sequel', "~> 5.6"
-gem 'pg', "~> 1.1"
-gem 'msgpack', "~> 1.2"
-gem 'rb-readline', "~> 0.5"
-gem 'state_machines', "~> 0.5"
-gem 'cztop-reactor', "~> 0.7"
-gem 'pluggability', "~> 0.6"
+gem 'uuid', "~> 2.3"
 
 group :development do
 	gem 'rake-deveiate', "~> 0.5"

          
M lib/assemblage.rb +7 -0
@@ 7,6 7,7 @@ require 'socket'
 require 'set'
 require 'loggability'
 require 'configurability'
+require 'uuid'
 
 
 # Toplevel namespace

          
@@ 159,5 160,11 @@ module Assemblage
 		return raw.gsub( /[^\w\-]+/, '-' ).squeeze( '-' )
 	end
 
+
+	### Return a UUID generator, creating it if necessary.
+	def self::uuidgen
+		return @uuidgen ||= UUID.new
+	end
+
 end # module Assemblage
 

          
M spec/assemblage_spec.rb +8 -1
@@ 17,10 17,17 @@ describe Assemblage do
 	it "can generate a unique string ID for an object" do
 		expect( Socket ).to receive( :gethostname ).and_return( "Netrehesh.local" )
 		expect( described_class.make_unique_id( 'doot' ) ).
-			to match( /^doot-netrehesh-[[:xdigit:]]{16}$/ )
+			to match( /^doot-netrehesh-\h{16}$/ )
 	end
 
 
+	it "has a UUID generator" do
+		result = described_class.uuidgen
+		expect( result ).to respond_to( :generate )
+		# C29916D9-47EA-4A09-9568-0091A2D5A882
+		expect( result.generate ).to match( /\A\h{8}(-\h{4}){3}-\h{12}\z/ )
+	end
+
 	describe "configurability" do
 
 		before( :all ) do