letters 0.4.0 → 0.4.1
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.
- data/README.md +9 -0
- data/lib/letters/core_ext.rb +7 -4
- data/lib/letters/version.rb +1 -1
- data/spec/letters/config_spec.rb +10 -0
- metadata +1 -1
data/README.md
CHANGED
@@ -60,6 +60,7 @@ Here are the methods, listed with any options that can be passed in to modify th
|
|
60
60
|
|
61
61
|
- `:message (string)`: Print out the specified message as the method is being called.
|
62
62
|
- `:line_no (boolean)`: Print out the line number where a method is called as it is being called
|
63
|
+
- `:disable (boolean)`: Disable this method's side effects
|
63
64
|
|
64
65
|
You can easily set these for an entire project using global configuration if you wish (see below).
|
65
66
|
|
@@ -203,3 +204,11 @@ Letters.config do
|
|
203
204
|
all :line_no => true
|
204
205
|
end
|
205
206
|
```
|
207
|
+
|
208
|
+
To disable all Letters, for example if you're worried about them getting into a production environment:
|
209
|
+
|
210
|
+
```ruby
|
211
|
+
Letters.config do
|
212
|
+
all :disable => true
|
213
|
+
end
|
214
|
+
```
|
data/lib/letters/core_ext.rb
CHANGED
@@ -15,11 +15,14 @@ module Letters
|
|
15
15
|
|
16
16
|
def ubertap(letter, opts={}, orig_caller=[], &block)
|
17
17
|
full_opts = Letters.defaults_with(letter, opts)
|
18
|
-
Helpers.message full_opts
|
19
|
-
Helpers.print_line(orig_caller[0]) if full_opts[:line_no]
|
20
18
|
|
21
|
-
|
22
|
-
|
19
|
+
unless full_opts[:disable]
|
20
|
+
Helpers.message full_opts
|
21
|
+
Helpers.print_line(orig_caller[0]) if full_opts[:line_no]
|
22
|
+
|
23
|
+
tap do |o|
|
24
|
+
block.call(o, full_opts)
|
25
|
+
end
|
23
26
|
end
|
24
27
|
end
|
25
28
|
|
data/lib/letters/version.rb
CHANGED
data/spec/letters/config_spec.rb
CHANGED
@@ -40,6 +40,16 @@ module Letters
|
|
40
40
|
$stdout.should_receive(:puts).never
|
41
41
|
hash.b
|
42
42
|
end
|
43
|
+
|
44
|
+
it "allows disabling of all letters" do
|
45
|
+
Letters.config do
|
46
|
+
all :disable => true
|
47
|
+
b :line_no => true
|
48
|
+
end
|
49
|
+
|
50
|
+
$stdout.should_receive(:puts).never
|
51
|
+
hash.b
|
52
|
+
end
|
43
53
|
end
|
44
54
|
|
45
55
|
describe ".reset_config!" do
|