Project

chronicles

0.01
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Remembering object methods' call
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Chronicles

Gem Version Build Status Dependency Status Code Climate Coverage Inline docs

Remembers invocations of object methods

Installation

Add this line to your application's Gemfile:

# Gemfile
gem "chronicles"

Then execute:

bundle

Or add it manually:

gem install chronicles

Usage

class Test
  include Chronicles

  def initialize
    start_chronicles
    # ...
  end

  public    attr_reader :foo
  protected attr_reader :bar
  private   attr_reader :baz
end

test = Test.new
test.chronicles # => []

test.foo
test.chronicles # => [:foo]

test.send :bar
test.chronicles # => [:foo, :bar]

test.send :baz
test.chronicles # => [:foo, :bar, :baz]

test.foo
test.chronicles # => [:foo, :bar, :baz, :foo]

test.chronicles.clear
test.chronicles # => []

You can restrict chronicles by public, private or protected methods only:

class Test
  # ...
  def initialize
    start_chronicles private: false
  end
end

test.foo       # public
test.send :bar # protected
test.send :baz # private
test.chronicles # => [:foo, :bar]

You can explicitly set methods to look for:

class Test
  # ...
  def initialize
    start_chronicles only: [:bar]
  end
end

test.foo       # public
test.send :bar # protected
test.send :baz # private
test.chronicles # => [:bar]

Or exclude them from being registered:

class Test
  # ...
  def initialize
    start_chronicles except: [:bar]
  end
end

test.foo       # public
test.send :bar # protected
test.send :baz # private
test.chronicles # => [:foo, :baz]

Or combine those conditions:

class Test
  # ...
  def initialize
    start_chronicles protected: false, except: [:foo]
  end
end

test.foo       # public
test.send :bar # protected
test.send :baz # private
test.chronicles # => [:baz]

Actually, you can start chronicles after initialization and do it several times to add new methods to be looked for.

The problem is all methods included to the chronicle will be kept registered. To stop registering selected methods use the stop_chronicles:

test.chronicles  # => []

test.start_chronicles only: [:foo, :bar]
test.foo
test.bar
test.baz
test.chronicles  # => [:foo, :bar]

test.start_chronicles only: :baz
test.foo
test.bar
test.baz
test.chronicles # => [:foo, :bar, :foo, :bar, :baz]

test.stop_chronicles except: :baz
test.foo
test.bar
test.baz
test.chronicles # => [:foo, :bar, :foo, :bar, :baz, :baz]

Compatibility

Tested under rubies compatible to API 2.0+:

  • MRI 2.0+
  • Rubinius (mode 2.0+)
  • JRuby 9.0.0.0 (mode 2.0+)

Uses RSpec 3.0+ for testing and hexx-suit for dev/test tools collection.

Contributing

  • Fork the project.
  • Read the STYLEGUIDE.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with Rakefile or version (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

License

See the MIT LICENSE.

Bitdeli Badge