Skip to content

Commit

Permalink
replace UUIDTools with UUID for default UUID generation
Browse files Browse the repository at this point in the history
skirting issues involving require order on projects that use UUIDTools and UUID,
but just using UUID.
  • Loading branch information
Noah Davis committed Jun 16, 2011
1 parent 67ac772 commit 249ee4b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -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"
6 changes: 4 additions & 2 deletions Gemfile.lock
Expand Up @@ -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
Expand All @@ -24,4 +26,4 @@ DEPENDENCIES
json_pure (= 1.4.3)
rake (~> 0.8.7)
rspec (~> 1.3.0)
uuidtools
uuid
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -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

Expand Down
11 changes: 6 additions & 5 deletions e20_ops_middleware.gemspec
Expand Up @@ -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 = [
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/e20/ops/middleware/transaction_id_middleware.rb
@@ -1,4 +1,4 @@
require "uuidtools"
require "uuid"
require "logger"

module E20
Expand All @@ -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

Expand Down
6 changes: 6 additions & 0 deletions spec/ops/middleware/transaction_id_middleware_spec.rb
Expand Up @@ -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({})
Expand Down

0 comments on commit 249ee4b

Please sign in to comment.