Permalink
Browse files

replace UUIDTools with UUID for default UUID generation

skirting issues involving require order on projects that use UUIDTools and UUID,
but just using UUID.
  • Loading branch information...
1 parent 67ac772 commit 249ee4b47f72c8bfd96ab5d85007e86528427c3f Noah Davis committed Jun 16, 2011
View
2 Gemfile
@@ -3,6 +3,6 @@ source :rubyforge
gem "jeweler", "~> 1.4.0"
gem "rspec", "~> 1.3.0"
gem "rake", "~> 0.8.7"
-gem "uuidtools"
+gem "uuid"
gem "activesupport", "~> 2.3.8"
gem "json_pure", "= 1.4.3"
View
6 Gemfile.lock
@@ -9,11 +9,13 @@ GEM
git (>= 1.2.5)
rubyforge (>= 2.0.0)
json_pure (1.4.3)
+ macaddr (1.0.0)
rake (0.8.7)
rspec (1.3.0)
rubyforge (2.0.4)
json_pure (>= 1.1.7)
- uuidtools (2.1.1)
+ uuid (2.3.2)
+ macaddr (~> 1.0)
PLATFORMS
ruby
@@ -24,4 +26,4 @@ DEPENDENCIES
json_pure (= 1.4.3)
rake (~> 0.8.7)
rspec (~> 1.3.0)
- uuidtools
+ uuid
View
2 Rakefile
@@ -11,7 +11,7 @@ Jeweler::Tasks.new do |gem|
gem.homepage = "http://github.com/efficiency20/ops_middleware"
gem.description = "Adds middleware for debugging purposes"
gem.authors = ["Efficiency 2.0"]
- gem.add_dependency "uuidtools", "~> 2.1"
+ gem.add_dependency "uuid", "~> 2.3.2"
gem.add_development_dependency "rspec", "~> 1.3.0"
end
View
11 e20_ops_middleware.gemspec
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Efficiency 2.0"]
- s.date = %q{2011-03-16}
+ s.date = %q{2011-06-15}
s.description = %q{Adds middleware for debugging purposes}
s.email = %q{tech@efficiency20.com}
s.extra_rdoc_files = [
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
"Rakefile",
"VERSION",
"ci.rb",
+ "e20_ops_middleware.gemspec",
"lib/e20/ops/hostname.rb",
"lib/e20/ops/middleware.rb",
"lib/e20/ops/middleware/hostname_middleware.rb",
@@ -41,7 +42,7 @@ Gem::Specification.new do |s|
s.homepage = %q{http://github.com/efficiency20/ops_middleware}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
- s.rubygems_version = %q{1.5.2}
+ s.rubygems_version = %q{1.4.2}
s.summary = %q{Collection of useful middleware for exposing information about deployed Rack applications}
s.test_files = [
"spec/ops/hostname_spec.rb",
@@ -56,14 +57,14 @@ Gem::Specification.new do |s|
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<uuidtools>, ["~> 2.1"])
+ s.add_runtime_dependency(%q<uuid>, ["~> 2.3.2"])
s.add_development_dependency(%q<rspec>, ["~> 1.3.0"])
else
- s.add_dependency(%q<uuidtools>, ["~> 2.1"])
+ s.add_dependency(%q<uuid>, ["~> 2.3.2"])
s.add_dependency(%q<rspec>, ["~> 1.3.0"])
end
else
- s.add_dependency(%q<uuidtools>, ["~> 2.1"])
+ s.add_dependency(%q<uuid>, ["~> 2.3.2"])
s.add_dependency(%q<rspec>, ["~> 1.3.0"])
end
end
View
4 lib/e20/ops/middleware/transaction_id_middleware.rb
@@ -1,4 +1,4 @@
-require "uuidtools"
+require "uuid"
require "logger"
module E20
@@ -8,7 +8,7 @@ class TransactionIdMiddleware
def initialize(app, options = {})
@app = app
- @uuid_generator = options[:uuid_generator] || UUIDTools::UUID.method(:random_create)
+ @uuid_generator = options[:uuid_generator] || lambda { UUID.generate(:compact) }
@logger = options[:logger] || Logger.new(STDOUT)
end
View
6 spec/ops/middleware/transaction_id_middleware_spec.rb
@@ -15,6 +15,12 @@
body.should == "OK!"
end
+ it "defaults to a 32 character transaction id" do
+ middleware = E20::Ops::Middleware::TransactionIdMiddleware.new(app, :logger => logger)
+ status, headers, body = middleware.call({})
+ headers["X-Transaction"].size.should == 32
+ end
+
it "sets an X-Transaction header" do
middleware = E20::Ops::Middleware::TransactionIdMiddleware.new(app, :uuid_generator => uuid, :logger => logger)
status, headers, body = middleware.call({})

0 comments on commit 249ee4b

Please sign in to comment.