puts_debuggerer 0.13.1 → 0.13.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ebff6f84d78f7241fdb021e55a6d90ab94a1a2827cfd9a1dee2280a28a34d42
4
- data.tar.gz: d5960273c6cde51e258c4b426cfff5ff00bf67f4961c32c85011698888c228d2
3
+ metadata.gz: 6f1e480d2a8330d48a546c7e89a2479185cfad2bc1f6b8cf1a9750494de27406
4
+ data.tar.gz: e135390dd68993136fd2fd4d22d4721dd8a12454f5ce71f2ad164f453358e1db
5
5
  SHA512:
6
- metadata.gz: 9b82d39c624a8d151d6d72c73b0f464e74935cf4d0c88140c700f533647ad3f089b8be41cb3f0e2e7c97ea06b917d57ef4f91292accc6a2b74d4cd50198ca442
7
- data.tar.gz: ffcc096603c4b46a1e134b2ab8de5090403fc579505bd6a7a5b9eaa9e87561faa6ef5d5196d88157fe92ea370a4c309bc0edeb9da278ec8128cdbf88743884c5
6
+ metadata.gz: 752b67073d6ffda81d890aa568a74f48f7f09b3321c4d5b6e7f51ea8a5c098b0feebe77e3ca5d4f0a80eb842844e8d76f8f75443ab075f153d761842594664db
7
+ data.tar.gz: bb327d1a2633282307da402569697746c4f0ba91e0c93955728fb9ba647bec9d7d2100406040afe950c630d4a0e9774d3afdc94ac0e8bf1795b429e231dda2d4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.13.2
4
+
5
+ - Fix issue caused by MiniTest Rails having `IRB` constant declared despite being outside of IRB
6
+
7
+ ## 0.13.1
8
+
9
+ - Support `a: '[PD]'` shortcut to passing `announcer: '[PD]'`
10
+ - Support `c: :t` shortcut to passing `caller: true`
11
+
3
12
  ## 0.13.0
4
13
 
5
14
  - Support `h: :t` shortcut to passing `header: true`
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2017-2020 - Andy Maleh
1
+ Copyright (c) 2017-2021 - Andy Maleh
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -114,7 +114,7 @@ Output:
114
114
  => "[Hard Cover] Pragmatic Ruby Book - English Version"
115
115
  ```
116
116
 
117
- What if you would like to add a header for faster findability of groups of related pd statements? Just use the `header` option (or `h`):
117
+ What if you would like to add a header for faster findability of groups of related pd statements? Just use the `header` option:
118
118
 
119
119
  ```ruby
120
120
  pd order_total, header: true
@@ -122,6 +122,14 @@ pd order_summary
122
122
  pd order_details
123
123
  ```
124
124
 
125
+ Or the `h` shortcut:
126
+
127
+ ```ruby
128
+ pd order_total, h: :t
129
+ pd order_summary
130
+ pd order_details
131
+ ```
132
+
125
133
  Output:
126
134
 
127
135
  ```
@@ -145,12 +153,20 @@ Output:
145
153
  => "[Hard Cover] Pragmatic Ruby Book - English Version"
146
154
  ```
147
155
 
148
- Wanna customize the header and add a footer too? No problem:
156
+ Wanna add a footer too? No problem!
157
+
158
+ ```ruby
159
+ pd order_total, header: true
160
+ pd order_summary
161
+ pd order_details, footer: true
162
+ ```
163
+
164
+ Or use the `f` shortcut:
149
165
 
150
166
  ```ruby
151
- pd order_total, header: '>'*80
167
+ pd order_total, h: :t
152
168
  pd order_summary
153
- pd order_details, footer: '<'*80
169
+ pd order_details, f: :t
154
170
  ```
155
171
 
156
172
  Output:
@@ -158,7 +174,7 @@ Output:
158
174
  ```
159
175
  (2.7ms) CREATE TABLE "ar_internal_metadata" ("key" character varying PRIMARY KEY, "value" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
160
176
  ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]]
161
- >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
177
+ ################################################################################
162
178
  [PD] /Users/User/ordering/order.rb:39
163
179
  > pd order_total, header: '>'*80
164
180
  => 195.50
@@ -174,10 +190,10 @@ Output:
174
190
  [PD] /Users/User/ordering/order.rb:41
175
191
  > pd order_details, footer: '<'*80
176
192
  => "[Hard Cover] Pragmatic Ruby Book - English Version"
177
- <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
193
+ ################################################################################
178
194
  ```
179
195
 
180
- Need a quick stack trace? Just use the `caller` option (you may surround with header and footer too via `wrapper` or `w`).
196
+ Need a quick stack trace? Just use the `caller` option (you may surround with header and footer too via `wrapper`).
181
197
 
182
198
  ```ruby
183
199
  pd order_total, caller: true, wrapper: true
@@ -185,6 +201,14 @@ pd order_summary
185
201
  pd order_details
186
202
  ```
187
203
 
204
+ Or use the `c` and `w` shortcuts:
205
+
206
+ ```ruby
207
+ pd order_total, c: :t, w: :t
208
+ pd order_summary
209
+ pd order_details
210
+ ```
211
+
188
212
  Output:
189
213
 
190
214
  ```
@@ -254,6 +278,14 @@ pd order_summary
254
278
  pd order_details
255
279
  ```
256
280
 
281
+ Or use shortcut syntax:
282
+
283
+ ```ruby
284
+ pd order_total, c: 3, w: :t
285
+ pd order_summary
286
+ pd order_details
287
+ ```
288
+
257
289
  ```
258
290
  (2.7ms) CREATE TABLE "ar_internal_metadata" ("key" character varying PRIMARY KEY, "value" character varying, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
259
291
  ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", :environment], ["LIMIT", 1]]
@@ -288,7 +320,7 @@ There are many more options and features in [puts_debuggerer](https://rubygems.o
288
320
  Add the following to bundler's `Gemfile`.
289
321
 
290
322
  ```ruby
291
- gem 'puts_debuggerer', '~> 0.13.1'
323
+ gem 'puts_debuggerer', '~> 0.13.2'
292
324
  ```
293
325
 
294
326
  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.
@@ -298,7 +330,7 @@ This is the recommended way for [Rails](rubyonrails.org) apps. Optionally, you m
298
330
  Or manually install and require library.
299
331
 
300
332
  ```bash
301
- gem install puts_debuggerer -v0.13.1
333
+ gem install puts_debuggerer -v0.13.2
302
334
  ```
303
335
 
304
336
  ```ruby
@@ -470,7 +502,7 @@ Example Printout:
470
502
  ```
471
503
 
472
504
  #### `PutsDebuggerer.header`
473
- (default = `'>'*80`)
505
+ (default = `'>'*80`) [shortcut: `h`]
474
506
 
475
507
  Header to include at the top of every print out.
476
508
  * Default value is `nil`
@@ -530,7 +562,7 @@ Prints out:
530
562
  ```
531
563
 
532
564
  #### `PutsDebuggerer.footer`
533
- (default = `'<'*80`)
565
+ (default = `'<'*80`) [shortcut: `f`]
534
566
 
535
567
  Footer to include at the bottom of every print out.
536
568
  * Default value is `nil`
@@ -590,7 +622,7 @@ Prints out:
590
622
  ```
591
623
 
592
624
  #### `PutsDebuggerer.wrapper`
593
- (default = `'*'*80`)
625
+ (default = `'*'*80`) [shortcut: `w`]
594
626
 
595
627
  Wrapper to include at the top and bottom of every print out (both header and footer).
596
628
  * Default value is `nil`
@@ -762,7 +794,7 @@ Prints out:
762
794
  ```
763
795
 
764
796
  #### `PutsDebuggerer.announcer`
765
- (default = `"[PD]"`)
797
+ (default = `"[PD]"`) [shortcut: `a`]
766
798
 
767
799
  Announcer (e.g. `[PD]`) to announce every print out with (default: `"[PD]"`)
768
800
 
@@ -833,7 +865,7 @@ FOOTER: ************************************************************************
833
865
  ```
834
866
 
835
867
  #### `PutsDebuggerer.caller`
836
- (default = nil)
868
+ (default = nil) [shortcut: `c`]
837
869
 
838
870
  Caller backtrace included at the end of every print out
839
871
  Passed an argument of true/false, nil, or depth as an integer.
@@ -845,15 +877,33 @@ Example:
845
877
 
846
878
  ```ruby
847
879
  # File Name: /Users/User/sample_app/lib/sample.rb
848
- PutsDebuggerer.caller = 3
849
- pd (x=1)
880
+ pd (x=1), caller: 3
850
881
  ```
851
882
 
852
- Prints out:
883
+ Prints out (fictional):
853
884
 
854
885
  ```bash
855
- [PD] /Users/User/sample_app/lib/sample.rb:3
856
- > pd x=1
886
+ [PD] /Users/User/sample_app/lib/sample.rb:2
887
+ > pd x=1, caller: 3
888
+ => "1"
889
+ /Users/User/sample_app/lib/master_samples.rb:368:in \`block (3 levels) in <top (required)>\'
890
+ /Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`eval\'
891
+ /Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`evaluate\'
892
+ /Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/context.rb:381:in \`evaluate\'
893
+ ```
894
+
895
+ Shortcut Example:
896
+
897
+ ```ruby
898
+ # File Name: /Users/User/sample_app/lib/sample.rb
899
+ pd (x=1), c: 3
900
+ ```
901
+
902
+ Prints out (fictional):
903
+
904
+ ```bash
905
+ [PD] /Users/User/sample_app/lib/sample.rb:2
906
+ > pd x=1, caller: 3
857
907
  => "1"
858
908
  /Users/User/sample_app/lib/master_samples.rb:368:in \`block (3 levels) in <top (required)>\'
859
909
  /Users/User/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/irb/workspace.rb:87:in \`eval\'
@@ -1054,4 +1104,4 @@ Note that it ignores the configured printer when printing exceptions as it relie
1054
1104
 
1055
1105
  [MIT](LICENSE.txt)
1056
1106
 
1057
- Copyright (c) 2017-2020 - Andy Maleh.
1107
+ Copyright (c) 2017-2021 - Andy Maleh.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.1
1
+ 0.13.2
@@ -147,7 +147,7 @@ module Kernel
147
147
  if defined?(Pry)
148
148
  @pry_instance ||= Pry.new
149
149
  source_line = Pry::Command::Hist.new(pry_instance: @pry_instance).call.instance_variable_get(:@buffer).split("\n")[source_line_number - 1] # TODO handle multi-lines in source_line_count
150
- elsif defined?(IRB)
150
+ elsif defined?(IRB) && TOPLEVEL_BINDING.receiver.respond_to?(:conf)
151
151
  source_line = TOPLEVEL_BINDING.receiver.conf.io.line(source_line_number) # TODO handle multi-lines in source_line_count
152
152
  else
153
153
  source_line = PutsDebuggerer::SourceFile.new(source_file).source(source_line_count, source_line_number)
@@ -1,7 +1,7 @@
1
1
  module PutsDebuggerer
2
2
  class SourceFile
3
3
  def initialize(file_path)
4
- @file = File.new(file_path) if file_path
4
+ @file = File.new(file_path) if file_path && File.exist?(file_path)
5
5
  end
6
6
 
7
7
  def source(source_line_count, source_line_number)
@@ -16,7 +16,7 @@ module PutsDebuggerer
16
16
  def source_lines(source_line_count, source_line_number)
17
17
  lines = []
18
18
  begin
19
- while @file.lineno < source_line_number + source_line_count
19
+ while @file && @file.lineno < source_line_number + source_line_count
20
20
  file_line_number = @file.lineno + 1
21
21
  file_line = @file.readline
22
22
  if file_line_number >= source_line_number && file_line_number < source_line_number + source_line_count
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puts_debuggerer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.1
4
+ version: 0.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-04 00:00:00.000000000 Z
11
+ date: 2021-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -206,7 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
206
206
  - !ruby/object:Gem::Version
207
207
  version: '0'
208
208
  requirements: []
209
- rubygems_version: 3.2.3
209
+ rubygems_version: 3.2.31
210
210
  signing_key:
211
211
  specification_version: 4
212
212
  summary: Ruby library for improved puts debugging, automatically displaying bonus