Skip to content

Commit

Permalink
Renamed log-weasel to log_weasel. First running spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
asalant committed Feb 12, 2011
1 parent 01e7950 commit 5829766
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .rvmrc
@@ -1 +1 @@
rvm --create ruby-1.9.2-p0@log-weasel
rvm --create ruby-1.9.2-p0@log_weasel
2 changes: 1 addition & 1 deletion Gemfile
@@ -1,4 +1,4 @@
source "http://rubygems.org"

# Specify your gem's dependencies in log-weasel.gemspec
# Specify your gem's dependencies in log_weasel.gemspec
gemspec
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -4,10 +4,10 @@ Instrument Rails and Resque with shared transaction IDs so that you trace execut

## Installation

Add log-weasel to your Gemfile:
Add log_weasel to your Gemfile:

<pre>
gem 'log-weasel'
gem 'log_weasel'
</pre>

Use bundler to install it:
Expand Down
9 changes: 9 additions & 0 deletions Rakefile
@@ -1,2 +1,11 @@
require 'bundler'
Bundler.setup

require 'rspec'
require 'rspec/core/rake_task'

Bundler::GemHelper.install_tasks

Rspec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = 'spec/**/*_spec.rb'
end
5 changes: 0 additions & 5 deletions lib/log-weasel.rb

This file was deleted.

1 change: 1 addition & 0 deletions lib/log_weasel.rb
@@ -0,0 +1 @@
require 'log_weasel/transaction'
21 changes: 21 additions & 0 deletions lib/log_weasel/transaction.rb
@@ -0,0 +1,21 @@
module LogWeasel
module Transaction

def self.create(key = nil)
Thread.current[:manilla_transaction_id] = "#{key ? "#{key}_" : ""}#{SecureRandom.hex(10)}"
end

def self.destroy
Thread.current[:manilla_transaction_id] = nil
end

def self.id=(id)
Thread.current[:manilla_transaction_id] = id
end

def self.id
Thread.current[:manilla_transaction_id]
end
end

end
File renamed without changes.
15 changes: 10 additions & 5 deletions log-weasel.gemspec → log_weasel.gemspec
@@ -1,18 +1,23 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "log-weasel/version"
require "log_weasel/version"

Gem::Specification.new do |s|
s.name = "log-weasel"
s.name = "log_weasel"
s.version = Log::Weasel::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Alon Salant"]
s.email = ["alon@salant.org"]
s.homepage = ""
s.summary = %q{Instrument Rails and Resque with shared transaction IDs so that you trace execution across instances.}
s.homepage = "http://github.com/carbonfive/log_weasel"
s.summary = "log_weasel-#{Log::Weasel::VERSION}"
s.description = %q{Instrument Rails and Resque with shared transaction IDs so that you trace execution across instances.}

s.rubyforge_project = "log-weasel"
s.rubyforge_project = "log_weasel"

s.add_development_dependency('rspec')
s.add_development_dependency('mocha')
s.add_development_dependency('resque', ['~> 1.0'])
s.add_development_dependency('activesupport', ['~> 3.0'])

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
Expand Down
54 changes: 54 additions & 0 deletions spec/log_weasel/transaction_spec.rb
@@ -0,0 +1,54 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'active_support'
require 'active_support/secure_random'

describe LogWeasel::Transaction do

describe ".id" do

it "is nil if not created" do
LogWeasel::Transaction.id.should be_nil
end

end

describe ".id=" do
before do
LogWeasel::Transaction.id = "1234"
end

it "sets the id" do
LogWeasel::Transaction.id.should == "1234"
end

end

describe ".create" do
before do
SecureRandom.stubs(:hex).returns('94b2')
end

it 'creates a transaction id with no key' do
id = LogWeasel::Transaction.create
id.should == '94b2'
end

it 'creates a transaction id with a key' do
id = LogWeasel::Transaction.create 'KEY'
id.should == 'KEY_94b2'
LogWeasel::Transaction.id.should == id
end

end

describe ".destroy" do
before do
LogWeasel::Transaction.create
end

it "removes transaction id" do
LogWeasel::Transaction.destroy
LogWeasel::Transaction.id.should be_nil
end
end
end
9 changes: 9 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,9 @@
$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'log_weasel'
require 'rspec'

Rspec.configure do |config|
config.mock_with :mocha
end

0 comments on commit 5829766

Please sign in to comment.