debugging 1.0.2 → 2.0.0

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
- SHA1:
3
- metadata.gz: feff53cb6187e3f47870749cf2e5985f0fa89573
4
- data.tar.gz: 65531fd65d4fac8d5682a0076c4ba0309e44e6a7
2
+ SHA256:
3
+ metadata.gz: 872be0c025197161f198fa80b00b9858ccd5c2a07fa9206614e167f3ece4127d
4
+ data.tar.gz: f3a4c854578c6a36be5919069a2448c2771e4d14e320a303194214d8a1c74d33
5
5
  SHA512:
6
- metadata.gz: 22efa00dd86f8ee7abba08cd6904e0aeed9a001c151b7903d1c0421900f5588a939a10d633eea83702f06685caad70256f0fa3701b9ea054c6dd4f9019a9e6c1
7
- data.tar.gz: e75d6c844255645dbe5f6a50ccfb91c2300fb517450a8ba403d37ec7758c24c44e15aa3f11e0660c235f1fcc8db72cef1a44ed541e138977ad4411b47ba35dfa
6
+ metadata.gz: 7d1401c88701c1ff2e1a6a55452dce12f707beaefca1c1391be0f2733d094d93a43810103ce1627bff6165688ef4ae56c05e7f0555b67d65e8c14610fad6cac4
7
+ data.tar.gz: d219975b0a6656d4c3ce8828037a183d6e92aad103fdd41aacd5130fbd17db730aca2f51629171c9e24db2eded92368085eaaa0cffb6dcd46ec05153af65ca7c
@@ -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,54 @@
1
+ ## ChangeLog
2
+
3
+ ### 2.0.0 / 2021-12-30
4
+
5
+ * Remove `debugging/repl`, since Ruby now has `binding.irb`
6
+
7
+ ### 1.1.2 / 2020-12-29
8
+
9
+ * Relax required Ruby version
10
+
11
+ ### 1.1.1 / 2017-03-18
12
+
13
+ * Make howtocall private
14
+ * Relax paint dependency (allow paint versions 2.x)
15
+
16
+ ### 1.1.0 / 2015-03-26
17
+
18
+ * Added:
19
+ * howtocall
20
+ * Change output from `mof`, now only returns singleton methods per module for modules
21
+ * Make q compatible with paint ~> 1.0
22
+ * Drop support for Ruby 1
23
+
24
+
25
+ ### 1.0.2 / 2015-01-24
26
+
27
+ * Bump binding.repl version
28
+
29
+
30
+ ### 1.0.1 / 2014-02-15
31
+
32
+ * Bump binding.repl version
33
+
34
+
35
+ ### 1.0.0 / 2014-01-19
36
+
37
+ * Adjusted concept: Only helper method style
38
+ * Removed:
39
+ * dd
40
+ * binding.vars
41
+
42
+ * Added:
43
+ * beep
44
+ * repl
45
+
46
+ * Renamed:
47
+ * oo -> at
48
+ * cc -> callstack
49
+ * mm -> mof
50
+ * regexp_visualize -> re
51
+
52
+ * Method List: Display all available ancestors by default and add third argument for grepping
53
+ * Moved from zucker 13.1 gem into its own gem
54
+
data/Gemfile CHANGED
@@ -1,11 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
-
5
- group :full_support do
6
- gem 'binding_of_caller'
7
- end
8
-
9
- platform :rbx do
10
- gem 'rubysl-singleton'
11
- end
data/Gemfile.lock CHANGED
@@ -1,43 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- debugging (1.0.2)
5
- binding.repl (~> 3)
6
- paint (~> 0, >= 0.8.7)
4
+ debugging (1.1.2)
5
+ paint (>= 0.9, < 3.0)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
- binding.repl (3.0.0)
12
- binding_of_caller (0.7.2)
13
- debug_inspector (>= 0.0.1)
14
- debug_inspector (0.0.2)
15
- diff-lcs (1.2.5)
16
- json (1.8.1)
17
- paint (0.9.0)
18
- rake (10.1.1)
19
- rdoc (3.12.2)
20
- json (~> 1.4)
21
- rspec (2.14.1)
22
- rspec-core (~> 2.14.0)
23
- rspec-expectations (~> 2.14.0)
24
- rspec-mocks (~> 2.14.0)
25
- rspec-core (2.14.7)
26
- rspec-expectations (2.14.4)
10
+ diff-lcs (1.4.4)
11
+ paint (2.2.1)
12
+ rake (13.0.6)
13
+ rspec (2.99.0)
14
+ rspec-core (~> 2.99.0)
15
+ rspec-expectations (~> 2.99.0)
16
+ rspec-mocks (~> 2.99.0)
17
+ rspec-core (2.99.2)
18
+ rspec-expectations (2.99.2)
27
19
  diff-lcs (>= 1.1.3, < 2.0)
28
- rspec-mocks (2.14.4)
29
- rubygems-tasks (0.2.4)
30
- rubysl-singleton (2.0.0)
20
+ rspec-mocks (2.99.4)
31
21
 
32
22
  PLATFORMS
33
23
  ruby
34
24
 
35
25
  DEPENDENCIES
36
- binding_of_caller
37
- bundler (~> 1.0)
38
26
  debugging!
39
- rake (~> 10.1)
40
- rdoc (~> 3.0)
41
- rspec (~> 2.4)
42
- rubygems-tasks (~> 0.2)
43
- rubysl-singleton
27
+ rake (~> 13.0)
28
+ rspec (~> 2.99)
29
+
30
+ BUNDLED WITH
31
+ 2.2.22
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Jan Lelis
1
+ Copyright (c) 2010-2021 Jan Lelis
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 ADDED
@@ -0,0 +1,168 @@
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
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
+ ```
32
+
33
+ ## Methods
34
+ ### at(label = nil)
35
+
36
+ Prints out that a specific point in a script has been reached.
37
+
38
+ ```
39
+ [label] @ method `...', line ... of file ....
40
+ ```
41
+
42
+ ### beep
43
+
44
+ Lets your terminal bell ring.
45
+
46
+ ### callstack
47
+
48
+ Prints out your current callstack. For example:
49
+
50
+ ```
51
+ <main>
52
+ start
53
+ catch
54
+ block in start
55
+ eval_input
56
+ each_top_level_statement
57
+ catch
58
+ block in each_top_level_statement
59
+ loop
60
+ block (2 levels) in each_top_level_statement
61
+ block in eval_input
62
+ signal_status
63
+ block (2 levels) in eval_input
64
+ evaluate
65
+ evaluate
66
+ eval
67
+ irb_binding
68
+ ```
69
+
70
+ ### howtocall(obj = self, method_or_proc)
71
+
72
+ Displays parameter names and types for a proc or method (identified by a symbol):
73
+
74
+ ```ruby
75
+ def function(a, b = 3, &c)
76
+ end
77
+ howtocall :function #=> function(a, b, &c)
78
+ ```
79
+
80
+ What is not visible in the example above: All optional parameters are displayed underlined.
81
+
82
+ If you want to access a function that is defined on an other object than the current one,
83
+ you can pass it as an optional parameter:
84
+
85
+ ```ruby
86
+ howtocall FileUtils, :cd #=> cd(dir, options, &block)
87
+ howtocall Open3, :popen3 #=> popen3(*cmd, **opts, &block)
88
+
89
+ ```
90
+
91
+ An example with lambdas and keyword arguments:
92
+
93
+ ```ruby
94
+ a = ->(filter: /\A.*\z/, string:){ string[filter] }
95
+ howtocall a #=> call(string:, filter:)
96
+ ```
97
+
98
+
99
+ ### mof(obj, depth = nil)
100
+
101
+ "Methods of": Prints out available methods, ordered by modules:
102
+
103
+ ```ruby
104
+ mof [1,2,3]
105
+ ```
106
+
107
+ ```
108
+ ###
109
+ Eigenclass
110
+
111
+ Array
112
+ inspect to_s to_a to_h to_ary frozen? == eql? hash [] []= at fet
113
+ ch first last concat << push pop shift unshift insert each each_i
114
+ ndex reverse_each length size empty? find_index index rindex join r
115
+ everse reverse! rotate rotate! sort sort! sort_by! collect collect!
116
+ map map! select select! keep_if values_at delete delete_at delete_i
117
+ f reject reject! zip transpose replace clear fill include? <=> sli
118
+ ce slice! assoc rassoc + * - & | uniq uniq! compact compact! fl
119
+ atten flatten! count shuffle! shuffle sample cycle permutation combi
120
+ nation repeated_permutation repeated_combination product take take_whil
121
+ e drop drop_while bsearch pack
122
+
123
+ Enumerable
124
+ to_a entries to_h sort sort_by grep count find detect find_index f
125
+ ind_all select reject collect map flat_map collect_concat inject red
126
+ uce partition group_by first all? any? one? none? min max minmax
127
+ min_by max_by minmax_by member? include? each_with_index reverse_each
128
+ each_entry each_slice each_cons each_with_object zip take take_while
129
+ drop drop_while cycle chunk slice_before lazy
130
+
131
+ Object
132
+
133
+ Debugging
134
+
135
+ Kernel
136
+ nil? === =~ !~ eql? hash <=> class singleton_class clone dup tain
137
+ t tainted? untaint untrust untrusted? trust freeze frozen? to_s ins
138
+ pect methods singleton_methods protected_methods private_methods public
139
+ _methods instance_variables instance_variable_get instance_variable_set
140
+ instance_variable_defined? remove_instance_variable instance_of? kind_of?
141
+ is_a? tap send public_send respond_to? extend display method publi
142
+ c_method singleton_method define_singleton_method object_id to_enum enu
143
+ m_for
144
+
145
+ BasicObject
146
+ == equal? ! != instance_eval instance_exec __send__ __id__
147
+ ```
148
+
149
+ ### q(*args)
150
+
151
+ Like `Kernel#p`, but with colors on one line:
152
+
153
+ ```ruby
154
+ q :is_like, ?p, "but on one line"
155
+ ```
156
+
157
+ ### re(string, regex, groups = nil)
158
+
159
+ Assists you when matching regexes againts strings. Try this one:
160
+
161
+ ```ruby
162
+ re "mail@janlelis.de", /\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,10})\b/i, 0..2
163
+ ```
164
+
165
+ ## J-_-L
166
+
167
+ Copyright (c) 2010-2021 Jan Lelis. MIT License. Originated from the
168
+ [zucker](https://github.com/janlelis/sugar_refinery) gem.
data/Rakefile CHANGED
@@ -1,36 +1,42 @@
1
- # encoding: utf-8
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
- begin
6
- require 'bundler'
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
- begin
14
- Bundler.setup(:development)
15
- rescue Bundler::BundlerError => e
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
- require 'rubygems/tasks'
24
- Gem::Tasks.new
33
+ # # #
34
+ # Spec
25
35
 
26
- require 'rdoc/task'
27
- RDoc::Task.new do |rdoc|
28
- rdoc.title = "ruby_version"
36
+ desc "#{gemspec.name} | Spec"
37
+ task :spec do
38
+ sh "rspec"
29
39
  end
30
- task :doc => :rdoc
31
-
32
- require 'rspec/core/rake_task'
33
- RSpec::Core::RakeTask.new
34
40
 
35
41
  task :test => :spec
36
42
  task :default => :spec
data/debugging.gemspec CHANGED
@@ -5,24 +5,23 @@ 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 = 'Provides useful print debugging helpers.'
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 = "mail@janlelis.de"
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
+ gem.metadata = { "rubygems_mfa_required" => "true" }
19
20
 
20
- gem.add_dependency 'paint', '~> 0', '>= 0.8.7'
21
- gem.add_dependency 'binding.repl', '~> 3'
21
+ gem.required_ruby_version = '>= 2.0', '< 4.0'
22
22
 
23
- gem.add_development_dependency 'bundler', '~> 1.0'
24
- gem.add_development_dependency 'rake', '~> 10.1'
25
- gem.add_development_dependency 'rdoc', '~> 3.0'
26
- gem.add_development_dependency 'rspec', '~> 2.4'
27
- gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
23
+ gem.add_dependency 'paint', '>= 0.9', '< 3.0'
24
+
25
+ gem.add_development_dependency 'rake', '~> 13.0'
26
+ gem.add_development_dependency 'rspec', '~> 2.99'
28
27
  end
data/lib/debugging/all.rb CHANGED
@@ -5,5 +5,4 @@
5
5
  mof
6
6
  q
7
7
  re
8
- repl
9
- ].each{ |m| require_relative(m) }
8
+ ].each{ |m| require_relative(m) }
@@ -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, grep_for = //)
7
- grep_for = Regexp.new(grep_for)
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, :public_methods
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(grep_for)
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
@@ -4,6 +4,6 @@ module Debugging
4
4
  private
5
5
 
6
6
  def q(*args)
7
- puts args.map{ |e| Paint[e.inspect, :random] }*' ' unless args.empty?
7
+ puts args.map{ |e| Paint[e.inspect, Paint.random] }*' ' unless args.empty?
8
8
  end
9
9
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Debugging
2
- VERSION = "1.0.2"
4
+ VERSION = "2.0.0"
3
5
  end
@@ -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 'should output the same as p for a single arg' do
6
- Paint.unpaint(capture_stdout{q /some object/}).should ==
7
- capture_stdout{p /some object/}
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
- Paint.unpaint(capture_stdout do
12
- q 1, "1", 2..5, [], {:hallo => :du}, nil, true
13
- end).chop.should ==
14
- capture_stdout do
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
- end.chop.gsub( "\n", ' ' )
18
+ }.chop.gsub( "\n", ' ' )
17
19
  end
18
20
  end
19
21
 
metadata CHANGED
@@ -1,121 +1,66 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debugging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Lelis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-24 00:00:00.000000000 Z
11
+ date: 2021-12-30 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
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 0.8.7
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
17
  - - ">="
31
18
  - !ruby/object:Gem::Version
32
- version: 0.8.7
33
- - !ruby/object:Gem::Dependency
34
- name: binding.repl
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
19
+ version: '0.9'
20
+ - - "<"
38
21
  - !ruby/object:Gem::Version
39
- version: '3'
22
+ version: '3.0'
40
23
  type: :runtime
41
24
  prerelease: false
42
25
  version_requirements: !ruby/object:Gem::Requirement
43
26
  requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '3'
47
- - !ruby/object:Gem::Dependency
48
- name: bundler
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
27
+ - - ">="
52
28
  - !ruby/object:Gem::Version
53
- version: '1.0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
29
+ version: '0.9'
30
+ - - "<"
59
31
  - !ruby/object:Gem::Version
60
- version: '1.0'
32
+ version: '3.0'
61
33
  - !ruby/object:Gem::Dependency
62
34
  name: rake
63
35
  requirement: !ruby/object:Gem::Requirement
64
36
  requirements:
65
37
  - - "~>"
66
38
  - !ruby/object:Gem::Version
67
- version: '10.1'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '10.1'
75
- - !ruby/object:Gem::Dependency
76
- name: rdoc
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '3.0'
39
+ version: '13.0'
82
40
  type: :development
83
41
  prerelease: false
84
42
  version_requirements: !ruby/object:Gem::Requirement
85
43
  requirements:
86
44
  - - "~>"
87
45
  - !ruby/object:Gem::Version
88
- version: '3.0'
46
+ version: '13.0'
89
47
  - !ruby/object:Gem::Dependency
90
48
  name: rspec
91
49
  requirement: !ruby/object:Gem::Requirement
92
50
  requirements:
93
51
  - - "~>"
94
52
  - !ruby/object:Gem::Version
95
- version: '2.4'
53
+ version: '2.99'
96
54
  type: :development
97
55
  prerelease: false
98
56
  version_requirements: !ruby/object:Gem::Requirement
99
57
  requirements:
100
58
  - - "~>"
101
59
  - !ruby/object:Gem::Version
102
- version: '2.4'
103
- - !ruby/object:Gem::Dependency
104
- name: rubygems-tasks
105
- requirement: !ruby/object:Gem::Requirement
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
60
+ version: '2.99'
61
+ description: Utilities for better "print debugging"
62
+ email:
63
+ - hi@ruby.consulting
119
64
  executables: []
120
65
  extensions: []
121
66
  extra_rdoc_files: []
@@ -123,12 +68,12 @@ files:
123
68
  - ".editorconfig"
124
69
  - ".gitignore"
125
70
  - ".rspec"
126
- - ".travis.yml"
127
- - ChangeLog.rdoc
71
+ - CODE_OF_CONDUCT.md
72
+ - ChangeLog.md
128
73
  - Gemfile
129
74
  - Gemfile.lock
130
- - LICENSE.txt
131
- - README.rdoc
75
+ - MIT-LICENSE.txt
76
+ - README.md
132
77
  - Rakefile
133
78
  - debugging.gemspec
134
79
  - lib/debugging.rb
@@ -136,20 +81,20 @@ files:
136
81
  - lib/debugging/at.rb
137
82
  - lib/debugging/beep.rb
138
83
  - lib/debugging/callstack.rb
84
+ - lib/debugging/howtocall.rb
139
85
  - lib/debugging/mof.rb
140
86
  - lib/debugging/q.rb
141
87
  - lib/debugging/re.rb
142
- - lib/debugging/repl.rb
143
88
  - lib/debugging/version.rb
144
- - pkg/debugging-1.0.0.gem
145
- - pkg/debugging-1.0.1.gem
89
+ - spec/howtocall_spec.rb
146
90
  - spec/q_spec.rb
147
91
  - spec/re_spec.rb
148
92
  - spec/spec_helper.rb
149
93
  homepage: https://github.com/janlelis/debugging
150
94
  licenses:
151
95
  - MIT
152
- metadata: {}
96
+ metadata:
97
+ rubygems_mfa_required: 'true'
153
98
  post_install_message:
154
99
  rdoc_options: []
155
100
  require_paths:
@@ -158,19 +103,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
103
  requirements:
159
104
  - - ">="
160
105
  - !ruby/object:Gem::Version
161
- version: '0'
106
+ version: '2.0'
107
+ - - "<"
108
+ - !ruby/object:Gem::Version
109
+ version: '4.0'
162
110
  required_rubygems_version: !ruby/object:Gem::Requirement
163
111
  requirements:
164
112
  - - ">="
165
113
  - !ruby/object:Gem::Version
166
114
  version: '0'
167
115
  requirements: []
168
- rubyforge_project:
169
- rubygems_version: 2.4.5
116
+ rubygems_version: 3.3.3
170
117
  signing_key:
171
118
  specification_version: 4
172
- summary: Print debugging helpers.
119
+ summary: Print debugging helpers
173
120
  test_files:
121
+ - spec/howtocall_spec.rb
174
122
  - spec/q_spec.rb
175
123
  - spec/re_spec.rb
176
124
  - spec/spec_helper.rb
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: ruby
2
-
3
- rvm:
4
- - ruby-head
5
- - 2.2.0
6
- - 2.1.0
7
- - 2.0.0
8
- - 1.9.3
9
- - jruby
10
- - jruby-19mode
11
- - rbx
12
-
13
- bundler_args: --without full_support
data/ChangeLog.rdoc DELETED
@@ -1,27 +0,0 @@
1
- === 1.0.2 / 2015-01-24
2
-
3
- * Bump binding.repl version
4
-
5
-
6
- === 1.0.1 / 2014-02-15
7
-
8
- * Bump binding.repl version
9
-
10
-
11
- === 1.0.0 / 2014-01-19
12
-
13
- * Adjusted concept: Only helper method style
14
- * Removed:
15
- * dd
16
- * binding.vars
17
- * Added:
18
- * beep
19
- * repl
20
- * Renamed:
21
- * oo -> at
22
- * cc -> callstack
23
- * mm -> mof
24
- * regexp_visualize -> re
25
- * Method List: Display all available ancestors by default and add third argument for grepping
26
- * Moved from zucker 13.1 gem into its own gem
27
-
data/README.rdoc DELETED
@@ -1,123 +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', require: 'debugging/all'
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 fet
63
- ch first last concat << push pop shift unshift insert each each_i
64
- ndex reverse_each length size empty? find_index index rindex join r
65
- everse reverse! rotate rotate! sort sort! sort_by! collect collect!
66
- map map! select select! keep_if values_at delete delete_at delete_i
67
- f reject reject! zip transpose replace clear fill include? <=> sli
68
- ce slice! assoc rassoc + * - & | uniq uniq! compact compact! fl
69
- atten flatten! count shuffle! shuffle sample cycle permutation combi
70
- nation repeated_permutation repeated_combination product take take_whil
71
- e drop drop_while bsearch pack
72
-
73
- Enumerable
74
- to_a entries to_h sort sort_by grep count find detect find_index f
75
- ind_all select reject collect map flat_map collect_concat inject red
76
- uce partition group_by first all? any? one? none? min max minmax
77
- min_by max_by minmax_by member? include? each_with_index reverse_each
78
- each_entry each_slice each_cons each_with_object zip take take_while
79
- drop drop_while cycle chunk slice_before lazy
80
-
81
- Object
82
-
83
- Debugging
84
-
85
- Kernel
86
- nil? === =~ !~ eql? hash <=> class singleton_class clone dup tain
87
- t tainted? untaint untrust untrusted? trust freeze frozen? to_s ins
88
- pect methods singleton_methods protected_methods private_methods public
89
- _methods instance_variables instance_variable_get instance_variable_set
90
- instance_variable_defined? remove_instance_variable instance_of? kind_of?
91
- is_a? tap send public_send respond_to? extend display method publi
92
- c_method singleton_method define_singleton_method object_id to_enum enu
93
- m_for
94
-
95
- BasicObject
96
- == equal? ! != instance_eval instance_exec __send__ __id__
97
-
98
-
99
- === q(*args)
100
-
101
- q :is_like, ?p, "but on one line"
102
-
103
-
104
- === re(string, regex, groups = nil)
105
-
106
- Assists you when matching regexes againts strings. Try this one:
107
-
108
- re "mail@janlelis.de", /\b([A-Z0-9._%+-]+)@([A-Z0-9.-]+\.[A-Z]{2,10})\b/i, 0..2
109
-
110
-
111
- === repl
112
-
113
- Starts your favorite IRB session.
114
-
115
-
116
- == Also See
117
-
118
- https://github.com/davejacobs/letters
119
-
120
-
121
- == J-_-L
122
-
123
- Copyright (c) 2010-2015 Jan Lelis. MIT License. Originated from the {zucker}[http://rubyzucker.info] gem.
@@ -1,16 +0,0 @@
1
- require 'debugging'
2
- require 'binding.repl'
3
-
4
- begin
5
- require 'binding_of_caller'
6
- rescue LoadError
7
- warn 'Using Debugging#repl requires the "binding_of_caller" gem. Please install it or add it to your Gemfile!'
8
- end
9
-
10
- module Debugging
11
- private
12
-
13
- def repl
14
- binding.of_caller(1).repl.auto
15
- end
16
- end
Binary file
Binary file