super_awesome_print 0.2.6 → 0.2.7
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.
- checksums.yaml +4 -4
- data/README.md +27 -18
- data/lib/super_awesome_print/configuration.rb +16 -8
- data/lib/super_awesome_print/version.rb +1 -1
- data/lib/super_awesome_print.rb +22 -28
- metadata +14 -25
- data/.gitignore +0 -9
- data/.rspec +0 -2
- data/.travis.yml +0 -4
- data/CODE_OF_CONDUCT.md +0 -13
- data/Gemfile +0 -4
- data/Rakefile +0 -6
- data/bin/console +0 -14
- data/bin/setup +0 -7
- data/super_awesome_print.gemspec +0 -30
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8dcbcd2d03a3005179e357dba79cac9ff235c4ef582aaaeaec9723191f7e6b14
|
|
4
|
+
data.tar.gz: 410e5466d12988d153b738f05381dbf9e920b7e0b0817bf7ec50997fd928f5cd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 85a06d0fbe8691681ceab0bf43bcfc58c78dfc98122d2e32240c6a805f8eaea0aa93a9c9a4f043e6f525dad18d39452219b68ab2a657c423c1f42e90358bbf65
|
|
7
|
+
data.tar.gz: '008722bc3e34bb2955a4fb16656067136bcf9967cc9507660bdec2ff068c742cc9b6146fd7f57e226930094ed6cef50fc3f57458251cbfe68e3cfc27d9eed2b6'
|
data/README.md
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# SuperAwesomePrint
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/olegantonyan/super_awesome_print/actions/workflows/ci.yml)
|
|
4
|
+
|
|
5
|
+
Prints values with [awesome_print](https://github.com/awesome-print/awesome_print), framed by colored `***` markers, a timestamp and the caller location, so they're easy to spot in long console output.
|
|
6
|
+
|
|
7
|
+

|
|
4
8
|
|
|
5
|
-

|
|
6
9
|
```ruby
|
|
7
10
|
def index
|
|
8
11
|
@posts = Post.all
|
|
@@ -18,52 +21,58 @@ Add this line to your application's Gemfile:
|
|
|
18
21
|
gem 'super_awesome_print'
|
|
19
22
|
```
|
|
20
23
|
|
|
21
|
-
And then
|
|
24
|
+
And then run:
|
|
22
25
|
|
|
23
26
|
$ bundle install
|
|
24
27
|
|
|
25
|
-
Or install it yourself
|
|
28
|
+
Or install it yourself:
|
|
26
29
|
|
|
27
30
|
$ gem install super_awesome_print
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
Requires Ruby 2.7 or newer.
|
|
33
|
+
|
|
34
|
+
## Configuration
|
|
35
|
+
|
|
36
|
+
Optionally, customize it in an initializer. In Rails, add the following to `config/initializers/super_awesome_print.rb`:
|
|
31
37
|
|
|
32
38
|
```ruby
|
|
33
39
|
SuperAwesomePrint.configure do |config|
|
|
34
|
-
config.caller_lines = 3 # defaults to 1
|
|
40
|
+
config.caller_lines = 3 # number of backtrace lines to print, defaults to 1
|
|
35
41
|
config.blank_lines_top = 2 # defaults to 0
|
|
36
42
|
config.blank_lines_bottom = 2 # defaults to 0
|
|
37
|
-
config.root_path = Rails.root.to_s #
|
|
38
|
-
config.log_file_path = '/some/path/to/log/file' #
|
|
43
|
+
config.root_path = Rails.root.to_s # stripped from caller paths, defaults to Rails.root
|
|
44
|
+
config.log_file_path = '/some/path/to/log/file' # where `sapf` writes
|
|
39
45
|
end
|
|
40
46
|
```
|
|
41
47
|
|
|
42
48
|
## Usage
|
|
43
49
|
|
|
44
|
-
|
|
50
|
+
Call `sap` anywhere to print a value. It returns its argument, so you can wrap an expression without changing it:
|
|
45
51
|
|
|
46
|
-
|
|
52
|
+
```ruby
|
|
53
|
+
total = sap(items.sum(&:price))
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
To write to a file instead, use `sapf`:
|
|
47
57
|
|
|
48
58
|
```ruby
|
|
49
59
|
sapf 'hello world'
|
|
50
60
|
```
|
|
51
61
|
|
|
52
|
-
By default
|
|
62
|
+
By default, `sapf` appends to `sapf.log` in the current directory, or to `log/sapf.log` in Rails. Set `log_file_path` to change it.
|
|
53
63
|
|
|
54
|
-
|
|
64
|
+
To keep `sap` from leaking into production, see the [RuboCop cop](https://github.com/olegantonyan/super_awesome_print_rubocop).
|
|
55
65
|
|
|
56
66
|
## Development
|
|
57
67
|
|
|
58
|
-
After checking out the repo, run `bin/setup` to install dependencies
|
|
68
|
+
After checking out the repo, run `bin/setup` to install dependencies, then `bundle exec rake test` to run the tests. Run `bin/console` for an interactive prompt.
|
|
59
69
|
|
|
60
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`,
|
|
70
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, then run `bundle exec rake release`. This creates a git tag for the version, pushes git commits and tags, and pushes the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
61
71
|
|
|
62
72
|
## Contributing
|
|
63
73
|
|
|
64
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/olegantonyan/super_awesome_print. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](
|
|
65
|
-
|
|
74
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/olegantonyan/super_awesome_print. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](https://www.contributor-covenant.org) code of conduct.
|
|
66
75
|
|
|
67
76
|
## License
|
|
68
77
|
|
|
69
|
-
The gem is available as open source under the terms of the [MIT License](
|
|
78
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
module SuperAwesomePrint
|
|
2
|
+
class Configuration
|
|
3
|
+
attr_accessor :caller_lines, :blank_lines_top, :blank_lines_bottom, :root_path, :log_file_path
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
def initialize
|
|
6
|
+
@caller_lines = 1
|
|
7
|
+
@blank_lines_top = 0
|
|
8
|
+
@blank_lines_bottom = 0
|
|
9
|
+
@root_path = rails_root
|
|
10
|
+
@log_file_path = @root_path.empty? ? File.join(Dir.pwd, 'sapf.log') : File.join(@root_path, 'log', 'sapf.log')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def rails_root
|
|
16
|
+
defined?(::Rails) && ::Rails.respond_to?(:root) ? ::Rails.root.to_s : ''
|
|
17
|
+
end
|
|
10
18
|
end
|
|
11
19
|
end
|
data/lib/super_awesome_print.rb
CHANGED
|
@@ -3,34 +3,29 @@ require 'super_awesome_print/configuration'
|
|
|
3
3
|
require 'awesome_print'
|
|
4
4
|
|
|
5
5
|
module Kernel
|
|
6
|
+
private
|
|
7
|
+
|
|
6
8
|
def sap(msg)
|
|
7
9
|
SuperAwesomePrint.blank_lines_top
|
|
8
|
-
ap "*** #{Time.now} ***", :
|
|
9
|
-
ap msg.class
|
|
10
|
-
SuperAwesomePrint.
|
|
10
|
+
ap "*** #{Time.now} ***", color: { string: :green }
|
|
11
|
+
ap msg.class
|
|
12
|
+
SuperAwesomePrint.trace(caller).each { |line| ap line, color: { string: :purpleish } }
|
|
11
13
|
ap msg
|
|
12
|
-
ap '*** END ***', :
|
|
14
|
+
ap '*** END ***', color: { string: :green }
|
|
13
15
|
SuperAwesomePrint.blank_lines_bottom
|
|
14
16
|
msg
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
def sapf(msg)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
else
|
|
26
|
-
line.gsub(root_path + '/', '')
|
|
27
|
-
end
|
|
20
|
+
trace = SuperAwesomePrint.trace(caller)
|
|
21
|
+
File.open(SuperAwesomePrint.config.log_file_path, 'a') do |file|
|
|
22
|
+
file.puts("*** #{Time.now} ***")
|
|
23
|
+
file.puts(" class: #{msg.class}")
|
|
24
|
+
trace.each { |line| file.puts(" trace: #{line}") }
|
|
25
|
+
file.puts(msg.inspect)
|
|
26
|
+
file.puts('*** END ***')
|
|
28
27
|
end
|
|
29
|
-
|
|
30
|
-
file.puts(msg.inspect)
|
|
31
|
-
file.puts('*** END ***')
|
|
32
|
-
ensure
|
|
33
|
-
file.close
|
|
28
|
+
msg
|
|
34
29
|
end
|
|
35
30
|
end
|
|
36
31
|
|
|
@@ -39,17 +34,16 @@ module SuperAwesomePrint
|
|
|
39
34
|
attr_writer :configuration
|
|
40
35
|
end
|
|
41
36
|
|
|
42
|
-
def self.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
lines.
|
|
37
|
+
def self.trace(backtrace)
|
|
38
|
+
lines = backtrace.first(config.caller_lines)
|
|
39
|
+
root = config.root_path.to_s.chomp('/')
|
|
40
|
+
return lines if root.empty?
|
|
41
|
+
|
|
42
|
+
lines.map { |line| line.sub(%r{\A#{Regexp.escape(root)}/}, '') }
|
|
48
43
|
end
|
|
49
44
|
|
|
50
45
|
def self.blank_lines_top
|
|
51
|
-
#
|
|
52
|
-
# So we want to puts once regardless of config
|
|
46
|
+
# the first puts has no visible effect, so always print one
|
|
53
47
|
puts
|
|
54
48
|
config.blank_lines_top.times { puts }
|
|
55
49
|
end
|
|
@@ -59,7 +53,7 @@ module SuperAwesomePrint
|
|
|
59
53
|
end
|
|
60
54
|
|
|
61
55
|
def self.config
|
|
62
|
-
|
|
56
|
+
configuration
|
|
63
57
|
end
|
|
64
58
|
|
|
65
59
|
def self.configuration
|
metadata
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: super_awesome_print
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Oleg Antonyan
|
|
8
|
-
|
|
9
|
-
bindir: exe
|
|
8
|
+
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
13
|
+
name: awesome_print
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
18
|
version: '0'
|
|
20
|
-
type: :
|
|
19
|
+
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
@@ -25,7 +24,7 @@ dependencies:
|
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '0'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
27
|
+
name: minitest
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
30
|
- - ">="
|
|
@@ -39,45 +38,36 @@ dependencies:
|
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: '0'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
41
|
+
name: rake
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
44
43
|
requirements:
|
|
45
44
|
- - ">="
|
|
46
45
|
- !ruby/object:Gem::Version
|
|
47
46
|
version: '0'
|
|
48
|
-
type: :
|
|
47
|
+
type: :development
|
|
49
48
|
prerelease: false
|
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
50
|
requirements:
|
|
52
51
|
- - ">="
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
53
|
version: '0'
|
|
55
|
-
description:
|
|
54
|
+
description: Prints values with awesome_print, framed by colored markers, a timestamp
|
|
55
|
+
and the caller location.
|
|
56
56
|
email:
|
|
57
57
|
- oleg.b.antonyan@gmail.com
|
|
58
58
|
executables: []
|
|
59
59
|
extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
|
61
61
|
files:
|
|
62
|
-
- ".gitignore"
|
|
63
|
-
- ".rspec"
|
|
64
|
-
- ".travis.yml"
|
|
65
|
-
- CODE_OF_CONDUCT.md
|
|
66
|
-
- Gemfile
|
|
67
62
|
- LICENSE.txt
|
|
68
63
|
- README.md
|
|
69
|
-
- Rakefile
|
|
70
|
-
- bin/console
|
|
71
|
-
- bin/setup
|
|
72
64
|
- lib/super_awesome_print.rb
|
|
73
65
|
- lib/super_awesome_print/configuration.rb
|
|
74
66
|
- lib/super_awesome_print/version.rb
|
|
75
|
-
|
|
76
|
-
homepage: http://github.com/olegantonyan/super_awesome_print
|
|
67
|
+
homepage: https://github.com/olegantonyan/super_awesome_print
|
|
77
68
|
licenses:
|
|
78
69
|
- MIT
|
|
79
70
|
metadata: {}
|
|
80
|
-
post_install_message:
|
|
81
71
|
rdoc_options: []
|
|
82
72
|
require_paths:
|
|
83
73
|
- lib
|
|
@@ -85,15 +75,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
85
75
|
requirements:
|
|
86
76
|
- - ">="
|
|
87
77
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: '
|
|
78
|
+
version: '2.7'
|
|
89
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
80
|
requirements:
|
|
91
81
|
- - ">="
|
|
92
82
|
- !ruby/object:Gem::Version
|
|
93
83
|
version: '0'
|
|
94
84
|
requirements: []
|
|
95
|
-
rubygems_version:
|
|
96
|
-
signing_key:
|
|
85
|
+
rubygems_version: 4.0.16
|
|
97
86
|
specification_version: 4
|
|
98
|
-
summary:
|
|
87
|
+
summary: awesome_print wrapper that makes debug output easy to spot in long logs
|
|
99
88
|
test_files: []
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# Contributor Code of Conduct
|
|
2
|
-
|
|
3
|
-
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
|
4
|
-
|
|
5
|
-
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
|
6
|
-
|
|
7
|
-
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
|
8
|
-
|
|
9
|
-
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
|
10
|
-
|
|
11
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
|
12
|
-
|
|
13
|
-
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
DELETED
data/Rakefile
DELETED
data/bin/console
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'bundler/setup'
|
|
4
|
-
require 'super_awesome_print'
|
|
5
|
-
|
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
-
|
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
-
# require "pry"
|
|
11
|
-
# Pry.start
|
|
12
|
-
|
|
13
|
-
require 'irb'
|
|
14
|
-
IRB.start
|
data/bin/setup
DELETED
data/super_awesome_print.gemspec
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require 'super_awesome_print/version'
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name = 'super_awesome_print'
|
|
8
|
-
spec.version = SuperAwesomePrint::VERSION
|
|
9
|
-
spec.authors = ['Oleg Antonyan']
|
|
10
|
-
spec.email = ['oleg.b.antonyan@gmail.com']
|
|
11
|
-
|
|
12
|
-
spec.summary = 'Simple wrapper around awesome_print for easier look in long log'
|
|
13
|
-
spec.description = "Add colored '*********', time and line number around printed value"
|
|
14
|
-
spec.homepage = 'http://github.com/olegantonyan/super_awesome_print'
|
|
15
|
-
spec.license = 'MIT'
|
|
16
|
-
|
|
17
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
18
|
-
spec.bindir = 'exe'
|
|
19
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
20
|
-
spec.require_paths = ['lib']
|
|
21
|
-
|
|
22
|
-
spec.add_development_dependency 'bundler'
|
|
23
|
-
spec.add_development_dependency 'rake'
|
|
24
|
-
|
|
25
|
-
if RUBY_VERSION < '1.9.3'
|
|
26
|
-
spec.add_runtime_dependency 'awesome_print', '1.2.0'
|
|
27
|
-
else
|
|
28
|
-
spec.add_runtime_dependency 'awesome_print'
|
|
29
|
-
end
|
|
30
|
-
end
|