annals 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/annals.gemspec +1 -1
  3. data/lib/annals.rb +14 -9
  4. metadata +1 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{annals}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["geemus (Wesley Beary)"]
@@ -4,6 +4,15 @@ class Annals
4
4
 
5
5
  def initialize(max = 20, &block)
6
6
  @max = max
7
+ if block_given?
8
+ @trace_func = block
9
+ else
10
+ @trace_func = lambda { |event, file, line, id, binding, classname|
11
+ if event == 'call'
12
+ unshift(:file => file, :line => line, :method => "in #{id}")
13
+ end
14
+ }
15
+ end
7
16
  start
8
17
  end
9
18
 
@@ -17,7 +26,7 @@ class Annals
17
26
  @buffer.map {|event| "#{event[:file]}:#{event[:line]} #{event[:method]}"}
18
27
  end
19
28
 
20
- def puts
29
+ def print_lines
21
30
  for line in lines
22
31
  puts(line)
23
32
  end
@@ -26,27 +35,23 @@ class Annals
26
35
  def start
27
36
  @buffer = []
28
37
  @size = 0
29
- Kernel.set_trace_func(
30
- lambda { |event, file, line, id, binding, classname|
31
- if event == 'call'
32
- unshift(:file => file, :line => line, :method => "in #{id}")
33
- end
34
- }
35
- )
38
+ Kernel.set_trace_func(@trace_func)
39
+ true
36
40
  end
37
41
 
38
42
  def stop
39
43
  Kernel.set_trace_func(lambda {})
40
44
  @buffer.shift # remove Annals#stop from buffer
45
+ true
41
46
  end
42
47
 
43
48
  def unshift(line)
44
- @buffer.unshift(line)
45
49
  if @size == @max
46
50
  @buffer.pop
47
51
  else
48
52
  @size += 1
49
53
  end
54
+ @buffer.unshift(line)
50
55
  end
51
56
 
52
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: annals
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - geemus (Wesley Beary)