hatchet 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/RELEASE.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Release notes
2
2
 
3
+ ## 0.2.6
4
+
5
+ * Log messages can be objects deferring to `to_s` (thanks to
6
+ [@gstark](https://github.com/gstark))
7
+
3
8
  ## 0.2.5
4
9
 
5
10
  * Rails 4.0 compatibility
@@ -76,7 +76,7 @@ module Hatchet
76
76
  # Public: Returns the String representation of the message.
77
77
  #
78
78
  def to_s
79
- @message ||= @block.call
79
+ @evaluated_message ||= (@message || @block.call).to_s
80
80
  end
81
81
 
82
82
  end
@@ -4,6 +4,6 @@ module Hatchet
4
4
 
5
5
  # Public: The version of Hatchet.
6
6
  #
7
- VERSION = '0.2.5'
7
+ VERSION = '0.2.6'
8
8
 
9
9
  end
@@ -3,6 +3,14 @@
3
3
  require_relative 'spec_helper'
4
4
 
5
5
  describe Message do
6
+ describe 'providing an evaluted message that is not a string' do
7
+ let(:subject) { Message.new(ndc: [], message: Rational(1.5)) }
8
+
9
+ it 'returns the given message' do
10
+ assert_equal '3/2', subject.to_s
11
+ end
12
+ end
13
+
6
14
  describe 'providing an evaluted message' do
7
15
  let(:subject) { Message.new(ndc: [], message: 'Evaluated') }
8
16
 
@@ -11,6 +19,18 @@ describe Message do
11
19
  end
12
20
  end
13
21
 
22
+ describe 'providing a block message that does not return a string' do
23
+ let(:subject) do
24
+ Message.new(ndc: []) do
25
+ Rational(1.5)
26
+ end
27
+ end
28
+
29
+ it 'returns the result of evaluating the block and calling #to_s on the result' do
30
+ assert_equal '3/2', subject.to_s
31
+ end
32
+ end
33
+
14
34
  describe 'providing a block message' do
15
35
  let(:subject) do
16
36
  @evaluated = 0
@@ -84,5 +104,36 @@ describe Message do
84
104
  end
85
105
  end
86
106
  end
107
+
108
+ if ENV["BENCH"] then
109
+ describe 'benchmarks' do
110
+ let(:subject) { Message.new(ndc: [], message: 'Evaluated') }
111
+
112
+ it 'invoking to_s once' do
113
+ start = Time.now
114
+
115
+ 50_000.times do
116
+ subject.to_s
117
+ end
118
+
119
+ took = Time.now - start
120
+ puts "\nMessages took #{took} to generate\n"
121
+ end
122
+
123
+ it 'invoking to_s four times' do
124
+ start = Time.now
125
+
126
+ 50_000.times do
127
+ subject.to_s
128
+ subject.to_s
129
+ subject.to_s
130
+ subject.to_s
131
+ end
132
+
133
+ took = Time.now - start
134
+ puts "\nMessages took #{took} to generate\n"
135
+ end
136
+ end
137
+ end
87
138
  end
88
139
 
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hatchet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Garry Shutler
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-09-03 00:00:00.000000000 Z
12
+ date: 2013-09-08 00:00:00.000000000 Z
12
13
  dependencies: []
13
14
  description: Logging library that provides the ability to add class/module specific
14
15
  filters
@@ -55,26 +56,33 @@ files:
55
56
  - RELEASE.md
56
57
  homepage: http://gshutler.github.com/hatchet/
57
58
  licenses: []
58
- metadata: {}
59
59
  post_install_message:
60
60
  rdoc_options: []
61
61
  require_paths:
62
62
  - lib
63
63
  required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
64
65
  requirements:
65
- - - '>='
66
+ - - ! '>='
66
67
  - !ruby/object:Gem::Version
67
68
  version: '0'
69
+ segments:
70
+ - 0
71
+ hash: -2691813738806144431
68
72
  required_rubygems_version: !ruby/object:Gem::Requirement
73
+ none: false
69
74
  requirements:
70
- - - '>='
75
+ - - ! '>='
71
76
  - !ruby/object:Gem::Version
72
77
  version: '0'
78
+ segments:
79
+ - 0
80
+ hash: -2691813738806144431
73
81
  requirements: []
74
82
  rubyforge_project:
75
- rubygems_version: 2.0.7
83
+ rubygems_version: 1.8.25
76
84
  signing_key:
77
- specification_version: 4
85
+ specification_version: 3
78
86
  summary: Logging library that provides the ability to add class/module specific filters
79
87
  test_files:
80
88
  - spec/configuration_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 1a8f3bba951d0af7880faf8d61eaee4b82e45dd7
4
- data.tar.gz: 8d295b2641278f9356f3421f99ea0d853006f45a
5
- SHA512:
6
- metadata.gz: 7ccde4fad36c80d294a94d66beaee715823ff1c8ea716e4863d45490dd78b533d244beb9c0de8a023a050a58455ed0f5651a6228752448c4a93d4329c45776a1
7
- data.tar.gz: 9510517dcb067265926129e7e6cb5a3df9e3be0f811125f8def4320acc4c0c5cb89bc3442a51b9aa79e3fbc8af3387e9b0c108432ca3f4e99592bb93c396668b