debugging 1.0.0 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.editorconfig +12 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/ChangeLog.md +50 -0
- data/Gemfile +0 -4
- data/{LICENSE.txt → MIT-LICENSE.txt} +1 -1
- data/README.md +173 -0
- data/Rakefile +28 -24
- data/debugging.gemspec +8 -8
- data/lib/debugging/howtocall.rb +36 -0
- data/lib/debugging/mof.rb +13 -12
- data/lib/debugging/q.rb +1 -1
- data/lib/debugging/version.rb +1 -1
- data/spec/howtocall_spec.rb +74 -0
- data/spec/q_spec.rb +10 -8
- metadata +29 -50
- data/.travis.yml +0 -13
- data/ChangeLog.rdoc +0 -17
- data/README.rdoc +0 -102
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e4ec121a21a63ab0420e7c1aaa05cb7f12fd6269090a7ab8d177fbdb630ca7a0
|
4
|
+
data.tar.gz: 8f120206703e54307826c9d293f6f14379f9b4e2f7673a05ddf93d113a940e6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3840c3a53afdf18f074086ee5fa628887f0176284edb371c752600140f78617b611dddc05d76a6a9b17e4eaadb819d039c1f4aa90401009babbd0de1a9a6e5f
|
7
|
+
data.tar.gz: b2b295c4a739ac963d881fffdcbdda265c59025b45389a5a96faa59f1ae894a9599b9746016b2f72960c2101e1579cd12a5d7c6ad0fae7e7312482da79b5f527
|
data/.editorconfig
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at conduct@janlelis.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/ChangeLog.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
## ChangeLog
|
2
|
+
|
3
|
+
### 1.1.2 / 2020-12-29
|
4
|
+
|
5
|
+
* Relax required Ruby version
|
6
|
+
|
7
|
+
### 1.1.1 / 2017-03-18
|
8
|
+
|
9
|
+
* Make howtocall private
|
10
|
+
* Relax paint dependency (allow paint versions 2.x)
|
11
|
+
|
12
|
+
### 1.1.0 / 2015-03-26
|
13
|
+
|
14
|
+
* Added:
|
15
|
+
* howtocall
|
16
|
+
* Change output from `mof`, now only returns singleton methods per module for modules
|
17
|
+
* Make q compatible with paint ~> 1.0
|
18
|
+
* Drop support for Ruby 1
|
19
|
+
|
20
|
+
|
21
|
+
### 1.0.2 / 2015-01-24
|
22
|
+
|
23
|
+
* Bump binding.repl version
|
24
|
+
|
25
|
+
|
26
|
+
### 1.0.1 / 2014-02-15
|
27
|
+
|
28
|
+
* Bump binding.repl version
|
29
|
+
|
30
|
+
|
31
|
+
### 1.0.0 / 2014-01-19
|
32
|
+
|
33
|
+
* Adjusted concept: Only helper method style
|
34
|
+
* Removed:
|
35
|
+
* dd
|
36
|
+
* binding.vars
|
37
|
+
|
38
|
+
* Added:
|
39
|
+
* beep
|
40
|
+
* repl
|
41
|
+
|
42
|
+
* Renamed:
|
43
|
+
* oo -> at
|
44
|
+
* cc -> callstack
|
45
|
+
* mm -> mof
|
46
|
+
* regexp_visualize -> re
|
47
|
+
|
48
|
+
* Method List: Display all available ancestors by default and add third argument for grepping
|
49
|
+
* Moved from zucker 13.1 gem into its own gem
|
50
|
+
|
data/Gemfile
CHANGED
data/README.md
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
# Ruby Print Debugging [![version](https://badge.fury.io/rb/debugging.svg)](https://badge.fury.io/rb/debugging) [<img src="https://github.com/janlelis/debugging/workflows/Test/badge.svg" />](https://github.com/janlelis/debugging/actions?query=workflow%3ATest)
|
2
|
+
|
3
|
+
Helps you to introspect and debug your code.
|
4
|
+
|
5
|
+
|
6
|
+
## Setup
|
7
|
+
|
8
|
+
Install gem:
|
9
|
+
|
10
|
+
```
|
11
|
+
$ gem install debugging binding_of_caller
|
12
|
+
```
|
13
|
+
|
14
|
+
|
15
|
+
In Ruby:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
require 'debugging/all'
|
19
|
+
```
|
20
|
+
|
21
|
+
Instead of requiring all, you can also require only one function, e.g:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'debugging/q'
|
25
|
+
```
|
26
|
+
|
27
|
+
In a bundler project, you will need to add the gem to your project's `Gemfile`:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
gem 'debugging', require: 'debugging/all'
|
31
|
+
gem 'binding_of_caller'
|
32
|
+
```
|
33
|
+
|
34
|
+
## Methods
|
35
|
+
### at(label = nil)
|
36
|
+
|
37
|
+
Prints out that a specific point in a script has been reached.
|
38
|
+
|
39
|
+
```
|
40
|
+
[label] @ method `...', line ... of file ....
|
41
|
+
```
|
42
|
+
|
43
|
+
### beep
|
44
|
+
|
45
|
+
Lets your terminal bell ring.
|
46
|
+
|
47
|
+
### callstack
|
48
|
+
|
49
|
+
Prints out your current callstack. For example:
|
50
|
+
|
51
|
+
```
|
52
|
+
<main>
|
53
|
+
start
|
54
|
+
catch
|
55
|
+
block in start
|
56
|
+
eval_input
|
57
|
+
each_top_level_statement
|
58
|
+
catch
|
59
|
+
block in each_top_level_statement
|
60
|
+
loop
|
61
|
+
block (2 levels) in each_top_level_statement
|
62
|
+
block in eval_input
|
63
|
+
signal_status
|
64
|
+
block (2 levels) in eval_input
|
65
|
+
evaluate
|
66
|
+
evaluate
|
67
|
+
eval
|
68
|
+
irb_binding
|
69
|
+
```
|
70
|
+
|
71
|
+
### howtocall(obj = self, method_or_proc)
|
72
|
+
|
73
|
+
Displays parameter names and types for a proc or method (identified by a symbol):
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
def function(a, b = 3, &c)
|
77
|
+
end
|
78
|
+
howtocall :function #=> function(a, b, &c)
|
79
|
+
```
|
80
|
+
|
81
|
+
What is not visible in the example above: All optional parameters are displayed underlined.
|
82
|
+
|
83
|
+
If you want to access a function that is defined on an other object than the current one,
|
84
|
+
you can pass it as an optional parameter:
|
85
|
+
|
86
|
+
```ruby
|
87
|
+
howtocall FileUtils, :cd #=> cd(dir, options, &block)
|
88
|
+
howtocall Open3, :popen3 #=> popen3(*cmd, **opts, &block)
|
89
|
+
|
90
|
+
```
|
91
|
+
|
92
|
+
An example with lambdas and keyword arguments:
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
a = ->(filter: /\A.*\z/, string:){ string[filter] }
|
96
|
+
howtocall a #=> call(string:, filter:)
|
97
|
+
```
|
98
|
+
|
99
|
+
|
100
|
+
### mof(obj, depth = nil)
|
101
|
+
|
102
|
+
"Methods of": Prints out available methods, ordered by modules:
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
mof [1,2,3]
|
106
|
+
```
|
107
|
+
|
108
|
+
```
|
109
|
+
###
|
110
|
+
Eigenclass
|
111
|
+
|
112
|
+
Array
|
113
|
+
inspect to_s to_a to_h to_ary frozen? == eql? hash [] []= at fet
|
114
|
+
ch first last concat << push pop shift unshift insert each each_i
|
115
|
+
ndex reverse_each length size empty? find_index index rindex join r
|
116
|
+
everse reverse! rotate rotate! sort sort! sort_by! collect collect!
|
117
|
+
map map! select select! keep_if values_at delete delete_at delete_i
|
118
|
+
f reject reject! zip transpose replace clear fill include? <=> sli
|
119
|
+
ce slice! assoc rassoc + * - & | uniq uniq! compact compact! fl
|
120
|
+
atten flatten! count shuffle! shuffle sample cycle permutation combi
|
121
|
+
nation repeated_permutation repeated_combination product take take_whil
|
122
|
+
e drop drop_while bsearch pack
|
123
|
+
|
124
|
+
Enumerable
|
125
|
+
to_a entries to_h sort sort_by grep count find detect find_index f
|
126
|
+
ind_all select reject collect map flat_map collect_concat inject red
|
127
|
+
uce partition group_by first all? any? one? none? min max minmax
|
128
|
+
min_by max_by minmax_by member? include? each_with_index reverse_each
|
129
|
+
each_entry each_slice each_cons each_with_object zip take take_while
|
130
|
+
drop drop_while cycle chunk slice_before lazy
|
131
|
+
|
132
|
+
Object
|
133
|
+
|
134
|
+
Debugging
|
135
|
+
|
136
|
+
Kernel
|
137
|
+
nil? === =~ !~ eql? hash <=> class singleton_class clone dup tain
|
138
|
+
t tainted? untaint untrust untrusted? trust freeze frozen? to_s ins
|
139
|
+
pect methods singleton_methods protected_methods private_methods public
|
140
|
+
_methods instance_variables instance_variable_get instance_variable_set
|
141
|
+
instance_variable_defined? remove_instance_variable instance_of? kind_of?
|
142
|
+
is_a? tap send public_send respond_to? extend display method publi
|
143
|
+
c_method singleton_method define_singleton_method object_id to_enum enu
|
144
|
+
m_for
|
145
|
+
|
146
|
+
BasicObject
|
147
|
+
== equal? ! != instance_eval instance_exec __send__ __id__
|
148
|
+
```
|
149
|
+
|
150
|
+
### q(*args)
|
151
|
+
|
152
|
+
Like `Kernel#p`, but with colors on one line:
|
153
|
+
|
154
|
+
```ruby
|
155
|
+
q :is_like, ?p, "but on one line"
|
156
|
+
```
|
157
|
+
|
158
|
+
### re(string, regex, groups = nil)
|
159
|
+
|
160
|
+
Assists you when matching regexes againts strings. Try this one:
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
re "mail@janlelis.de", /\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,10})\b/i, 0..2
|
164
|
+
```
|
165
|
+
|
166
|
+
### repl
|
167
|
+
|
168
|
+
Starts your favorite IRB session from the current binding.
|
169
|
+
|
170
|
+
## J-_-L
|
171
|
+
|
172
|
+
Copyright (c) 2010-2020 Jan Lelis. MIT License. Originated from the
|
173
|
+
[zucker](https://github.com/janlelis/sugar_refinery) gem.
|
data/Rakefile
CHANGED
@@ -1,33 +1,37 @@
|
|
1
|
-
#
|
1
|
+
# # #
|
2
|
+
# Get gemspec info
|
3
|
+
|
4
|
+
gemspec_file = Dir['*.gemspec'].first
|
5
|
+
gemspec = eval File.read(gemspec_file), binding, gemspec_file
|
6
|
+
info = "#{gemspec.name} | #{gemspec.version} | " \
|
7
|
+
"#{gemspec.runtime_dependencies.size} dependencies | " \
|
8
|
+
"#{gemspec.files.size} files"
|
9
|
+
|
10
|
+
|
11
|
+
# # #
|
12
|
+
# Gem build and install task
|
13
|
+
|
14
|
+
desc info
|
15
|
+
task :gem do
|
16
|
+
puts info + "\n\n"
|
17
|
+
print " "; sh "gem build #{gemspec_file}"
|
18
|
+
FileUtils.mkdir_p 'pkg'
|
19
|
+
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
|
20
|
+
puts; sh %{gem install --no-document pkg/#{gemspec.name}-#{gemspec.version}.gem}
|
21
|
+
end
|
2
22
|
|
3
|
-
require 'rubygems'
|
4
23
|
|
5
|
-
|
6
|
-
|
7
|
-
rescue LoadError => e
|
8
|
-
warn e.message
|
9
|
-
warn "Run `gem install bundler` to install Bundler."
|
10
|
-
exit -1
|
11
|
-
end
|
24
|
+
# # #
|
25
|
+
# Start an IRB session with the gem loaded
|
12
26
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
warn e.message
|
17
|
-
warn "Run `bundle install` to install missing gems."
|
18
|
-
exit e.status_code
|
27
|
+
desc "#{gemspec.name} | IRB"
|
28
|
+
task :irb do
|
29
|
+
sh "irb -I ./lib -r #{gemspec.name.gsub '-','/'}"
|
19
30
|
end
|
20
31
|
|
21
|
-
require 'rake'
|
22
32
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
require 'rdoc/task'
|
27
|
-
RDoc::Task.new do |rdoc|
|
28
|
-
rdoc.title = "ruby_version"
|
29
|
-
end
|
30
|
-
task :doc => :rdoc
|
33
|
+
# # #
|
34
|
+
# Spec
|
31
35
|
|
32
36
|
require 'rspec/core/rake_task'
|
33
37
|
RSpec::Core::RakeTask.new
|
data/debugging.gemspec
CHANGED
@@ -5,24 +5,24 @@ require File.expand_path('../lib/debugging/version', __FILE__)
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "debugging"
|
7
7
|
gem.version = Debugging::VERSION
|
8
|
-
gem.summary = 'Print debugging helpers
|
9
|
-
gem.description = '
|
8
|
+
gem.summary = 'Print debugging helpers'
|
9
|
+
gem.description = 'Utilities for better "print debugging"'
|
10
10
|
gem.license = "MIT"
|
11
11
|
gem.authors = ["Jan Lelis"]
|
12
|
-
gem.email = "
|
12
|
+
gem.email = ["hi@ruby.consulting"]
|
13
13
|
gem.homepage = "https://github.com/janlelis/debugging"
|
14
14
|
|
15
|
-
gem.files = Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
|
15
|
+
gem.files = Dir['{**/}{.*,*}'].select { |path| File.file?(path) && path !~ /pkg/ }
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ['lib']
|
19
19
|
|
20
|
-
gem.
|
21
|
-
|
20
|
+
gem.required_ruby_version = '>= 2.0', '< 4.0'
|
21
|
+
|
22
|
+
gem.add_dependency 'paint', '>= 0.9', '< 3.0'
|
23
|
+
gem.add_dependency 'binding.repl', '~> 3.0'
|
22
24
|
|
23
|
-
gem.add_development_dependency 'bundler', '~> 1.0'
|
24
25
|
gem.add_development_dependency 'rake', '~> 10.1'
|
25
26
|
gem.add_development_dependency 'rdoc', '~> 3.0'
|
26
27
|
gem.add_development_dependency 'rspec', '~> 2.4'
|
27
|
-
gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
|
28
28
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'debugging'
|
2
|
+
|
3
|
+
module Debugging
|
4
|
+
private
|
5
|
+
|
6
|
+
def howtocall(object = self, method_or_proc)
|
7
|
+
if method_or_proc.is_a? Proc
|
8
|
+
params = method_or_proc.parameters
|
9
|
+
template = "call(%s)"
|
10
|
+
else
|
11
|
+
unless method_or_proc.is_a?(Method) || method_or_proc.is_a?(UnboundMethod)
|
12
|
+
method_or_proc = object.method(method_or_proc)
|
13
|
+
end
|
14
|
+
params = method_or_proc.parameters
|
15
|
+
template = "#{method_or_proc.name}(%s)"
|
16
|
+
end
|
17
|
+
|
18
|
+
sig = params.map{ |type, name|
|
19
|
+
param = ""
|
20
|
+
param << "*" if type == :rest
|
21
|
+
param << "**" if type == :keyrest
|
22
|
+
param << "&" if type == :block
|
23
|
+
name = ?? if !name && !(type == :rest || type == :keyrest)
|
24
|
+
if type == :opt || type == :key
|
25
|
+
param << Paint[name, :underline]
|
26
|
+
else
|
27
|
+
param << name.to_s
|
28
|
+
end
|
29
|
+
param << ":" if type == :key || type == :keyreq
|
30
|
+
param
|
31
|
+
}*", "
|
32
|
+
|
33
|
+
puts template %(sig)
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
end
|
data/lib/debugging/mof.rb
CHANGED
@@ -3,27 +3,28 @@ require 'debugging'
|
|
3
3
|
module Debugging
|
4
4
|
private
|
5
5
|
|
6
|
-
def mof(obj, depth = nil,
|
7
|
-
|
6
|
+
def mof(obj, depth = nil, grep = //)
|
7
|
+
grep = Regexp.new(grep)
|
8
8
|
puts Paint["###", :red, :bold]
|
9
9
|
|
10
|
-
eigen_methods = obj.singleton_methods.grep(grep_for)
|
11
|
-
if eigen_methods.empty?
|
12
|
-
puts Paint['Eigenclass', :yellow]
|
13
|
-
else
|
14
|
-
puts Paint['Eigenclass', :green, :underline], eigen_methods.map(&:to_s)*' '
|
15
|
-
end
|
16
|
-
puts
|
17
|
-
|
18
10
|
if obj.is_a? Module
|
19
|
-
klass, method_function = obj, :
|
11
|
+
klass, method_function = obj, :singleton_methods
|
12
|
+
depth += 1 if depth
|
20
13
|
else
|
21
14
|
klass, method_function = obj.class, :public_instance_methods
|
15
|
+
|
16
|
+
eigen_methods = obj.singleton_methods.grep(grep)
|
17
|
+
if eigen_methods.empty?
|
18
|
+
puts Paint['Eigenclass', :yellow]
|
19
|
+
else
|
20
|
+
puts Paint['Eigenclass', :green, :underline], eigen_methods.map(&:to_s)*' '
|
21
|
+
end
|
22
|
+
puts
|
22
23
|
end
|
23
24
|
|
24
25
|
(depth || klass.ancestors.size).times{ |level|
|
25
26
|
if cur = klass.ancestors[level]
|
26
|
-
level_methods = cur.send(method_function, false).grep(
|
27
|
+
level_methods = cur.send(method_function, false).grep(grep)
|
27
28
|
colors = level_methods.empty? ? [:yellow] : [:green, :underline]
|
28
29
|
puts Paint["#{cur}", *colors], level_methods.map(&:to_s)*' '
|
29
30
|
puts unless level_methods.empty?
|
data/lib/debugging/q.rb
CHANGED
data/lib/debugging/version.rb
CHANGED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'debugging/howtocall'
|
3
|
+
|
4
|
+
describe "howtocall" do
|
5
|
+
it "displays method parameters" do
|
6
|
+
def function(a, b)
|
7
|
+
end
|
8
|
+
|
9
|
+
expect( capture_stdout{ howtocall :function } ).to eq "function(a, b)\n"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "underlines optional parameters" do
|
13
|
+
def function(a, b = 3)
|
14
|
+
end
|
15
|
+
|
16
|
+
expect( capture_stdout{ howtocall :function } ).to eq "function(a, \e[4mb\e[0m)\n"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "shows block parameters" do
|
20
|
+
def function(a, &b)
|
21
|
+
end
|
22
|
+
|
23
|
+
expect( capture_stdout{ howtocall :function } ).to eq "function(a, &b)\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "optionally takes an object where the method shoud be looked for (if not self)" do
|
27
|
+
module Klass
|
28
|
+
def self.function(a,b)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
expect( capture_stdout{ howtocall Klass, :function } ).to eq "function(a, b)\n"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "appends : for keyword arguments" do
|
36
|
+
def function(a: 42, b: 43)
|
37
|
+
end
|
38
|
+
|
39
|
+
expect( capture_stdout{ howtocall :function } ).to eq "function(\e[4ma\e[0m:, \e[4mb\e[0m:)\n"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "shows *splats and keyword **splats" do
|
43
|
+
def function(*cmd, **opts)
|
44
|
+
end
|
45
|
+
|
46
|
+
expect( capture_stdout{ howtocall :function } ).to eq "function(*cmd, **opts)\n"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "shows ? for array deconstructor parameters" do
|
50
|
+
def function((a, b))
|
51
|
+
end
|
52
|
+
|
53
|
+
expect( capture_stdout{ howtocall :function } ).to eq "function(?)\n"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "also works for procs" do
|
57
|
+
lambda = ->(a, b){}
|
58
|
+
|
59
|
+
expect( capture_stdout{ howtocall lambda } ).to eq "call(a, b)\n"
|
60
|
+
end
|
61
|
+
|
62
|
+
if RUBY_ENGINE == "ruby" || RUBY_ENGINE == "jruby"
|
63
|
+
context "[native methods]" do
|
64
|
+
it "shows ? instead of parameter names for fixed amount of parameters" do
|
65
|
+
expect( capture_stdout{ howtocall :is_a? } ).to eq "is_a?(?)\n"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "shows * instead of parameters for variable amount of parameters" do
|
69
|
+
expect( capture_stdout{ howtocall :puts } ).to eq "puts(*)\n"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/spec/q_spec.rb
CHANGED
@@ -2,18 +2,20 @@ require 'spec_helper'
|
|
2
2
|
require 'debugging/q'
|
3
3
|
|
4
4
|
describe 'q' do
|
5
|
-
it
|
6
|
-
|
7
|
-
|
5
|
+
it "should output the same as p for a single arg" do
|
6
|
+
expect(
|
7
|
+
Paint.unpaint(capture_stdout{q /some object/})
|
8
|
+
).to eq capture_stdout{p /some object/}
|
8
9
|
end
|
9
10
|
|
10
11
|
it "should output the same as p but for multiple args one one line, values separated by two spaces" do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
expect(
|
13
|
+
Paint.unpaint(capture_stdout{
|
14
|
+
q 1, "1", 2..5, [], {:hallo => :du}, nil, true
|
15
|
+
}
|
16
|
+
).chop ).to eq capture_stdout{
|
15
17
|
p 1, "1", 2..5, [], {:hallo => :du}, nil, true
|
16
|
-
|
18
|
+
}.chop.gsub( "\n", ' ' )
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
metadata
CHANGED
@@ -1,63 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debugging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Lelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paint
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
19
|
+
version: '0.9'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
27
|
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
29
|
+
version: '0.9'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: binding.repl
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '0'
|
39
|
+
version: '3.0'
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: bundler
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
requirements:
|
51
|
-
- - "~>"
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '1.0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - "~>"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '1.0'
|
46
|
+
version: '3.0'
|
61
47
|
- !ruby/object:Gem::Dependency
|
62
48
|
name: rake
|
63
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,34 +86,22 @@ dependencies:
|
|
100
86
|
- - "~>"
|
101
87
|
- !ruby/object:Gem::Version
|
102
88
|
version: '2.4'
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
requirements:
|
107
|
-
- - "~>"
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0.2'
|
110
|
-
type: :development
|
111
|
-
prerelease: false
|
112
|
-
version_requirements: !ruby/object:Gem::Requirement
|
113
|
-
requirements:
|
114
|
-
- - "~>"
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
version: '0.2'
|
117
|
-
description: Provides useful print debugging helpers.
|
118
|
-
email: mail@janlelis.de
|
89
|
+
description: Utilities for better "print debugging"
|
90
|
+
email:
|
91
|
+
- hi@ruby.consulting
|
119
92
|
executables: []
|
120
93
|
extensions: []
|
121
94
|
extra_rdoc_files: []
|
122
95
|
files:
|
96
|
+
- ".editorconfig"
|
123
97
|
- ".gitignore"
|
124
98
|
- ".rspec"
|
125
|
-
-
|
126
|
-
- ChangeLog.
|
99
|
+
- CODE_OF_CONDUCT.md
|
100
|
+
- ChangeLog.md
|
127
101
|
- Gemfile
|
128
102
|
- Gemfile.lock
|
129
|
-
- LICENSE.txt
|
130
|
-
- README.
|
103
|
+
- MIT-LICENSE.txt
|
104
|
+
- README.md
|
131
105
|
- Rakefile
|
132
106
|
- debugging.gemspec
|
133
107
|
- lib/debugging.rb
|
@@ -135,11 +109,13 @@ files:
|
|
135
109
|
- lib/debugging/at.rb
|
136
110
|
- lib/debugging/beep.rb
|
137
111
|
- lib/debugging/callstack.rb
|
112
|
+
- lib/debugging/howtocall.rb
|
138
113
|
- lib/debugging/mof.rb
|
139
114
|
- lib/debugging/q.rb
|
140
115
|
- lib/debugging/re.rb
|
141
116
|
- lib/debugging/repl.rb
|
142
117
|
- lib/debugging/version.rb
|
118
|
+
- spec/howtocall_spec.rb
|
143
119
|
- spec/q_spec.rb
|
144
120
|
- spec/re_spec.rb
|
145
121
|
- spec/spec_helper.rb
|
@@ -155,19 +131,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
131
|
requirements:
|
156
132
|
- - ">="
|
157
133
|
- !ruby/object:Gem::Version
|
158
|
-
version: '0'
|
134
|
+
version: '2.0'
|
135
|
+
- - "<"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '4.0'
|
159
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
139
|
requirements:
|
161
140
|
- - ">="
|
162
141
|
- !ruby/object:Gem::Version
|
163
142
|
version: '0'
|
164
143
|
requirements: []
|
165
|
-
|
166
|
-
rubygems_version: 2.2.1
|
144
|
+
rubygems_version: 3.2.3
|
167
145
|
signing_key:
|
168
146
|
specification_version: 4
|
169
|
-
summary: Print debugging helpers
|
147
|
+
summary: Print debugging helpers
|
170
148
|
test_files:
|
149
|
+
- spec/howtocall_spec.rb
|
171
150
|
- spec/q_spec.rb
|
172
151
|
- spec/re_spec.rb
|
173
152
|
- spec/spec_helper.rb
|
data/.travis.yml
DELETED
data/ChangeLog.rdoc
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
=== 1.0.0 / 2014-01-19
|
2
|
-
|
3
|
-
* Adjusted concept: Only helper method style
|
4
|
-
* Removed:
|
5
|
-
* dd
|
6
|
-
* binding.vars
|
7
|
-
* Added:
|
8
|
-
* beep
|
9
|
-
* repl
|
10
|
-
* Renamed:
|
11
|
-
* oo -> at
|
12
|
-
* cc -> callstack
|
13
|
-
* mm -> mof
|
14
|
-
* regexp_visualize -> re
|
15
|
-
* Method List: Display all available ancestors by default and add third argument for grepping
|
16
|
-
* Moved from zucker 13.1 gem into its own gem
|
17
|
-
|
data/README.rdoc
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
= Ruby Print Debugging {<img src="https://travis-ci.org/janlelis/debugging.png" />}[https://travis-ci.org/janlelis/debugging]
|
2
|
-
|
3
|
-
|
4
|
-
== Setup
|
5
|
-
|
6
|
-
$ gem install debugging binding_of_caller
|
7
|
-
|
8
|
-
|
9
|
-
Or in your Gemfile:
|
10
|
-
|
11
|
-
gem 'debugging'
|
12
|
-
gem 'binding_of_caller'
|
13
|
-
|
14
|
-
|
15
|
-
In Ruby:
|
16
|
-
|
17
|
-
require 'debugging/all'
|
18
|
-
|
19
|
-
|
20
|
-
== Methods
|
21
|
-
|
22
|
-
=== at(label = nil)
|
23
|
-
|
24
|
-
[label] @ method `...', line ... of file ....
|
25
|
-
|
26
|
-
|
27
|
-
=== beep
|
28
|
-
|
29
|
-
Lets your terminal bell ring.
|
30
|
-
|
31
|
-
|
32
|
-
=== callstack
|
33
|
-
|
34
|
-
<main>
|
35
|
-
start
|
36
|
-
catch
|
37
|
-
block in start
|
38
|
-
eval_input
|
39
|
-
each_top_level_statement
|
40
|
-
catch
|
41
|
-
block in each_top_level_statement
|
42
|
-
loop
|
43
|
-
block (2 levels) in each_top_level_statement
|
44
|
-
block in eval_input
|
45
|
-
signal_status
|
46
|
-
block (2 levels) in eval_input
|
47
|
-
evaluate
|
48
|
-
evaluate
|
49
|
-
eval
|
50
|
-
irb_binding
|
51
|
-
|
52
|
-
|
53
|
-
=== mof(obj, depth = nil)
|
54
|
-
|
55
|
-
Methods of:
|
56
|
-
|
57
|
-
>> mof [1,2,3]
|
58
|
-
###
|
59
|
-
Eigenclass
|
60
|
-
|
61
|
-
Array
|
62
|
-
inspect to_s to_a to_h to_ary frozen? == eql? hash [] []= at fetch first last concat << push pop shift unshift insert each each_index reverse_each length size empty? find_index index rindex join reverse reverse! rotate rotate! sort sort! sort_by! collect collect! map map! select select! keep_if values_at delete delete_at delete_if reject reject! zip transpose replace clear fill include? <=> slice slice! assoc rassoc + * - & | uniq uniq! compact compact! flatten flatten! count shuffle! shuffle sample cycle permutation combination repeated_permutation repeated_combination product take take_while drop drop_while bsearch pack
|
63
|
-
|
64
|
-
Enumerable
|
65
|
-
to_a entries to_h sort sort_by grep count find detect find_index find_all select reject collect map flat_map collect_concat inject reduce partition group_by first all? any? one? none? min max minmax min_by max_by minmax_by member? include? each_with_index reverse_each each_entry each_slice each_cons each_with_object zip take take_while drop drop_while cycle chunk slice_before lazy
|
66
|
-
|
67
|
-
Object
|
68
|
-
|
69
|
-
Debugging
|
70
|
-
|
71
|
-
Kernel
|
72
|
-
nil? === =~ !~ eql? hash <=> class singleton_class clone dup taint tainted? untaint untrust untrusted? trust freeze frozen? to_s inspect methods singleton_methods protected_methods private_methods public_methods instance_variables instance_variable_get instance_variable_set instance_variable_defined? remove_instance_variable instance_of? kind_of? is_a? tap send public_send respond_to? extend display method public_method singleton_method define_singleton_method object_id to_enum enum_for
|
73
|
-
|
74
|
-
BasicObject
|
75
|
-
== equal? ! != instance_eval instance_exec __send__ __id__
|
76
|
-
|
77
|
-
|
78
|
-
=== q(*args)
|
79
|
-
|
80
|
-
q :is_like, ?p, "but on one line"
|
81
|
-
|
82
|
-
|
83
|
-
=== re(string, regex, groups = nil)
|
84
|
-
|
85
|
-
An utility to assist you matching regexes againts strings. Try this one:
|
86
|
-
|
87
|
-
>> re "mail@janlelis.de", /\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,10})\b/i, 0..2
|
88
|
-
|
89
|
-
|
90
|
-
=== repl
|
91
|
-
|
92
|
-
Starts your favorite IRB session.
|
93
|
-
|
94
|
-
|
95
|
-
== Also See
|
96
|
-
|
97
|
-
https://github.com/davejacobs/letters
|
98
|
-
|
99
|
-
|
100
|
-
== J-_-L
|
101
|
-
|
102
|
-
Copyright (c) 2010-2014 Jan Lelis. MIT License. Originated from the zucker gem.
|