letters 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/lib/letters/config.rb +1 -1
- data/lib/letters/core_ext.rb +12 -4
- data/lib/letters/kill.rb +9 -0
- data/lib/letters/version.rb +1 -1
- data/spec/letters/core_ext_spec.rb +7 -10
- metadata +17 -16
data/README.md
CHANGED
@@ -193,10 +193,10 @@ The `o` method takes options, too, so you can add a prefix message to the output
|
|
193
193
|
Kill
|
194
194
|
</td>
|
195
195
|
<td>
|
196
|
-
:
|
196
|
+
:on
|
197
197
|
</td>
|
198
198
|
<td>
|
199
|
-
raises Letters::KillError
|
199
|
+
raises Letters::KillError at a specified number of calls
|
200
200
|
</td>
|
201
201
|
</tr>
|
202
202
|
|
@@ -311,7 +311,7 @@ See the [full documentation](http://lettersrb.com/api) for examples and more det
|
|
311
311
|
|
312
312
|
### Configuration ###
|
313
313
|
|
314
|
-
|
314
|
+
For maximum productivity, you can tune and tweak each Letters method to fit your own tastes. Want to name put files somewhere else? No problem. Don't like YAML? Default `f` to use Pretty Print instead! The world of defaults is your oyster.
|
315
315
|
|
316
316
|
```ruby
|
317
317
|
Letters.config do
|
data/lib/letters/config.rb
CHANGED
data/lib/letters/core_ext.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "letters/config"
|
2
2
|
require "letters/helpers"
|
3
3
|
require "letters/diff"
|
4
|
+
require "letters/kill"
|
4
5
|
require "letters/time_formats"
|
5
6
|
require "letters/empty_error"
|
6
7
|
require "letters/kill_error"
|
@@ -96,13 +97,20 @@ module Letters
|
|
96
97
|
# Kill
|
97
98
|
def k(opts={})
|
98
99
|
opts = Letters.defaults_with(:k, opts)
|
100
|
+
|
101
|
+
# Support :max option until I can deprecate it
|
102
|
+
opts[:on] ||= opts[:max]
|
103
|
+
|
99
104
|
opts.merge! :error_class => KillError
|
100
105
|
tap do |o|
|
101
|
-
|
102
|
-
|
103
|
-
|
106
|
+
Letters.kill_count ||= 0
|
107
|
+
|
108
|
+
if Letters.kill_count >= opts[:on]
|
109
|
+
Letters.kill_count = 0
|
110
|
+
o.a(opts) { false }
|
104
111
|
end
|
105
|
-
|
112
|
+
|
113
|
+
Letters.kill_count += 1
|
106
114
|
end
|
107
115
|
end
|
108
116
|
|
data/lib/letters/kill.rb
ADDED
data/lib/letters/version.rb
CHANGED
@@ -147,29 +147,26 @@ module Letters
|
|
147
147
|
end
|
148
148
|
|
149
149
|
describe "#k (kill)" do
|
150
|
-
it
|
150
|
+
it "raises a KillError immediately by default" do
|
151
151
|
lambda { hash.k }.should raise_error(KillError)
|
152
152
|
end
|
153
153
|
|
154
|
-
it
|
155
|
-
lambda { hash.k(
|
154
|
+
it "does not raises if number of calls are below the specified number" do
|
155
|
+
lambda { hash.k(:on => 1) }.should_not raise_error
|
156
156
|
end
|
157
157
|
|
158
|
-
it
|
158
|
+
it "raises a KillError if number of calls has reached the specified number" do
|
159
159
|
count = 0
|
160
|
+
hash.k(:on => 2)
|
160
161
|
lambda do
|
161
|
-
|
162
|
-
hash.k(max: 5)
|
163
|
-
count += 1
|
164
|
-
end
|
162
|
+
hash.k(:on => 2)
|
165
163
|
end.should raise_error(KillError)
|
166
|
-
count.should eq(5)
|
167
164
|
end
|
168
165
|
end
|
169
166
|
|
170
167
|
describe "#l (log)" do
|
171
168
|
it "logs the object if a logger is present and then returns the object" do
|
172
|
-
logger = double
|
169
|
+
logger = double "logger"
|
173
170
|
logger.should_receive(:info).with(hash.to_yaml)
|
174
171
|
hash.should_receive(:logger).and_return(logger)
|
175
172
|
hash.l
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: letters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-07 00:00:00.
|
12
|
+
date: 2012-10-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: awesome_print
|
16
|
-
requirement: &
|
16
|
+
requirement: &70186112051180 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70186112051180
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &70186112050660 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70186112050660
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: xml-simple
|
38
|
-
requirement: &
|
38
|
+
requirement: &70186112050040 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70186112050040
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: colorize
|
49
|
-
requirement: &
|
49
|
+
requirement: &70186112049280 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70186112049280
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: debugger
|
60
|
-
requirement: &
|
60
|
+
requirement: &70186112048660 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70186112048660
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: timecop
|
71
|
-
requirement: &
|
71
|
+
requirement: &70186112048240 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70186112048240
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &70186112047760 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70186112047760
|
91
91
|
description: Letters brings Ruby debugging into the 21st century. It leverages print,
|
92
92
|
the debugger, control transfer, even computer beeps to let you see into your code's
|
93
93
|
state.
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- lib/letters/diff.rb
|
103
103
|
- lib/letters/empty_error.rb
|
104
104
|
- lib/letters/helpers.rb
|
105
|
+
- lib/letters/kill.rb
|
105
106
|
- lib/letters/kill_error.rb
|
106
107
|
- lib/letters/nil_error.rb
|
107
108
|
- lib/letters/patch/core.rb
|