wrapped_print 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +20 -5
- data/lib/wrapped_print/version.rb +1 -1
- data/lib/wrapped_print.rb +5 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8380d15cf9fef2966497078a0ea8bd86b3da7af68b7e8478521aee29e09c5bef
|
4
|
+
data.tar.gz: b15e54b6c314a2eee7f183fc827107f42aa4180415f57f51b2597b731f124a2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ee262235312fee3016a33a1d88bead7a9e3de67c06db580bed05c9abf7c87ae2634fdfd165e39e8b20acc10f2361b012318cf4e6224615a76c4dfbbf6909f08
|
7
|
+
data.tar.gz: 5f45236620e28963ba20789484e71cecf6b8481dbfbfb0c7c19b498579b6f1aa9bc58be72ffea50b4e6b09b40454a12abfe73dfe1fd331a0e0d20d3f7f1adfa4
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# WrappedPrint
|
2
2
|
|
3
|
-
|
3
|
+
[![RailsJazz](https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/my_other.svg?raw=true)](https://www.railsjazz.com)
|
4
|
+
[![https://www.patreon.com/igorkasyanchuk](https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/patron.svg?raw=true)](https://www.patreon.com/igorkasyanchuk)
|
5
|
+
|
6
|
+
How usually you debug your code? Binding.pry, byebug, puts, ...
|
4
7
|
|
5
8
|
How ofter do you write a code something like:
|
6
9
|
|
@@ -10,12 +13,20 @@ puts current_user.full_name
|
|
10
13
|
puts "="*50
|
11
14
|
```
|
12
15
|
|
13
|
-
I do this at least few times per week, sometimes per day.
|
16
|
+
I do this at least few times per week, sometimes per day.
|
14
17
|
|
15
18
|
This is annoying. It's need to be automated. And this gem is a simple solution.
|
16
19
|
|
17
20
|
Just add this gem and use a global method `.wp` to see in the console value of your object or wrap code in block with `wp { ... }`.
|
18
21
|
|
22
|
+
```ruby
|
23
|
+
def index
|
24
|
+
# to get list of emails and print them in console
|
25
|
+
# .wp method prints in console and returns same object
|
26
|
+
@emails = User.pluck(:emails).wp
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
19
30
|
See screenshot below with examples of usage (gem can be used not only in specs, this is just an example).
|
20
31
|
|
21
32
|
[<img src="https://raw.githubusercontent.com/igorkasyanchuk/wrapped_print/main/docs/demo_print.png"
|
@@ -41,17 +52,18 @@ And then `require "wrapped_print"`
|
|
41
52
|
|
42
53
|
## Usage
|
43
54
|
|
44
|
-
You can do a simple configuration to the gem:
|
55
|
+
You can do a simple configuration to the gem (config/initializers/wrapped_print.rb):
|
45
56
|
|
46
57
|
```ruby
|
47
58
|
WrappedPrint.setup do |config|
|
48
59
|
# config.log_to = :console # simply puts
|
49
60
|
config.log_to = :logs # e.g. Rails.logger.info....
|
61
|
+
# config.log_to = ActiveSupport::Logger.new($stdout) # custom logger
|
50
62
|
|
51
63
|
# # applicable only for Logger (not console)
|
52
64
|
config.level = :debug
|
53
65
|
# config.level = :info
|
54
|
-
end
|
66
|
+
end if defined?(WrappedPrint)
|
55
67
|
```
|
56
68
|
|
57
69
|
You can print using `puts` or to `Rails.logger`.
|
@@ -73,7 +85,7 @@ or
|
|
73
85
|
```ruby
|
74
86
|
#
|
75
87
|
# see how .wp is called. This method `.wp` returning the original value, so you can use it as normal variable.
|
76
|
-
#
|
88
|
+
#
|
77
89
|
class A
|
78
90
|
def calc
|
79
91
|
z = balance.wp # same as z = balance
|
@@ -100,3 +112,6 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/igorka
|
|
100
112
|
## License
|
101
113
|
|
102
114
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
115
|
+
|
116
|
+
[<img src="https://github.com/igorkasyanchuk/rails_time_travel/blob/main/docs/more_gems.png?raw=true"
|
117
|
+
/>](https://www.railsjazz.com/?utm_source=github&utm_medium=bottom&utm_campaign=wrapped_print)
|
data/lib/wrapped_print.rb
CHANGED
@@ -4,6 +4,7 @@ require "active_support"
|
|
4
4
|
# WrappedPrint.setup do |config|
|
5
5
|
# config.log_to = :console # simply puts
|
6
6
|
# config.log_to = :logs # e.g. Rails.logger.info....
|
7
|
+
# config.log_to = ActiveSupport::Logger.new("#{Rails.root}/log/wrapped_print.log") # custom logger
|
7
8
|
|
8
9
|
# # applicable only for Logger (not console)
|
9
10
|
# config.level = :debug
|
@@ -51,7 +52,10 @@ module WrappedPrint
|
|
51
52
|
|
52
53
|
private
|
53
54
|
def detect_logger_method
|
54
|
-
|
55
|
+
return WrappedPrint.log_to.method(WrappedPrint.level) if WrappedPrint.log_to.is_a?(ActiveSupport::Logger)
|
56
|
+
|
57
|
+
case WrappedPrint.log_to
|
58
|
+
when :logs
|
55
59
|
Rails.logger.method(WrappedPrint.level)
|
56
60
|
else
|
57
61
|
method(:puts)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wrapped_print
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -51,7 +51,7 @@ licenses:
|
|
51
51
|
- MIT
|
52
52
|
metadata:
|
53
53
|
homepage_uri: https://github.com/igorkasyanchuk/wrapped_print
|
54
|
-
post_install_message:
|
54
|
+
post_install_message:
|
55
55
|
rdoc_options: []
|
56
56
|
require_paths:
|
57
57
|
- lib
|
@@ -66,8 +66,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
|
-
rubygems_version: 3.
|
70
|
-
signing_key:
|
69
|
+
rubygems_version: 3.3.7
|
70
|
+
signing_key:
|
71
71
|
specification_version: 4
|
72
72
|
summary: Very simple utility to help your with debugging code and print values to
|
73
73
|
console
|