every_day_irb 1.7.1 → 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
2
  SHA1:
3
- metadata.gz: cce92e8050e0eac9307235f880e754f34ec7d369
4
- data.tar.gz: a8386baa8d0ee0d625f99fc3a7dbe46228ebcc5c
3
+ metadata.gz: 244188d18a787358db20562d891644c53daf6dc6
4
+ data.tar.gz: 9aa78fd37e995acf0eee2452f9cd0261221fe1e9
5
5
  SHA512:
6
- metadata.gz: 45a8f01e367fab7d5dad96af24f05e3b0f8ec0635f1e0e59df5d35937458f268bc3f2f52205b2e9a207807438abf38e0d6cb9151e5616f64917eb892abf355d1
7
- data.tar.gz: 96566b71de8e0ab91fe3b1b556f80ff7d6da2ebb44c735f99c7d2db46616fdff68b85619fbc95289d703947fa08b2cfef6132d9cdcea661efeb8f9dadde1793c
6
+ metadata.gz: 95518798918ce370df0bae9e216b68c375094b4fea251728e0dd4307015e04143985648d01b8ad5fb46d1af3311d5fc18603a1bc89554706c4ae34ce0f205f9d
7
+ data.tar.gz: b4c9d2df4dbaa5d99938b9b39e0eec26501466b8f672ffa5f951c47b5fc2e46da14e9ca61232ccafa4e039fb8f47217bcefeeecde76df9fb1e6fdf840228e90f
@@ -0,0 +1,5 @@
1
+ 2.0.0
2
+ * Separate every_day_irb release cycle from irbtools release cycle
3
+ * Move cd enhancements into cd microgem on which every_day_irb depends
4
+ * You must extend EveryDayIrb explicitely, does not happen on require, anymore
5
+ * Add rr for require_relative
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2014 Jan Lelis
1
+ Copyright (c) 2010-2015 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
@@ -0,0 +1,195 @@
1
+ # Irbtools [![version](https://badge.fury.io/rb/irbtools.svg)](http://badge.fury.io/rb/irbtools)
2
+
3
+ _ _| | | |
4
+ | __| __ \ __| _ \ _ \ | __|
5
+ | | | | | ( | ( | | \__ \
6
+ ___| _| _.__/ \__| \___/ \___/ _| ____/
7
+
8
+
9
+ Improvements for Ruby's IRB console, like colored output and a lot of
10
+ debugging and introspection methods. Unlike with PRY, you are still in your
11
+ normal IRB. It is designed to work out-of-the-box, so there is no reason to not
12
+ use it!
13
+
14
+ ## Setup
15
+
16
+ $ gem install irbtools
17
+
18
+ IRB executes code in `~/.irbrc` on start-up. If the file does not exist, yet,
19
+ just create a new one. Add the following content:
20
+
21
+ require 'irbtools'
22
+
23
+ You also need to add irbtools to your project's Gemfile:
24
+
25
+ gem 'irbtools', require: 'irbtools/binding'
26
+
27
+ Then start IRB (with **Irbtools** loaded) from the console or directly from your code with:
28
+
29
+ binding.irb
30
+
31
+ If the `binding_of_caller` gem is available (e.g. see below), you can omit the `binding`:
32
+
33
+ irb
34
+
35
+ ### More Improvements
36
+
37
+ Some suggested gems will not be installed to ensure wider general support. For
38
+ the full feature set, you can add **irbtools-more** and change your
39
+ `.irbrc` to:
40
+
41
+ require 'irbtools/more'
42
+
43
+ and edit your Gemfile to
44
+
45
+ gem 'irbtools-more', require: 'irbtools/binding'
46
+
47
+
48
+ ### Included Gems and Libraries
49
+ #### IRB Improvements
50
+
51
+ * Colored output:
52
+ [wirb](https://github.com/janlelis/wirb/)
53
+ [fanycy_irb](https://github.com/janlelis/fancy_irb)
54
+ * Custom views for specific objects:
55
+ [hirb](http://tagaholic.me/2009/03/13/hirb-irb-on-the-good-stuff.html)
56
+ * **(irbtools-more)** Correction suggestions for misspelled method/constant names:
57
+ [did_you_mean](https://github.com/yuki24/did_you_mean)
58
+ * **(irbtools-more)** Better tab-completion:
59
+ [bond](http://tagaholic.me/bond/)
60
+
61
+ #### Utils
62
+
63
+ * Useful IRB commands (see below):
64
+ [every_day_irb](https://github.com/janlelis/irbtools/tree/master/lib/every
65
+ _day_irb.rb)
66
+ [debugging](https:/github.com/janlelis/debugging)
67
+ [fileutils](http://ruby-doc.org/stdlib-2.2.1/libdoc/fileutils/rdoc/FileUtils.html)
68
+ * Clipboard Access:
69
+ [clipboard](https://github.com/janlelis/clipboard)
70
+ * Terminal colors:
71
+ [paint](https://github.com/janlelis/paint)
72
+ * Load an editor into your IRB session:
73
+ [interactive_editor](https://github.com/jberkel/interactive_editor)
74
+
75
+ #### Introspection
76
+
77
+ * Displays a method's source:
78
+ [code](https://github.com/janlelis/code)
79
+ * Access to `ri` docs:
80
+ [ori](https://github.com/dadooda/ori)
81
+ * Manipulate instance variables with ease:
82
+ [instance](https://github.com/rubyworks/instance/)
83
+ * Platform information:
84
+ [ruby_version](https://github.com/janlelis/ruby_version)
85
+ [ruby_engine](https://github.com/janlelis/ruby_engine)
86
+ [os](https://github.com/rdp/os)
87
+ [ruby_info](https://github.com/janlelis/ruby_info)
88
+ * Improved method lookup path inspection:
89
+ [method_locator](https://github.com/ryanlecompte/method_locator)
90
+ * Finds methods that turn one value into another value:
91
+ [methodfinder](https://github.com/citizen428/methodfinder)
92
+ * **irbtools-more** Awesome lookup path inspection:
93
+ [looksee](https://github.com/oggy/looksee)
94
+
95
+
96
+ ### Irbtools Methods
97
+
98
+ Besides improving IRB itself, you will get the following methods:
99
+
100
+ Method | Arguments | Description
101
+ ------ | ---------- | -----------
102
+ `beep` | | Ring terminal bell.
103
+ `cat` | path | Read file contents.
104
+ `cd` | path = nil | Changes the directory. Can also be used in these forms: `~cd` (change to home directory), `-cd` (change to previous directory).
105
+ `clear` | | Clear the terminal.
106
+ `code` | object = self, method_name | Display the method source with syntax highlighting. Will also look up C methods if the **core_docs** gem is available.
107
+ `colorize` | string | Syntax highlight a Ruby string.
108
+ `copy` | string | Copy something to the clipboard.
109
+ `copy_input` | | Copy session history to the clipboard.
110
+ `copy_output` | | Copy session output history to the clipboard.
111
+ `ed` / `emacs` / `mate` / `mvim` / `nano` / `vi` / `vim` | filename = nil | Start an editor in the session context.
112
+ `engine` | | Show the Ruby engine.
113
+ `g` | *args | Like `Kernel#p`, but using terminal-notifier or growl.
114
+ `howtocall` | object = self, method_or_proc | Displays parameter names and types for a proc or method.
115
+ `info` | | List general information about the Ruby environment.
116
+ `ld` | file | Shortcut for `load lib.to_s + '.rb'`.
117
+ `ls` | path = "." | List directory content.
118
+ `mf` | object1, object2 | Find methods that turn one value into another value:w
119
+ `mof` | object, depth = 0, grep = // | Print a method list, ordered by modules.
120
+ `os` | | Query operating system information.
121
+ `pa` | string, color | Print a string in the specified color.
122
+ `page` | what, options = {} | Page long content.
123
+ `paste` | | Paste clipboard content.
124
+ `q` | *args | Like `Kernel#p`, but prints results on one line, with different colors.
125
+ `ray` | path | Syntax highlight a Ruby file.
126
+ `re` | string, regexg, groups = nil | Assists you when matching regexes againts strings.
127
+ `reset!` | | Restart the current IRB session.
128
+ `rq` | lib | Shortcut for `require lib.to_s`. Use it like this: `rq:prime`.
129
+ `rrq` / `rerequire` | lib | Hack to remove a library from `$LOADED_FEATURES` and `require` it again.
130
+ `session_history` | number_of_lines = nil | Return a string of all commands issued in the current session.
131
+ `version` | | Show the Ruby version.
132
+ `wp` | inspect_string | Syntax-highlight a Ruby object.
133
+ `Object#instance` | | Proxy object to read and manipulate instance variables / run eval.
134
+ `Object#lp` | | **irbtools-more** Supercharged method introspection in IRB
135
+ `Object#mlp` / `Object#method_lookup_path` | | Traverse an object's method lookup path to find all places where a method may be defined.
136
+ `Object#ri` | *args | Show ri documentation for this object or method.
137
+
138
+
139
+ ### Advanced tweaking
140
+
141
+ See [CONFIGURE.md](https://github.com/janlelis/irbtools/blob/master/CONFIGURE.md).
142
+
143
+
144
+ ### Troubleshooting: ANSI colors on Windows
145
+
146
+ Windows: ANSI support can be enabled via
147
+ [ansicon](https://github.com/adoxa/ansicon) or
148
+ [ConEmu](http://code.google.com/p/conemu-maximus5/).
149
+
150
+
151
+ ### Troubleshooting: Clipboard not working on Linux
152
+
153
+ Clipboard support requires **xclip** or **xsel**. On ubuntu, do: `sudo apt-get
154
+ install xclip`
155
+
156
+
157
+ ### Troubleshooting: Unicode causes wrong display widths
158
+
159
+ If you use double-width unicode characterss, you will need to paste the
160
+ following snippet to your `.irbrc` file.
161
+
162
+ Irbtools.replace_library_callback :fancy_irb do
163
+ FancyIrb.start east_asian_width: true
164
+ end
165
+
166
+ This setting is deactivated by default, because of performance issues.
167
+
168
+
169
+ ### Hint: Debundle
170
+
171
+ If you do not want to add **Irbtools** to your project's Gemfile, you will need a
172
+ [debundle hack](https://github.com/janlelis/debundle.rb). Put it at the
173
+ beginning of your `~/.irbrc` file and you are fine (until it breaks).
174
+
175
+
176
+ ### Hint: No ANSI / IRB extension
177
+
178
+ You can use Irbtools without colors/irb extensions. To do so, put this into `~/.irbrc`:
179
+
180
+ ```ruby
181
+ require 'irbtools/non_fancy'
182
+ Irbtools.start
183
+ ```
184
+
185
+
186
+ ### Hint: Web Console
187
+
188
+ **Irbtools** works well together with the amazing
189
+ [web-console!](https://github.com/rails/web-console)
190
+
191
+
192
+ ## J-_-L
193
+
194
+ Copyright (c) 2010-2015 Jan Lelis <http://janlelis.com> released under the MIT
195
+ license.
@@ -1,19 +1,28 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.dirname(__FILE__) + '/lib/irbtools/configure'
2
+ require File.dirname(__FILE__) + '/lib/every_day_irb/version'
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'every_day_irb'
6
- s.version = Irbtools::VERSION
6
+ s.version = EveryDayIrb::VERSION
7
7
 
8
+ s.homepage = 'http://github.com/janlelis/irbtools'
8
9
  s.authors = ["Jan Lelis"]
9
- s.summary = 'every_day_irb defines helper methods that simplify life in irb.'
10
- s.description = 'every_day_irb defines helper methods that simplify life in irb.: ls, cat, rq, rrq, ld, session_history, reset!, clear, ...'
10
+ s.summary = 'EveryDayIrb simplifies daily life in IRB.'
11
+ s.description = 'EveryDayIrb simplifies daily life in IRB with commands like: ls, cat, rq, rrq, ld, reset!, ...'
11
12
  s.email = 'mail@janlelis.de'
12
- s.extra_rdoc_files = %w[MIT-LICENSE README.rdoc]
13
- s.files = Dir.glob(%w[lib/every_day_irb.rb every_day_irb.gemspec])
14
- s.homepage = 'http://github.com/janlelis/irbtools'
15
- s.required_ruby_version = '>= 1.9.3'
13
+ s.files = %w[
14
+ lib/every_day_irb.rb
15
+ lib/every_day_irb/version.rb
16
+ spec/every_day_irb_spec.rb
17
+ every_day_irb.gemspec
18
+ ]
19
+ s.extra_rdoc_files = %w[
20
+ README.md
21
+ CHANGELOG-EVERYDAYIRB.txt
22
+ MIT-LICENSE.txt
23
+ ]
16
24
  s.license = 'MIT'
17
- s.add_development_dependency %q<rspec>
18
- s.add_development_dependency %q<rake>
25
+
26
+ s.required_ruby_version = '~> 2.0'
27
+ s.add_dependency 'cd', '~> 1.0'
19
28
  end
@@ -1,16 +1,20 @@
1
- # every_day_irb defines some helper methods that might be useful in every-day irb usage
1
+ require_relative 'every_day_irb/version'
2
2
 
3
- module EveryDayIrb
4
- VERSION = "1.7.1"
3
+ require 'cd'
5
4
 
5
+ module EveryDayIrb
6
6
  extend self
7
7
  private
8
8
 
9
9
  # shows the contents of your current directory (more such commands available by FileUtils)
10
- def ls(path='.')
11
- Dir[ File.join( path, '*' )].map{|filename| File.basename filename }
10
+ def ls(path = '.')
11
+ Cd.cd.ls(path)
12
+ end
13
+
14
+ # patch cd so that it also shows the current directory and got some extras
15
+ def cd(path = nil)
16
+ Cd.cd(path)
12
17
  end
13
- alias dir ls
14
18
 
15
19
  # read file contents (also see ray for ruby source files ;) )
16
20
  def cat(path)
@@ -22,6 +26,11 @@ module EveryDayIrb
22
26
  require lib.to_s
23
27
  end
24
28
 
29
+ # same for require relative
30
+ def rr(lib)
31
+ require_relative lib.to_s
32
+ end
33
+
25
34
  # load shortcut, not suited for non-rb
26
35
  def ld(lib)
27
36
  load lib.to_s + '.rb'
@@ -40,11 +49,16 @@ module EveryDayIrb
40
49
  end
41
50
  alias rrq rerequire
42
51
 
52
+ # just clear the screen
53
+ def clear
54
+ system 'clear'
55
+ end
56
+
43
57
  # restart irb
44
58
  def reset!
45
59
  # remember history...
46
- reset_irb = proc{ exec$0 }
47
- if defined?(Ripl) && Ripl.respond_to?(:started?) && Ripl.started?
60
+ reset_irb = proc{ exec $0 }
61
+ if defined?(Ripl) && Ripl.started?
48
62
  Ripl.shell.write_history if Ripl.shell.respond_to? :write_history
49
63
  reset_irb.call
50
64
  else
@@ -53,15 +67,10 @@ module EveryDayIrb
53
67
  end
54
68
  end
55
69
 
56
- # just clear the screen
57
- def clear
58
- system 'clear'
59
- end
60
-
61
- # returns the last lines, needed for some copy_ methods
70
+ # returns the last lines
62
71
  def session_history(number_of_lines = nil)
63
72
  if !number_of_lines
64
- if defined?(Ripl) && Ripl.respond_to?(:started?) && Ripl.started?
73
+ if defined?(Ripl) && Ripl.started?
65
74
  number_of_lines = Ripl.shell.line
66
75
  else
67
76
  number_of_lines = context.instance_variable_get(:@line_no)
@@ -71,6 +80,3 @@ module EveryDayIrb
71
80
  end
72
81
  end
73
82
 
74
- include EveryDayIrb
75
-
76
- # J-_-L
@@ -0,0 +1,3 @@
1
+ module EveryDayIrb
2
+ VERSION = "2.0.0".freeze
3
+ end
@@ -0,0 +1,126 @@
1
+ require_relative '../lib/every_day_irb'
2
+
3
+ require 'fileutils'
4
+
5
+ describe EveryDayIrb do
6
+ include EveryDayIrb
7
+
8
+ let(:filename){ __FILE__ }
9
+ let(:filename_without_rb){ filename.sub(/\.rb$/, '') }
10
+ let(:path){ File.dirname(filename) + '/..' }
11
+
12
+ describe '#ls' do
13
+ it 'returns an array' do
14
+ expect( ls ).to be_a Array
15
+ end
16
+
17
+ context '[no args]' do
18
+ it 'calls Dir["./*"] to get the list of all files in the current dir' do
19
+ res = Dir['./*']
20
+ expect( Dir ).to receive(:[]).with('./*').and_return(res)
21
+
22
+ ls
23
+ end
24
+ end
25
+
26
+ context 'one arg' do
27
+ it 'calls Dir["#{path}/*"] to get the list of all files of the given path' do
28
+ res = Dir["#{path}/*"]
29
+ expect( Dir ).to receive(:[]).with("#{path}/*").and_return(res)
30
+
31
+ ls(path)
32
+ end
33
+ end
34
+ end
35
+
36
+ describe "#cd" do
37
+ it 'returns an array' do
38
+ expect( ls ).to be_a Array
39
+ end
40
+
41
+ it 'requests FileUtils to change the directory' do
42
+ expect( FileUtils::Verbose ).to receive(:cd).with("/")
43
+
44
+ cd "/"
45
+ end
46
+ end
47
+
48
+ describe '#cat' do
49
+ it 'returns a String' do
50
+ expect( cat(filename) ).to be_a String
51
+ end
52
+
53
+ it 'calls File.read(path)' do
54
+ expect( File ).to receive(:read).with(filename)
55
+
56
+ cat(filename)
57
+ end
58
+ end
59
+
60
+ describe '#rq' do
61
+ it 'calls require with the arg' do
62
+ expect( self ).to receive(:require).with('rbconfig')
63
+
64
+ rq 'rbconfig'
65
+ end
66
+
67
+ it 'calls to_s on the arg' do
68
+ expect( self ).to receive(:require).with('rbconfig')
69
+
70
+ rq:rbconfig
71
+ end
72
+ end
73
+
74
+ describe '#rr' do
75
+ it 'calls require_re with the arg' do
76
+ expect( self ).to receive(:require_relative).with('something').and_return(nil)
77
+
78
+ rr 'something'
79
+ end
80
+
81
+ it 'calls to_s on the arg' do
82
+ expect( self ).to receive(:require_relative).with('something').and_return(nil)
83
+
84
+ rr:something
85
+ end
86
+ end
87
+
88
+ describe '#ld' do
89
+ it 'calls load with the arg, but appends ".rb"' do
90
+ expect( self ).to receive(:load).with(filename)
91
+
92
+ ld filename_without_rb
93
+ end
94
+
95
+ it 'calls to_s on the arg' do
96
+ expect( self ).to receive(:load).with(filename)
97
+
98
+ ld filename_without_rb.to_sym
99
+ end
100
+ end
101
+
102
+ describe '#rerequire' do
103
+ it 'requires a library a second time' do
104
+ first_time = require 'abbrev'
105
+ second_time = rerequire 'abbrev'
106
+
107
+ expect( second_time ).to be true
108
+ end
109
+ end
110
+
111
+ describe '#clear' do
112
+ it "calls the system's clear command" do
113
+ expect( self ).to receive(:system).with('clear')
114
+
115
+ clear
116
+ end
117
+ end
118
+
119
+ describe '#reset!' do
120
+ pending
121
+ end
122
+
123
+ describe '#session_history' do
124
+ pending
125
+ end
126
+ end
metadata CHANGED
@@ -1,56 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: every_day_irb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
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: 2015-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rspec
14
+ name: cd
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
19
+ version: '1.0'
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- description: 'every_day_irb defines helper methods that simplify life in irb.: ls,
42
- cat, rq, rrq, ld, session_history, reset!, clear, ...'
26
+ version: '1.0'
27
+ description: 'EveryDayIrb simplifies daily life in IRB with commands like: ls, cat,
28
+ rq, rrq, ld, reset!, ...'
43
29
  email: mail@janlelis.de
44
30
  executables: []
45
31
  extensions: []
46
32
  extra_rdoc_files:
47
- - MIT-LICENSE
48
- - README.rdoc
33
+ - README.md
34
+ - CHANGELOG-EVERYDAYIRB.txt
35
+ - MIT-LICENSE.txt
49
36
  files:
50
- - MIT-LICENSE
51
- - README.rdoc
37
+ - CHANGELOG-EVERYDAYIRB.txt
38
+ - MIT-LICENSE.txt
39
+ - README.md
52
40
  - every_day_irb.gemspec
53
41
  - lib/every_day_irb.rb
42
+ - lib/every_day_irb/version.rb
43
+ - spec/every_day_irb_spec.rb
54
44
  homepage: http://github.com/janlelis/irbtools
55
45
  licenses:
56
46
  - MIT
@@ -61,9 +51,9 @@ require_paths:
61
51
  - lib
62
52
  required_ruby_version: !ruby/object:Gem::Requirement
63
53
  requirements:
64
- - - ">="
54
+ - - "~>"
65
55
  - !ruby/object:Gem::Version
66
- version: 1.9.3
56
+ version: '2.0'
67
57
  required_rubygems_version: !ruby/object:Gem::Requirement
68
58
  requirements:
69
59
  - - ">="
@@ -71,8 +61,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
61
  version: '0'
72
62
  requirements: []
73
63
  rubyforge_project:
74
- rubygems_version: 2.4.5
64
+ rubygems_version: 2.4.6
75
65
  signing_key:
76
66
  specification_version: 4
77
- summary: every_day_irb defines helper methods that simplify life in irb.
67
+ summary: EveryDayIrb simplifies daily life in IRB.
78
68
  test_files: []
@@ -1,203 +0,0 @@
1
- = irbtools
2
-
3
- Improvements for Ruby's IRB console, for example, colored output, and a lot of debugging and introspection methods. Unlike with PRY, you are still in your normal IRB. It is designed to work out-of-the-box so there is no reason to not use it!
4
-
5
-
6
- == Setup
7
-
8
- $ gem install irbtools
9
-
10
-
11
- === Extra Requirements
12
-
13
- Linux: Clipboard support requires *xclip* or *xsel*: <tt>sudo apt-get install xclip</tt>
14
-
15
- Windows: ANSI colors can be enabled via ansicon[https://github.com/adoxa/ansicon]
16
-
17
- Mac OS: The g gem makes use of *growl*
18
-
19
-
20
- == Usage
21
-
22
- IRB executes code in <tt>~/.irbrc</tt> on start-up. If the file does not exist, yet, just create a new one. Add the following:
23
-
24
- require 'irbtools'
25
-
26
- See further below, if you want to customize which libraries should be loaded on IRB start-up.
27
-
28
-
29
- === With Bundler
30
-
31
- To integrate *irbtools* into a Rails console (or any project that uses bundler), add <tt>irbtools</tt> to your Gemfile:
32
-
33
- gem 'irbtools', require: 'binding.repl'
34
-
35
- Thanks to help from the {binding.repl gem}[https://github.com/rpag/binding.repl], you can start IRB (with *irbtools*) directly from your code:
36
-
37
- binding.repl!
38
-
39
-
40
- === Debundle
41
-
42
- Another way to activate *irbtools* in bundler projects is to add a {debundle hack}[https://github.com/janlelis/debundle.rb] at the beginning of your <tt>~/.irbrc</tt> file.
43
-
44
-
45
- === This is irbtools Light
46
-
47
- When installing *irbtools*, some gems will not be installed to ensure Windows OS support, for example, the bond gem for better auto-completion or the looksee gem for method/class introspection. These are packaged as {irbtools-more}[https://github.com/janlelis/irbtools-more]. To use <tt>irbtools-more</tt>, you will need to change your <tt>.irbrc</tt> to:
48
-
49
- require 'irbtools/more'
50
-
51
- and/or edit your Gemfile to
52
-
53
- gem 'irbtools-more', require: 'binding.repl'
54
-
55
-
56
- === Included Gems and Libraries
57
- ==== IRB Improvements
58
-
59
- * Colorization: wirb[https://github.com/janlelis/wirb/]
60
- * IRB tweaks: fancy_irb[https://github.com/janlelis/fancy_irb]
61
- * Custom views for specific objects: hirb[http://tagaholic.me/2009/03/13/hirb-irb-on-the-good-stuff.html]
62
- * <b>(irbtools-more)</b> Better IRB tab-completion: bond[http://tagaholic.me/bond/]
63
-
64
-
65
- ==== Helpful Methods
66
-
67
- * Useful IRB commands: every_day_irb[https://github.com/janlelis/irbtools/tree/master/lib/every_day_irb.rb]
68
- * Clipboard Access: clipboard[http://github.com/janlelis/clipboard]
69
- * Loads an editor into your IRB session: interactive_editor[https://github.com/jberkel/interactive_editor]
70
- * Print debugging helpers: debugging[https:/github.com/janlelis/debugging]
71
- * File-related system commands: *fileutils* (stdlib)
72
-
73
-
74
- ==== Platform Information
75
-
76
- * Query current Ruby version: ruby_version[https://github.com/janlelis/ruby_version]
77
- * Query current Ruby engine: ruby_engine[https://github.com/janlelis/ruby_engine]
78
- * Query current operating system: os[https://github.com/rdp/os]
79
- * Global information by the interpreter behind one <tt>Info</tt> constant: ruby_info[https://github.com/janlelis/ruby_info]
80
-
81
-
82
- ==== Introspection
83
-
84
- * Improved lookup path inspection: method_locator[https://github.com/ryanlecompte/method_locator]
85
- * Displays a method's source: method_source[https://github.com/banister/method_source]
86
- * Adds a +ri+ doc method to Object: [ori[https://github.com/dadooda/ori]
87
- * Finds the methods that turned a value into another value: methodfinder[https://github.com/citizen428/methodfinder]
88
- * Syntax highlighting: coderay[https://github.com/rubychan/coderay]
89
- * <b>irbtools-more</b> Awesome lookup path inspection: looksee[https://github.com/oggy/looksee]
90
- * <b>irbtools-more</b> Useful "did you mean?" suggestions in stack-traces: did_you_mean[https://github.com/yuki42/did_you_mean]
91
-
92
-
93
- ==== Code Organization
94
-
95
- * Command/task framework similar to rake and thor: boson[http://tagaholic.me/boson/]
96
- * Shortcuts for your favorite methods, saved in personal yaml file: alias[http://tagaholic.me/2009/07/07/alias-quickness-in-the-ruby-console.html]
97
-
98
-
99
- === Irbtools Methods
100
- ==== From every_day_irb
101
-
102
- [ls] Returns an array with the directory's content
103
- [cat] Shortcut for <tt>File.read</tt>
104
- [rq] Shortcut for <tt>require library.to_s</tt> (allows concise syntax like <tt>rq:mathn</tt>)
105
- [ld] Shortcut for <tt>load library.to_s + '.rb'</tt>
106
- [rrq/rerequire] Little hack for rerequiring a library (it's really hack and not reliable, but works in most cases)
107
- [reset!] Restarts IRB
108
- [clear] Clears the terminal (<tt>system "clear"</tt>)
109
- [session_history] Returns all issued commands as a string
110
-
111
-
112
- ==== From irbtools in conjunction with the libraries
113
-
114
- [cd] Improves the cd that is already provided by *fileutils* (try <tt>cd '-'</tt>)
115
- [version] Displays RubyVersion
116
- [engine] Displays RubyEngine
117
- [os] OS information
118
- [info] Aggregates information about your Ruby environment
119
- [copy] Shortcut for <tt>Clipboard.copy</tt>
120
- [paste] Shortcut for <tt>Clipboard.paste</tt>
121
- [copy_input] Copies the session_history to the clipboard
122
- [copy_output] Copies this session's results to the clipboard
123
- [mf] Shortcut for using the *methodfinder*
124
- [page] Shortcut for using the pager from *hirb*
125
- [colorize] Syntax highlights a ruby string using *coderay*
126
- [ray] Syntax highlights a ruby file using *coderay*
127
-
128
-
129
- ==== From the libraries (puplic Object methods, renamed/patched)
130
-
131
- [ri] Patching the +ri+ provided by *ori* to also allow default ri syntax on toplevel
132
- [src] Shortcut for displaying the method source using *method_source* and *coderay*
133
- [mlp] Shortcut for the *method_locator*
134
- [l/lp] Alternative method name to trigger the *looksee* gem (<b>irbtools-more</b>)
135
-
136
-
137
- == Advanced tweaking
138
- === Customize libraries to load
139
-
140
- It is possible to modify, which libraries to load:
141
-
142
- # Don't require 'irbtools', but:
143
- require 'irbtools/configure'
144
- # Here you can modify the libraries using the methods below
145
- Irbtools.start
146
-
147
- If you do not want to load the default set of *irbtools* gems, you will have to use <tt>require 'irbtools/minimal'</tt> instead of <tt>configure</tt>.
148
-
149
- You can use the following methods:
150
-
151
- * <tt>Irbtools.add_library(lib, options_hash, &block)</tt>
152
- * <tt>Irbtools.remove_library(lib)</tt>
153
-
154
- The <tt>options_hash</tt> defines the way in which *irbtools* loads the library. The following options are possible
155
- [(no options)/<tt>:start</tt>] The library is required on startup before doing anything else (before displaying the prompt)
156
- [<tt>:thread => identifier</tt>] After loading everything else, the library is required in a thread (while continuing loading). You can choose any identifier, but if you take the same one for multiple libraries, they will be loaded in the same thread (in the order that you define)
157
- [<tt>:late => true</tt>] The library is required just before showing the prompt (note: loading threads might still be in process)
158
- [<tt>:late_thread => identifier</tt>] Same as <tt>:thread</tt>, but after loading late libraries.
159
- [<tt>:sub_session => true</tt>] The library is loaded every time a sub-session starts (using <tt>IRB.conf[:IRB_RC]</tt>). In ripl[https://github.com/cldwalker/ripl], <tt>ripl-after_rc</tt> is used.
160
- [<tt>:autoload => :Constant</tt>] Use Ruby's <tt>autoload</tt> feature. It loads the library as soon as the constant is encountered.
161
-
162
- You can pass a block as third argument, which gets executed after the library has completed loading (except for <tt>:autoload</tt>, in which case the code will be executed directly on startup). You can modify the callbacks by using <tt>Irbtools.add_library_callback</tt> and <tt>Irbtools.replace_library_callback</tt>.
163
-
164
- When adding a new library, you should firstly consider some way to load it via <tt>:autoload</tt>.
165
- If this is not possible, try loading via <tt>:thread</tt>. If that is not possible either, you will need to fallback to the default loading mechanism.
166
-
167
-
168
- == Troubleshooting: Unicode causes wrong display widths?
169
-
170
- If you use double-width unicode characterss, you will need to paste the following snippet to your <tt>.irbrc</tt> file.
171
-
172
- Irbtools.replace_library_callback :fancy_irb do
173
- FancyIrb.start east_asian_width: true
174
- end
175
-
176
- This setting is deactivated by default, because of performance issues.
177
-
178
-
179
- == Hint: Faster start-up
180
-
181
- You can get an about a second faster start-up time by changing the loading methods for wirb and fancy_irb to <tt>:thread</tt> (drawback: the hash rocket will not be used for the first result):
182
-
183
- require 'irbtools/configure'
184
- Irbtools.remove_library :paint
185
- Irbtools.remove_library :fancy_irb
186
- Irbtools.add_library :paint, :late => true do Wirb.load_schema :classic_paint if defined? Wirb end
187
- Irbtools.add_library :fancy_irb, :thread => -1 do FancyIrb.start end
188
- Irbtools.start
189
-
190
-
191
- == Welcome Message
192
-
193
- The welcome message can be customized with <tt>Irbtools.welcome_message=</tt>
194
-
195
-
196
- == Web Console
197
-
198
- *irbtools* works well together with the amazing {web-console!}[https://github.com/rails/web-console]
199
-
200
-
201
- == J-_-L
202
-
203
- Copyright (c) 2010-2015 Jan Lelis <http://janlelis.com> released under the MIT license.