irbtools 3.0.5 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +11 -0
- data/.gitignore +2 -0
- data/CHANGELOG-MORE.md +78 -0
- data/CHANGELOG.md +27 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/CONFIGURE.md +1 -2
- data/Gemfile +7 -0
- data/Gemfile.lock +93 -0
- data/MIT-LICENSE.txt +1 -1
- data/README.md +189 -54
- data/Rakefile +0 -8
- data/irbtools.gemspec +13 -31
- data/lib/irbtools/binding.rb +4 -21
- data/lib/irbtools/commands/code.rb +35 -0
- data/lib/irbtools/commands/howtocall.rb +35 -0
- data/lib/irbtools/commands/look.rb +20 -0
- data/lib/irbtools/commands/shadow.rb +20 -0
- data/lib/irbtools/commands/sys.rb +25 -0
- data/lib/irbtools/commands.rb +5 -0
- data/lib/irbtools/configure.rb +1 -0
- data/lib/irbtools/implementation.rb +48 -37
- data/lib/irbtools/libraries.rb +14 -41
- data/lib/irbtools/version.rb +1 -1
- data/lib/irbtools.rb +6 -22
- data/spec/irbtools_commands_spec.rb +17 -0
- data/spec/irbtools_extra_methods_spec.rb +81 -0
- metadata +60 -57
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c962628e77711b94b8b2c4f1c9324d5b35c1f0b92419519fd6caa0509214219
|
4
|
+
data.tar.gz: d58171b0e82e5aba322a790c8ed9d51f96ce0606ddbfca60f44391719cfc07b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd488a948771e30dcab7dfc91c2e29fe223ac92976f4111c8e9154517107a92859b3d8f9da6713ec4c8439f453ec928031265053fbe761e37e749666a3b355fc
|
7
|
+
data.tar.gz: c5ee0a94b72e07441b774ba8fa795b61be1a116252736d7ec605ff3d9a6ea9b3092cc1839fa4eb340085bb0d09f2cc26f8ce4653355600fd130946da3108e646
|
data/.editorconfig
ADDED
data/.gitignore
ADDED
data/CHANGELOG-MORE.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Irbtools (More) Changelog
|
2
|
+
|
3
|
+
## 3.0 (final)
|
4
|
+
|
5
|
+
Retire irbtools-more:
|
6
|
+
|
7
|
+
* Move looksee to core irbtools
|
8
|
+
* Move core_docs to core irbtools
|
9
|
+
* Remove bond (outdated)
|
10
|
+
* Leave binding_of_caller optional
|
11
|
+
|
12
|
+
## 2.5.0
|
13
|
+
* Bump binding_of_caller & core_docs for Ruby 3.0
|
14
|
+
|
15
|
+
## 2.4.1
|
16
|
+
* Loosen Ruby dependency to allow Ruby 3.0
|
17
|
+
|
18
|
+
## 2.4.0
|
19
|
+
* Bump looksee & core_docs for Ruby 2.7
|
20
|
+
|
21
|
+
## 2.3.1
|
22
|
+
* Loosen irbrtools-more dependency to irbtools (allow 3.x)
|
23
|
+
|
24
|
+
## 2.3.0
|
25
|
+
* Remove dependency to did_you_mean, since it is now a default gem anyways
|
26
|
+
* Version bump: irbtools, looksee, core_docs, and binding_of_caller
|
27
|
+
|
28
|
+
## 2.2.1
|
29
|
+
* Add core_docs dependency
|
30
|
+
|
31
|
+
## 2.2.0
|
32
|
+
* Re-enable looksee (not comptible with Ruby 2.3, but does not crash anymore during install)
|
33
|
+
|
34
|
+
## 2.1.0
|
35
|
+
* Ruby 2.3 compat: Upgrade did_you_mean to ~> 1.0
|
36
|
+
* Ruby 2.3 compat: Disable looksee gem as long it is not adapted for 2.3
|
37
|
+
|
38
|
+
## 2.0.0
|
39
|
+
* Integrate more-repo into irbtools main repo
|
40
|
+
* Improve auto-completion
|
41
|
+
* Remove Object#l alias for looksee, use Object#lp
|
42
|
+
|
43
|
+
## 1.7.2
|
44
|
+
* Bump did_you_mean and looksee (Ruby 2.2 compat)
|
45
|
+
|
46
|
+
## 1.7.1
|
47
|
+
* Bump did_you_mean version
|
48
|
+
|
49
|
+
## 1.7.0
|
50
|
+
* Bump looksee
|
51
|
+
* Ruby 1.9.3 required
|
52
|
+
* Add did_you_mean gem
|
53
|
+
|
54
|
+
## 1.6.1
|
55
|
+
* Add binding_of_caller
|
56
|
+
* Alias looksee to Object#lp instead of Object#ls
|
57
|
+
|
58
|
+
## 1.6.0
|
59
|
+
* (nothing)
|
60
|
+
|
61
|
+
## 1.5.2
|
62
|
+
* Ruby 2.1 Compatibility / Update looksee gem
|
63
|
+
* Be less restrictive in gem dependencies
|
64
|
+
|
65
|
+
## 1.5.1
|
66
|
+
* (nothing)
|
67
|
+
|
68
|
+
## 1.5.0
|
69
|
+
* Ruby 2.0 Compatibility
|
70
|
+
* Drop 1.8 Support
|
71
|
+
* Drop DrX gem
|
72
|
+
|
73
|
+
## 1.2.0
|
74
|
+
* add looksee
|
75
|
+
|
76
|
+
## 0.3.2
|
77
|
+
* load in threads (irbtools 1.0)
|
78
|
+
* remove jeweler
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,32 @@
|
|
1
1
|
# Irbtools Changelog
|
2
2
|
|
3
|
+
## 4.0.1
|
4
|
+
|
5
|
+
* Bump ruby_engine gem
|
6
|
+
|
7
|
+
## 4.0.0
|
8
|
+
|
9
|
+
* Requires IRB 1.6 (Ruby 3.2 bundles IRB 1.6.2)
|
10
|
+
* Requires Ruby 3.0
|
11
|
+
|
12
|
+
* Remove a bunch of gems:
|
13
|
+
* Drop binding.repl gem since it was only needed for older Rubies
|
14
|
+
* Drop ori gem, since IRB now has `show_doc`
|
15
|
+
* Drop RubyInfo
|
16
|
+
|
17
|
+
* Retire irbtools-more:
|
18
|
+
* Move looksee to core irbtools
|
19
|
+
* Move core_docs to core irbtools
|
20
|
+
* Remove bond (outdated)
|
21
|
+
* Leave binding_of_caller optional
|
22
|
+
|
23
|
+
* Add command wrappers for code, howtocall, looksee, shadow
|
24
|
+
* Add `$` command to directly call system
|
25
|
+
|
26
|
+
* Version bumps: looksee, os, methodfinder, code, core_docs, debugging
|
27
|
+
* Alias IRB's ls to ils (fixes #53)
|
28
|
+
* Remove support for RIPL repl (outdated)
|
29
|
+
|
3
30
|
## 3.0.5
|
4
31
|
* Bump methodfinder dependency & update usage (fixes #52)
|
5
32
|
|
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 opensource@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/CONFIGURE.md
CHANGED
@@ -43,8 +43,7 @@ The following options are possible
|
|
43
43
|
: Same as `:thread`, but after loading late libraries.
|
44
44
|
`:sub_session => true`
|
45
45
|
: The library is loaded every time a sub-session starts (using
|
46
|
-
`IRB.conf[:IRB_RC]`).
|
47
|
-
`ripl-after_rc` is used.
|
46
|
+
`IRB.conf[:IRB_RC]`).
|
48
47
|
`:autoload => :Constant`
|
49
48
|
: Use Ruby's `autoload` feature. It loads the library as soon as the
|
50
49
|
constant is encountered.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
irbtools (4.0.0)
|
5
|
+
clipboard (~> 1.3)
|
6
|
+
code (>= 0.9.4, < 2.0)
|
7
|
+
coderay (~> 1.1)
|
8
|
+
core_docs (~> 0.9.9)
|
9
|
+
debugging (~> 2.1)
|
10
|
+
every_day_irb (~> 2.2)
|
11
|
+
fancy_irb (~> 1.2, >= 1.2.1)
|
12
|
+
hirb (~> 0.7, >= 0.7.3)
|
13
|
+
interactive_editor (~> 0.0, >= 0.0.10)
|
14
|
+
irb (~> 1.6.2)
|
15
|
+
looksee (~> 5.0)
|
16
|
+
methodfinder (~> 2.2, >= 2.2.5)
|
17
|
+
object_shadow (~> 1.1)
|
18
|
+
os (~> 1.1, >= 1.1.4)
|
19
|
+
paint (>= 0.9, < 3.0)
|
20
|
+
ruby_engine (~> 1.0)
|
21
|
+
ruby_version (~> 1.0)
|
22
|
+
wirb (~> 2.0, >= 2.2.1)
|
23
|
+
|
24
|
+
GEM
|
25
|
+
remote: https://rubygems.org/
|
26
|
+
specs:
|
27
|
+
cd (1.0.1)
|
28
|
+
clipboard (1.3.6)
|
29
|
+
code (0.9.4)
|
30
|
+
coderay (~> 1.1)
|
31
|
+
method_source (>= 0.9, < 2.0)
|
32
|
+
coderay (1.1.3)
|
33
|
+
core_docs (0.9.9)
|
34
|
+
yard (~> 0.9.11)
|
35
|
+
debugging (2.1.0)
|
36
|
+
paint (>= 0.9, < 3.0)
|
37
|
+
diff-lcs (1.5.0)
|
38
|
+
every_day_irb (2.2.0)
|
39
|
+
cd (~> 1.0)
|
40
|
+
fancy_irb (1.4.3)
|
41
|
+
paint (>= 0.9, < 3.0)
|
42
|
+
unicode-display_width (>= 1.1)
|
43
|
+
ffi (1.15.5)
|
44
|
+
hirb (0.7.3)
|
45
|
+
interactive_editor (0.0.11)
|
46
|
+
spoon (>= 0.0.1)
|
47
|
+
io-console (0.6.0)
|
48
|
+
irb (1.6.2)
|
49
|
+
reline (>= 0.3.0)
|
50
|
+
looksee (5.0.0)
|
51
|
+
method_source (1.0.0)
|
52
|
+
methodfinder (2.2.5)
|
53
|
+
object_shadow (1.1.1)
|
54
|
+
os (1.1.4)
|
55
|
+
paint (2.3.0)
|
56
|
+
rake (13.0.6)
|
57
|
+
reline (0.3.2)
|
58
|
+
io-console (~> 0.5)
|
59
|
+
rspec (3.12.0)
|
60
|
+
rspec-core (~> 3.12.0)
|
61
|
+
rspec-expectations (~> 3.12.0)
|
62
|
+
rspec-mocks (~> 3.12.0)
|
63
|
+
rspec-core (3.12.0)
|
64
|
+
rspec-support (~> 3.12.0)
|
65
|
+
rspec-expectations (3.12.1)
|
66
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
+
rspec-support (~> 3.12.0)
|
68
|
+
rspec-mocks (3.12.1)
|
69
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
70
|
+
rspec-support (~> 3.12.0)
|
71
|
+
rspec-support (3.12.0)
|
72
|
+
ruby_engine (1.0.1)
|
73
|
+
ruby_version (1.0.2)
|
74
|
+
spoon (0.0.6)
|
75
|
+
ffi
|
76
|
+
unicode-display_width (2.3.0)
|
77
|
+
webrick (1.7.0)
|
78
|
+
wirb (2.2.2)
|
79
|
+
paint (>= 0.9, < 3.0)
|
80
|
+
yard (0.9.28)
|
81
|
+
webrick (~> 1.7.0)
|
82
|
+
|
83
|
+
PLATFORMS
|
84
|
+
ruby
|
85
|
+
|
86
|
+
DEPENDENCIES
|
87
|
+
irb
|
88
|
+
irbtools!
|
89
|
+
rake
|
90
|
+
rspec
|
91
|
+
|
92
|
+
BUNDLED WITH
|
93
|
+
2.4.1
|
data/MIT-LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,19 +1,156 @@
|
|
1
1
|
# Irbtools [![[version]](https://badge.fury.io/rb/irbtools.svg)](https://badge.fury.io/rb/irbtools) [![[ci]](https://github.com/janlelis/irbtools/workflows/Test/badge.svg)](https://github.com/janlelis/irbtools/actions?query=workflow%3ATest)
|
2
2
|
|
3
|
+
## Irbtools 4.0 for IRB 1.6+
|
4
|
+
|
5
|
+
The current version of Irbtools requires [IRB 1.6+](https://github.com/ruby/irb) (which is the default for Ruby
|
6
|
+
from 3.2 on). Please use Irbtools 3 for earlier versions of IRB.
|
7
|
+
|
8
|
+
## Description
|
9
|
+
|
10
|
+
Improves Ruby's IRB with:
|
11
|
+
|
12
|
+
- a default configuration
|
13
|
+
- improved syntax highlighting of result objects
|
14
|
+
- helpful commands for debugging and introspection
|
15
|
+
|
16
|
+
## Examples
|
17
|
+
|
18
|
+
### Show lookup chain and method list grouped by visibility
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
>> shadow [1,2,3].reverse
|
22
|
+
=> # ObjectShadow of Object #85280
|
23
|
+
|
24
|
+
## Lookup Chain
|
25
|
+
|
26
|
+
[#<Class:#<Array:0x00007fccd9cfac30>>, Array, Enumerable, Object, "…"]
|
27
|
+
|
28
|
+
## 141 Public Methods (Non-Class/Object)
|
29
|
+
|
30
|
+
[:&, :*, :+, :-, :<<, :<=>, :==, :[], :[]=, :all?, :any?, :append, :assoc, :at, :bsearch, :bsearch_index, :chain,
|
31
|
+
:chunk, :chunk_while, :clear, :collect, :collect!, :collect_concat, :combination, :compact, :compact!, :concat,
|
32
|
+
:count, :cycle, :deconstruct, :delete, :delete_at, :delete_if, :detect, :difference, :dig, :drop, :drop_while,
|
33
|
+
:each, :each_cons, :each_entry, :each_index, :each_slice, :each_with_index, :each_with_object, :empty?, :entries,
|
34
|
+
:eql?, :fetch, :fill, :filter, :filter!, :filter_map, :find, :find_all, :find_index, :first, :flat_map, :flatten,
|
35
|
+
:flatten!, :grep, :grep_v, :group_by, :hash, :include?, :index, :inject, :insert, :inspect, :intersect?,
|
36
|
+
:intersection, :join, :keep_if, :last, :lazy, :length, :map, :map!, :max, :max_by, :member?, :min, :min_by,
|
37
|
+
:minmax, :minmax_by, :none?, :one?, :pack, :partition, :permutation, :pop, :prepend, :product, :push, :rassoc,
|
38
|
+
:reduce, :reject, :reject!, :repeated_combination, :repeated_permutation, :replace, :reverse, :reverse!,
|
39
|
+
:reverse_each, :rindex, :rotate, :rotate!, :sample, :select, :select!, :shelljoin, :shift, :shuffle, :shuffle!,
|
40
|
+
:size, :slice, :slice!, :slice_after, :slice_before, :slice_when, :sort, :sort!, :sort_by, :sort_by!, :sum,
|
41
|
+
:take, :take_while, :tally, :to_a, :to_ary, :to_h, :to_s, :to_set, :transpose, :union, :uniq, :uniq!, :unshift,
|
42
|
+
:values_at, :zip, :|]
|
43
|
+
|
44
|
+
## 2 Private Methods (Non-Class/Object)
|
45
|
+
|
46
|
+
[:initialize, :initialize_copy]
|
47
|
+
|
48
|
+
## Object Inspect
|
49
|
+
|
50
|
+
[3, 2, 1]
|
51
|
+
```
|
52
|
+
|
53
|
+
### Show a method list grouped by ancestors
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
>> look "str"
|
57
|
+
.
|
58
|
+
.
|
59
|
+
.
|
60
|
+
Comparable
|
61
|
+
< <= == > >= between? clamp
|
62
|
+
String
|
63
|
+
% crypt inspect squeeze!
|
64
|
+
* dedup intern start_with?
|
65
|
+
+ delete length strip
|
66
|
+
+@ delete! lines strip!
|
67
|
+
-@ delete_prefix ljust sub
|
68
|
+
<< delete_prefix! lstrip sub!
|
69
|
+
<=> delete_suffix lstrip! succ
|
70
|
+
.
|
71
|
+
.
|
72
|
+
.
|
73
|
+
```
|
74
|
+
|
75
|
+
### Show source code of a Ruby-based method
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
>> code SecureRandom.uuid
|
79
|
+
#
|
80
|
+
# /home/dan/.rvm/rubies/ruby-3.2.0/lib/ruby/3.2.0/random/formatter.rb:170
|
81
|
+
#
|
82
|
+
# Generate a random v4 UUID (Universally Unique IDentifier).
|
83
|
+
#
|
84
|
+
# require 'random/formatter'
|
85
|
+
#
|
86
|
+
# Random.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
|
87
|
+
# Random.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab"
|
88
|
+
# # or
|
89
|
+
# prng = Random.new
|
90
|
+
# prng.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b"
|
91
|
+
#
|
92
|
+
# The version 4 UUID is purely random (except the version).
|
93
|
+
# It doesn't contain meaningful information such as MAC addresses, timestamps, etc.
|
94
|
+
#
|
95
|
+
# The result contains 122 random bits (15.25 random bytes).
|
96
|
+
#
|
97
|
+
# See RFC4122[https://datatracker.ietf.org/doc/html/rfc4122] for details of UUID.
|
98
|
+
#
|
99
|
+
def uuid
|
100
|
+
ary = random_bytes(16).unpack("NnnnnN")
|
101
|
+
ary[2] = (ary[2] & 0x0fff) | 0x4000
|
102
|
+
ary[3] = (ary[3] & 0x3fff) | 0x8000
|
103
|
+
"%08x-%04x-%04x-%04x-%04x%08x" % ary
|
104
|
+
end
|
105
|
+
```
|
106
|
+
|
107
|
+
### Show source code of a natively implemented method
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
>> code Array#reverse
|
111
|
+
//
|
112
|
+
// https://github.com/ruby/ruby/blob/ruby_3_2/array.c#L3282
|
113
|
+
//
|
114
|
+
// Returns a new \Array with the elements of +self+ in reverse order:
|
115
|
+
//
|
116
|
+
// a = ['foo', 'bar', 'two']
|
117
|
+
// a1 = a.reverse
|
118
|
+
// a1 # => ["two", "bar", "foo"]
|
119
|
+
static VALUE
|
120
|
+
rb_ary_reverse_m(VALUE ary)
|
121
|
+
{
|
122
|
+
long len = RARRAY_LEN(ary);
|
123
|
+
VALUE dup = rb_ary_new2(len);
|
124
|
+
|
125
|
+
if (len > 0) {
|
126
|
+
const VALUE *p1 = RARRAY_CONST_PTR_TRANSIENT(ary);
|
127
|
+
VALUE *p2 = (VALUE *)RARRAY_CONST_PTR_TRANSIENT(dup) + len - 1;
|
128
|
+
do *p2-- = *p1++; while (--len > 0);
|
129
|
+
}
|
130
|
+
ARY_SET_LEN(dup, RARRAY_LEN(ary));
|
131
|
+
return dup;
|
132
|
+
}
|
133
|
+
```
|
134
|
+
|
135
|
+
### Find out method signatures (most useful for Ruby-based methods with keyword args)
|
136
|
+
|
3
137
|
```ruby
|
4
|
-
|
5
|
-
|
6
|
-
_| _| _| _| _| _|_|_|_| _|_| _|_| _| _|_|_| _| _| _|
|
7
|
-
_| _|_|_| _|_|_| _| _| _| _| _| _| _|_| _| _|_| _|
|
8
|
-
_| _| _| _| _| _| _| _| _| _| _| _|_| _| _| _|
|
9
|
-
_|_|_| _| _| _|_|_| _| _|_| _|_| _|_| _| _|_|_| _| _|_|_| _|
|
10
|
-
_| _|
|
138
|
+
>> howtocall require
|
139
|
+
require(path)
|
11
140
|
```
|
12
141
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
142
|
+
```ruby
|
143
|
+
>> require "rubygems/user_interaction"
|
144
|
+
>> ui = Gem::ConsoleUI.new
|
145
|
+
>> howtocall ui.choose_from_list
|
146
|
+
choose_from_list(question, list)
|
147
|
+
```
|
148
|
+
|
149
|
+
### Call system commands with `$`
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
>> $ git status # displays current git status
|
153
|
+
```
|
17
154
|
|
18
155
|
## Setup
|
19
156
|
|
@@ -28,55 +165,66 @@ You also need to add irbtools to your project's `Gemfile`:
|
|
28
165
|
|
29
166
|
gem 'irbtools', require: 'irbtools/binding'
|
30
167
|
|
31
|
-
Then start IRB (with **Irbtools** loaded) from the terminal or directly from
|
168
|
+
Then start IRB (with **Irbtools** loaded) from the terminal or directly from
|
169
|
+
your code with:
|
32
170
|
|
33
171
|
binding.irb
|
34
172
|
|
35
|
-
|
36
|
-
|
37
|
-
Some suggested gems will not be installed to ensure wider general support. For
|
38
|
-
the full feature set, you can install **irbtools-more**. To do so, change your
|
39
|
-
`.irbrc` to:
|
40
|
-
|
41
|
-
require 'irbtools/more'
|
173
|
+
*Optional:* If the **binding_of_caller** gem is available, you can just call the `irb`
|
174
|
+
method and it will start a session with the current binding:
|
42
175
|
|
43
|
-
|
44
|
-
|
45
|
-
gem 'irbtools-more', require: 'irbtools/binding'
|
176
|
+
irb
|
46
177
|
|
47
178
|
## Features
|
48
179
|
|
49
|
-
###
|
180
|
+
### General IRB Improvements
|
50
181
|
|
51
182
|
- Syntax highlighting ([wirb](https://github.com/janlelis/wirb/) / [fancy_irb](https://github.com/janlelis/fancy_irb))
|
52
|
-
- Loads included
|
53
|
-
- Customizable views for specfic options using [hirb](https://tagaholic.me/2009/03/13/hirb-irb-on-the-good-stuff.html)
|
54
|
-
- ActiveRecord results get displayed as a table
|
55
|
-
- **(irbtools-more)** [Improved tab-completion](https://tagaholic.me/bond/)
|
183
|
+
- Loads included libraries efficiently to reduce IRB start-up time
|
184
|
+
- Customizable views for specfic options using [hirb](https://tagaholic.me/2009/03/13/hirb-irb-on-the-good-stuff.html). By default, ActiveRecord results get displayed as a table.
|
56
185
|
|
57
|
-
###
|
186
|
+
### Included Debugging Methods for IRB
|
58
187
|
|
59
188
|
#### Highlights
|
60
189
|
|
61
190
|
- Lookup and manipulate instance variables / methods with ease using [object_shadow](https://github.com/janlelis/object_shadow/)
|
62
|
-
-
|
191
|
+
- Go even further with [looksee](https://github.com/oggy/looksee), the best lookup path inspection tool out there
|
63
192
|
- Display a method's source code using [code](https://github.com/janlelis/code)
|
64
|
-
- Inline access to *ri* docs by [ori](https://github.com/dadooda/ori)
|
65
|
-
- If you have deactivated *ri*, you can re-generate the docs with something like: `rvm docs generate-ri`
|
66
193
|
- Find methods that turn one value into another value with [methodfinder](https://github.com/citizen428/methodfinder)
|
67
194
|
- [Use VIM from inside IRB](https://github.com/jberkel/interactive_editor)
|
68
195
|
|
196
|
+
#### Extra Commands
|
197
|
+
|
198
|
+
Commands get treated specially by IRB and do not necessarily follow Ruby syntax.
|
199
|
+
|
200
|
+
Command | Alias | Description | Example
|
201
|
+
------ | ---------- | ---------|---
|
202
|
+
`code ` | - | Shows syntax-highlighted source code of a method | `code Array#reverse`
|
203
|
+
`howtocall ` | - | Shows the method signature | `howtocall String#gsub`
|
204
|
+
`look ` | - | Shows looksee method list | `look [1,2,3]`
|
205
|
+
`shadow ` | `+ ` | Shows object shadow method list | `shadow [1,2,3]`
|
206
|
+
`sys ` | `$ ` | Calls system shell | `$ top`
|
207
|
+
|
208
|
+
Two default commands have an additional alias:
|
209
|
+
|
210
|
+
Command | Alias | Description | Example
|
211
|
+
------ | ---------- | ---------|---
|
212
|
+
`show_doc` | `ri ` | Shows documentation | `ri String#gsub`
|
213
|
+
`chws` | `co ` | "change into an object" | `co [1,2,3]`
|
214
|
+
|
215
|
+
##### IRB's ls?
|
216
|
+
|
217
|
+
Please note that IRB's own **ls** command is aliased to `ils`, since `ls` already refers to a method listing all files in the current directory. If you haven't tried looksee (`look`) or object shadows (`shadow`) - give it a try ;)
|
218
|
+
|
69
219
|
#### Ruby Introspection
|
70
220
|
|
71
221
|
Method / Constant | Arguments | Description | Provided By
|
72
222
|
------ | ---------- | -----------|-
|
73
|
-
`
|
223
|
+
`Object#lp` or `Object#look` | | Supercharged method introspection in IRB | [looksee](https://github.com/oggy/looksee)
|
224
|
+
`Object#shadow` | | Manipulate instance variables and learn about callable methods | [object_shadow](https://github.com/janlelis/object_shadow/)
|
225
|
+
`code` | object = self, method_name | Display the method source with syntax highlighting. Will also try to look up C methods. | [code](https://github.com/janlelis/code)
|
74
226
|
`howtocall` | object = self, method_or_proc | Display parameter names and types you will need to call a method | [debugging/howtocall](https://github.com/janlelis/debugging#howtocallobj--self-method_or_proc)
|
75
227
|
`mf` | object1, object2 | Find methods which turn one value into another value | [methodfinder](https://github.com/citizen428/methodfinder)
|
76
|
-
`mof` | object, depth = 0, grep = // | Print a method list, ordered by modules (looksee lite) | [debugging](https://github.com/janlelis/debugging#mofobj-depth--nil)
|
77
|
-
`Object#lp` | | **(irbtools-more)** Supercharged method introspection in IRB | [looksee](https://github.com/oggy/looksee)
|
78
|
-
`Object#ri` | *args | Show ri documentation for this object or method | [ori](https://github.com/dadooda/ori)
|
79
|
-
`Object#shadow` | | Manipulate instance variables and learn about callable methods | [object_shadow](https://github.com/janlelis/object_shadow/)
|
80
228
|
|
81
229
|
#### Platform Info
|
82
230
|
|
@@ -85,14 +233,15 @@ Method / Constant | Arguments | Description | Provided By
|
|
85
233
|
`OS` | | Query operating system information | [os](https://github.com/rdp/os)
|
86
234
|
`RubyVersion` | | Show the Ruby version | [ruby_version](https://github.com/janlelis/ruby_version)
|
87
235
|
`RubyEngine` | | Show the Ruby engine | [ruby_engine](https://github.com/janlelis/ruby_engine)
|
88
|
-
`RubyInfo` | | List general information about the Ruby environment | [ruby_info](https://github.com/janlelis/ruby_info)
|
89
236
|
|
90
237
|
#### General Utils
|
91
238
|
|
92
239
|
Method / Constant | Arguments | Description | Provided By
|
93
240
|
------ | ---------- | -----------|-
|
94
241
|
`beep` | | Ring terminal bell | [debugging/beep](https://github.com/janlelis/debugging#beep)
|
242
|
+
`clear` | | Clear the terminal | [every_day_irb](https://github.com/janlelis/every_day_irb)
|
95
243
|
`copy` | string | Copy something to the clipboard | [clipboard](https://github.com/janlelis/clipboard)
|
244
|
+
`copy_output` | | Copy session output history to the clipboard | [clipboard](https://github.com/janlelis/clipboard), irbtools
|
96
245
|
`colorize` | string | Syntax-highlight a string of Ruby code | [coderay](https://github.com/rubychan/coderay), irbtools
|
97
246
|
`ed` / `emacs` / `mate` / `mvim` / `nano` / `vi` / `vim` | filename = nil | Start an editor in the session context | [interactive_editor](https://github.com/jberkel/interactive_editor)
|
98
247
|
`ld` | file | Shortcut for `load lib.to_s + '.rb'` | [every_day_irb](https://github.com/janlelis/every_day_irb)
|
@@ -101,21 +250,12 @@ Method / Constant | Arguments | Description | Provided By
|
|
101
250
|
`paste` | | Paste clipboard content | [clipboard](https://github.com/janlelis/clipboard)
|
102
251
|
`q` | *args | Like `Kernel#p`, but prints results on one line, with different colors | [debugging/q](https://github.com/janlelis/debugging#qargs)
|
103
252
|
`re` | string, regexg, groups = nil | Regex debugging helper | [debugging/re](https://github.com/janlelis/debugging#qargs)
|
253
|
+
`reset!` | | Restart the current IRB session | [every_day_irb](https://github.com/janlelis/every_day_irb)
|
104
254
|
`rq` | lib | Shortcut for `require lib.to_s`. Use it like this: `rq:prime` | [every_day_irb](https://github.com/janlelis/every_day_irb)
|
105
255
|
`rr` | lib | Shortcut for `require_relative lib.to_s` | [every_day_irb](https://github.com/janlelis/every_day_irb)
|
106
256
|
`rrq` / `rerequire` | lib | Hack to remove a library from `$LOADED_FEATURES` and `require` it again | [every_day_irb](https://github.com/janlelis/every_day_irb)
|
107
257
|
`wp` | inspect_string | Syntax-highlight a Ruby return value | [wirb](https://github.com/janlelis/wirb#kernelwp)
|
108
258
|
|
109
|
-
#### IRB Support
|
110
|
-
|
111
|
-
Method / Constant | Arguments | Description | Provided By
|
112
|
-
------ | ---------- | -----------|-
|
113
|
-
`clear` | | Clear the terminal | [every_day_irb](https://github.com/janlelis/every_day_irb)
|
114
|
-
`copy_input` | | Copy session history to the clipboard | [clipboard](https://github.com/janlelis/clipboard), irbtools
|
115
|
-
`copy_output` | | Copy session output history to the clipboard | [clipboard](https://github.com/janlelis/clipboard), irbtools
|
116
|
-
`reset!` | | Restart the current IRB session | [every_day_irb](https://github.com/janlelis/every_day_irb)
|
117
|
-
`session_history` | number_of_lines = nil | Return a string of all commands issued in the current session | [every_day_irb](https://github.com/janlelis/every_day_irb)
|
118
|
-
|
119
259
|
#### Files and Navigation
|
120
260
|
|
121
261
|
Method / Constant | Arguments | Description | Provided By
|
@@ -128,7 +268,7 @@ Method / Constant | Arguments | Description | Provided By
|
|
128
268
|
`chown_R` | user, group, path | Set file owner for directory | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html)
|
129
269
|
`cp` | source, destination | Copy file | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html)
|
130
270
|
`cp_r` | source, destination | Copy directory | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html)
|
131
|
-
`ls` | path = "." | List directory content | [
|
271
|
+
`ls` | path = "." | List directory content | [cd](https://github.com/janlelis/cd)
|
132
272
|
`ln` | target, link | Create symlink (`ln`) | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html)
|
133
273
|
`ln_s` | target, link | Create symlink (`ln -s`) | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html)
|
134
274
|
`ln_sf` | target, link | Create symlink (`ln -sf`) | [fileutils](https://ruby-doc.org/stdlib/libdoc/fileutils/rdoc/FileUtils.html)
|
@@ -173,12 +313,7 @@ You can use **Irbtools** without colors/IRB extensions. To do so, put this into
|
|
173
313
|
require 'irbtools/non_fancy'
|
174
314
|
Irbtools.start
|
175
315
|
```
|
176
|
-
|
177
|
-
### Hint: Web Console and Other Approaches
|
178
|
-
|
179
|
-
**Irbtools** works well together with the amazing [web-console!](https://github.com/rails/web-console), and also with the [ripl](https://github.com/cldwalker/ripl) IRB alternative.
|
180
|
-
|
181
316
|
## J-_-L
|
182
317
|
|
183
|
-
Copyright (c) 2010-
|
318
|
+
Copyright (c) 2010-2022 Jan Lelis <https://janlelis.com> released under the MIT
|
184
319
|
license.
|