puts_debuggerer 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -8
- data/lib/puts_debuggerer.rb +8 -17
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15dfcef6a6e1e5beb4239710ba4b0fa7e7577b1b
|
4
|
+
data.tar.gz: cf41610d09b62afd8792dfe7665cca246b89402c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5b7a1e346bd3e8d084d367fabbacaf396b9117ead8c071c3cabaf2d6645222c2e521c63876e73a710fe740121472559a174a1e44b5f54dc067199293113ce8b
|
7
|
+
data.tar.gz: eac965aa078e785bc9a99b337e981dc43820af6a8c4a7bb1de8a5567b9937359315d303c221fedfa0ebd832658aac531deea44332de07d057c8ae71d960a7888
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# puts_debuggerer v0.7.
|
1
|
+
# puts_debuggerer v0.7.1
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/puts_debuggerer.svg)](http://badge.fury.io/rb/puts_debuggerer)
|
3
3
|
[![Build Status](https://travis-ci.org/AndyObtiva/puts_debuggerer.svg?branch=master)](https://travis-ci.org/AndyObtiva/puts_debuggerer)
|
4
4
|
[![Coverage Status](https://coveralls.io/repos/github/AndyObtiva/puts_debuggerer/badge.svg?branch=master)](https://coveralls.io/github/AndyObtiva/puts_debuggerer?branch=master)
|
@@ -25,7 +25,7 @@ Love PD?! Why not promote with [merchandise](https://www.zazzle.com/i+heart+pd+g
|
|
25
25
|
Add the following to bundler's `Gemfile`.
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
gem 'puts_debuggerer', '~> 0.7.
|
28
|
+
gem 'puts_debuggerer', '~> 0.7.1'
|
29
29
|
```
|
30
30
|
|
31
31
|
This is the recommended way for [Rails](rubyonrails.org) apps. Optionally, you may create an initializer under `config/initializers` named `puts_debuggerer_options.rb` to enable further customizations as per the [Options](#options) section below.
|
@@ -35,7 +35,7 @@ This is the recommended way for [Rails](rubyonrails.org) apps. Optionally, you m
|
|
35
35
|
Or manually install and require library.
|
36
36
|
|
37
37
|
```bash
|
38
|
-
gem install puts_debuggerer -v0.7.
|
38
|
+
gem install puts_debuggerer -v0.7.1
|
39
39
|
```
|
40
40
|
|
41
41
|
```ruby
|
@@ -217,12 +217,11 @@ Prints out:
|
|
217
217
|
```
|
218
218
|
|
219
219
|
#### `PutsDebuggerer.print_engine`
|
220
|
-
(default = `:
|
220
|
+
(default = `:ap`)
|
221
221
|
|
222
222
|
Print engine is a global method symbol or lambda expression to use in object printout. Examples of global methods are `:p`, `:ap`, and `:pp`. An example of a lambda expression is `lambda {|o| Rails.logger.info(o)}`
|
223
223
|
|
224
|
-
Defaults to
|
225
|
-
If it finds [awesome_print](https://github.com/awesome-print/awesome_print) loaded, it defaults to `ap` as `:ap` instead. Also, if it finds Rails loaded without ap, it relies on `lambda {|o| Rails.logger.debug(o)}` as the print engine. Otherwise if both Rails and [awesome_print](https://github.com/awesome-print/awesome_print) are loaded, then it relies on `lambda {|o| Rails.logger.ap(o)}` instead
|
224
|
+
Defaults to [awesome_print](https://github.com/awesome-print/awesome_print). If it finds Rails loaded it defaults to `lambda {|o| Rails.logger.ap(o)}` instead
|
226
225
|
|
227
226
|
Example:
|
228
227
|
|
@@ -366,6 +365,7 @@ the same exact `object` passed to `pd` for counting.
|
|
366
365
|
|
367
366
|
Examples (global):
|
368
367
|
|
368
|
+
```ruby
|
369
369
|
PutsDebuggerer.run_at = 1
|
370
370
|
pd (x=1) # prints standard PD output
|
371
371
|
pd (x=1) # prints nothing
|
@@ -401,13 +401,14 @@ Examples (global):
|
|
401
401
|
pd (x=1) # prints nothing
|
402
402
|
pd (x=1) # prints nothing
|
403
403
|
pd (x=1) # prints standard PD output
|
404
|
-
pd (x=1) ... continue printing indefinitely on all subsequent runs
|
404
|
+
pd (x=1) # ... continue printing indefinitely on all subsequent runs
|
405
405
|
|
406
406
|
PutsDebuggerer.run_at = 3...-1
|
407
407
|
pd (x=1) # prints nothing
|
408
408
|
pd (x=1) # prints nothing
|
409
409
|
pd (x=1) # prints standard PD output
|
410
|
-
pd (x=1) ... continue printing indefinitely on all subsequent runs
|
410
|
+
pd (x=1) # ... continue printing indefinitely on all subsequent runs
|
411
|
+
```
|
411
412
|
|
412
413
|
You may reset the run_at number counter via:
|
413
414
|
`PutsDebuggerer.reset_run_at_global_number` for global usage.
|
@@ -474,6 +475,7 @@ Prints out `puts __caller_source_line__`
|
|
474
475
|
|
475
476
|
## Release Notes
|
476
477
|
|
478
|
+
* v0.7.1: default print engine to :ap (AwesomePrint)
|
477
479
|
* v0.7.0: `run_at` option, global and piecemeal.
|
478
480
|
* v0.6.1: updated README and broke apart specs
|
479
481
|
* v0.6.0: unofficial erb support, returning evaluated object/expression, removed static syntax support (replaced with header support)
|
data/lib/puts_debuggerer.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'ripper'
|
2
|
+
require 'awesome_print'
|
2
3
|
|
3
4
|
module PutsDebuggerer
|
4
5
|
HEADER_DEFAULT = '*'*80
|
5
6
|
FOOTER_DEFAULT = '*'*80
|
6
|
-
PRINT_ENGINE_DEFAULT = :
|
7
|
+
PRINT_ENGINE_DEFAULT = :ap
|
7
8
|
PRINT_ENGINE_MESSAGE_INVALID = 'print_engine must be a valid global method symbol (e.g. :p or :puts) or lambda/proc'
|
8
9
|
ANNOUNCER_DEFAULT = '[PD]'
|
9
10
|
FORMATTER_DEFAULT = -> (data) {
|
@@ -107,14 +108,13 @@ module PutsDebuggerer
|
|
107
108
|
# Print engine to use in object printout (e.g. `p`, `ap`, `pp`).
|
108
109
|
# It is represented by the print engine's global method name as a symbol
|
109
110
|
# (e.g. `:ap` for awesome_print).
|
110
|
-
# Defaults to
|
111
|
-
# If it finds awesome_print loaded, it defaults to `ap` as `:ap` instead.
|
111
|
+
# Defaults to awesome_print loaded.
|
112
112
|
#
|
113
113
|
# Example:
|
114
114
|
#
|
115
115
|
# # File Name: /Users/User/example.rb
|
116
116
|
# require 'awesome_print'
|
117
|
-
# PutsDebuggerer.print_engine = :
|
117
|
+
# PutsDebuggerer.print_engine = :p
|
118
118
|
# array = [1, [2, 3]]
|
119
119
|
# pd array
|
120
120
|
#
|
@@ -122,28 +122,19 @@ module PutsDebuggerer
|
|
122
122
|
#
|
123
123
|
# [PD] /Users/User/example.rb:5
|
124
124
|
# > pd array
|
125
|
-
# => [
|
126
|
-
# [0] 1,
|
127
|
-
# [1] [
|
128
|
-
# [0] 2,
|
129
|
-
# [1] 3
|
130
|
-
# ]
|
125
|
+
# => [1, [2, 3]]
|
131
126
|
# ]
|
132
127
|
attr_reader :print_engine
|
133
128
|
|
134
129
|
def print_engine=(engine)
|
135
130
|
if engine.nil?
|
136
131
|
if Object.const_defined?(:Rails)
|
137
|
-
|
138
|
-
@print_engine = lambda {|object| Rails.logger.ap(object)}
|
139
|
-
else
|
140
|
-
@print_engine = lambda {|object| Rails.logger.debug(object)}
|
141
|
-
end
|
132
|
+
@print_engine = lambda {|object| Rails.logger.ap(object)}
|
142
133
|
else
|
143
|
-
@print_engine =
|
134
|
+
@print_engine = PRINT_ENGINE_DEFAULT
|
144
135
|
end
|
145
136
|
elsif engine.is_a?(Proc)
|
146
|
-
@print_engine = engine
|
137
|
+
@print_engine = engine
|
147
138
|
else
|
148
139
|
@print_engine = method(engine).name rescue raise(PRINT_ENGINE_MESSAGE_INVALID)
|
149
140
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puts_debuggerer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Maleh
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.8.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.8.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|