puts_debuggerer 1.0.0 → 1.0.1

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: 43a2fbaa9054ef66fe1c92936402e68a375c1899d225a6ca4dd91283785c813d
4
- data.tar.gz: cd63108d9a2862e9569393b5efe9a3e5074a4b4393937b035092e733b7981553
3
+ metadata.gz: d233d55e6a6fd44243d0c03cc1a0d94452e8d6ca5ad1c363b286094ecbbea19b
4
+ data.tar.gz: cdc0375b20f5289213ebe2177d6812423654ed09e2405e490b60bb244011e923
5
5
  SHA512:
6
- metadata.gz: 79b7f7802d6b2c4bba93c336cd234d1550eecb20245a1a122d9fb383d4219eec8fc88c52b59ed042bc39c8863f47151b1357969f3de610f185b65f7e526b0d22
7
- data.tar.gz: ff4e1dd6a42fd3d5e43983c8e56671ee98dee8d60869f67d4af36b37bd10fdf78ec9c45067f724b32c5a265249aa944f853cf3dc812aec94c4e9f98ae7c5e114
6
+ metadata.gz: bd63f2cfba6602e0e090e565949782fe734ab62ca4f233114cdc7abb1b08ca213f8810f186f7ee8c5c63c9edfe04c39bc5661fc18ecd5ff20be18cd4fe3ef63c
7
+ data.tar.gz: 7c485c0dece0ee52bf9913b96620746974d8f28191a7ff182faeea18c84b65b331ba87d98b4038d60193c50170c5707d2eeaa0788bdc43950474dc6c28f5c0b8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.0.1
4
+
5
+ - Fix issue with deleting `pd` options from a `Hash` if it was the only argument breaking the guarantee that `pd` never modifies the printed object, which could cause bugs.
6
+ - Fix issue with attempting to modify a frozen `Hash` when passing a frozen `Hash` as the only argument for `pd` method
7
+
3
8
  ## 1.0.0
4
9
 
5
10
  - Support including class/method after file/line in every `pd` printout
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Puts Debuggerer 1.0.0
1
+ # Puts Debuggerer 1.0.1
2
2
  ## Debugger-less Debugging FTW
3
3
  ## [Featured in State of the Art Rails 2023 Edition](https://github.com/DanielVartanov/state-of-the-art-rails/tree/bd7a509f5f0ab07cebfeada779b5c73e1eaf22ed)
4
4
  [![Gem Version](https://badge.fury.io/rb/puts_debuggerer.svg)](http://badge.fury.io/rb/puts_debuggerer)
@@ -11,9 +11,9 @@ If you like [Awesome_Print](https://rubygems.org/gems/awesome_print) (or [Amazin
11
11
 
12
12
  Debuggers are great! They help us troubleshoot complicated programming problems by inspecting values produced by code, line by line. They are invaluable when trying to understand what is going on in a large application composed of thousands or millions of lines of code.
13
13
 
14
- In day-to-day test-driven development and simple app debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Still, there are a number of problems with puts debugging, like difficulty in locating puts statements in a large output log, knowing which methods and line numbers were invoked, identifying which variables were printed, and seeing the content of structured hashes and arrays in an understandable format.
14
+ In day-to-day test-driven development and simple app debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Still, there are a number of problems with puts debugging, like difficulty in locating puts statements in a large output log, knowing which files, line numbers, and methods the puts statements were invoked from, identifying which variables were printed, and seeing the content of structured hashes and arrays in an understandable format.
15
15
 
16
- Enter [puts_debuggerer](https://rubygems.org/gems/puts_debuggerer)! A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, invoked class methods, code statements, headers, footers, stack traces, and formats output nicely courtesy of [awesome_print](https://rubygems.org/gems/awesome_print) (or [amazing_print](https://github.com/amazing-print/amazing_print) if you prefer).
16
+ Enter [puts_debuggerer](https://rubygems.org/gems/puts_debuggerer)! A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, class names, method names, code statements, headers, footers, and stack traces; and formats output nicely courtesy of [awesome_print](https://rubygems.org/gems/awesome_print) (or [amazing_print](https://github.com/amazing-print/amazing_print) if you prefer).
17
17
 
18
18
  [puts_debuggerer](https://rubygems.org/gems/puts_debuggerer) automates tips mentioned in [this blog post](https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html) by Aaron Patterson using the `pd` method available everywhere after requiring the [gem](https://rubygems.org/gems/puts_debuggerer).
19
19
 
@@ -39,7 +39,7 @@ Output:
39
39
  => "Beatles"
40
40
  ```
41
41
 
42
- `pd` revealed that the variable contains the band name "Beatles" as its value not the bug "Beetle", in addition to revealing the printed code statement `pd bug_or_band`, the file name `/Users/User/trivia_app.rb`, the line number `6`, the class name `TriviaApp`, and the invoked method name `question`.
42
+ `pd` revealed that the variable contains the band name "Beatles" not the bug "Beetle", in addition to revealing the printed code statement `pd bug_or_band`, the file name `/Users/User/trivia_app.rb`, the line number `6`, the class name `TriviaApp`, and the method name `question`.
43
43
 
44
44
  ## Background
45
45
 
@@ -72,7 +72,7 @@ Which gets lost in a logging stream such as:
72
72
  (0.2ms) COMMIT
73
73
  ```
74
74
 
75
- Here is a simple example using `pd` instead, which provides everything the puts statements above provide in addition to deducing the file name, line number, and invoked class method automatically for dead-easy debugging:
75
+ Here is a simple example using `pd` instead, which provides everything the puts statements above provide in addition to deducing the file name, line number, class name, and method name automatically for dead-easy debugging:
76
76
 
77
77
  ```ruby
78
78
  pd order_total
@@ -332,7 +332,7 @@ This is the recommended way for installing in [Rails](rubyonrails.org) apps in a
332
332
  Add the following to bundler's `Gemfile` (in Rails, you can optionally limit to the `:development` and `:test` groups).
333
333
 
334
334
  ```ruby
335
- gem 'puts_debuggerer', '~> 1.0.0'
335
+ gem 'puts_debuggerer', '~> 1.0.1'
336
336
  ```
337
337
 
338
338
  Run:
@@ -353,12 +353,21 @@ unless Rails.env.development? || Rails.env.test?
353
353
  end
354
354
  ```
355
355
 
356
+ The Rails `config.log_level` is assumed to be `:debug`. If you have it set to something else like `:info`, then you need to update `PutsDebuggerer.printer` to print at a different log level (e.g. `:info`) by adding the following code to the initializer above (this code is a modification of the default at `PutsDebuggerer::PRINTER_RAILS`):
357
+
358
+ ```ruby
359
+ PutsDebuggerer.printer = lambda do |output|
360
+ puts output if Rails.env.test?
361
+ Rails.logger.info(output)
362
+ end
363
+ ```
364
+
356
365
  ### Option 2: Manual
357
366
 
358
367
  Or manually install and require library.
359
368
 
360
369
  ```bash
361
- gem install puts_debuggerer -v1.0.0
370
+ gem install puts_debuggerer -v1.0.1
362
371
  ```
363
372
 
364
373
  ```ruby
@@ -418,7 +427,7 @@ Output:
418
427
  => "Beatles"
419
428
  ```
420
429
 
421
- In addition to the object/expression output, you get to see the source file name, line number, invoked class method, and source code to help you debug and troubleshoot problems quicker (it even works in IRB).
430
+ In addition to the object/expression output, you get to see the source file name, line number, class name, method name, and source code to help you debug and troubleshoot problems quicker (it even works in IRB).
422
431
 
423
432
  You can use `pd` at the top-level main object too, and it prings `Object.<main>` for the class/method.
424
433
 
@@ -831,7 +840,7 @@ Prints out the following in standard out stream only (not in log files):
831
840
 
832
841
  Print engine is similar to `printer`, except it is focused on the scope of formatting
833
842
  the data object being printed (excluding metadata such as file name, line number,
834
- invoked class method, and expression, which are handled by the `printer`).
843
+ class name, method name, and expression, which are handled by the `printer`).
835
844
  As such, it is also a global method symbol or lambda expression.
836
845
  Examples of global methods are `:p`, `:ap`, and `:pp`.
837
846
  An example of a lambda expression is `lambda {|object| puts object.to_a.join(" | ")}`
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -484,9 +484,7 @@ module PutsDebuggerer
484
484
  convert_options(objects.delete_at(-1))
485
485
  elsif objects.size == 1 && objects.first.is_a?(Hash)
486
486
  hash = objects.first
487
- convert_options(hash.slice(*OPTIONS).tap do
488
- hash.delete_if {|option| OPTIONS.include?(option)}
489
- end)
487
+ convert_options(hash.slice(*OPTIONS))
490
488
  end
491
489
  end
492
490
 
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: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-31 00:00:00.000000000 Z
11
+ date: 2024-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -124,7 +124,7 @@ dependencies:
124
124
  version: '0'
125
125
  description: |
126
126
  Debuggers are great! They help us troubleshoot complicated programming problems by inspecting values produced by code, line by line. They are invaluable when trying to understand what is going on in a large application composed of thousands or millions of lines of code.
127
- In day-to-day test-driven development and simple debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Problem is you need to locate puts statements in large output logs, know which methods were invoked, find out what variable names are being printed, and see nicely formatted output. Enter puts_debuggerer. A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, invoked class methods, code statements, and formats output nicely courtesy of awesome_print.
127
+ In day-to-day test-driven development and simple debugging though, a puts statement can be a lot quicker in revealing what is going on than halting execution completely just to inspect a single value or a few. This is certainly true when writing the simplest possible code that could possibly work, and running a test every few seconds or minutes. Problem is you need to locate puts statements in large output logs, know which file names, line numbers, classes, and methods contained the puts statements, find out what variable names are being printed, and see nicely formatted output. Enter puts_debuggerer. A guilt-free puts debugging Ruby gem FTW that prints file names, line numbers, class names, method names, and code statements; and formats output nicely courtesy of awesome_print.
128
128
  Partially inspired by this blog post: https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html (Credit to Tenderlove.)
129
129
  email: andy.am@gmail.com
130
130
  executables: []
@@ -168,6 +168,6 @@ rubygems_version: 3.5.3
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: Ruby library for improved puts debugging, automatically displaying bonus
171
- useful information such as source file name, line number, invoked class method,
171
+ useful information such as source file name, line number, class name, method name,
172
172
  and source code.
173
173
  test_files: []