Skip to content

Latest commit

 

History

History
69 lines (47 loc) · 1.13 KB

README.textile

File metadata and controls

69 lines (47 loc) · 1.13 KB

Squeal

A simple object instantiation counter.

Inspired by oink (http://github.com/noahd1/oink).
I needed a non-rails one for my search engine project Picky (http://github.com/floere/picky), but oink did not fit well.

Note: It reports cumulatively until Squeal.reset is called.

Only works on certain Ruby classes yet (not String, for example).

Examples

Installation

gem install squeal

On a single class.

require 'squeal'

TestClass.squeal do
  TestClass.new
  TestClass.new
  Object.new
  String.new
end
TestClass.new

Squeal.report # => 'TestClass: 2'

On multiple classes

require 'squeal'

# Aliased as Squeal.record
#
Squeal.squeal(Object, TestClass) do
  TestClass.new
  String.new
  Object.new
  TestClass.new
  String.new
end
Object.new
TestClass.new

Squeal.report # => 'Object: 1, TestClass: 2'

Without a block

require 'squeal'

# Aliased as Squeal.squeal
#
Squeal.record Object, TestClass

TestClass.new
String.new
Object.new
TestClass.new
String.new

Squeal.stop

Object.new
TestClass.new

Squeal.report # => 'Object: 1, TestClass: 2'