every_day_irb 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/VERSION +1 -0
- data/every_day_irb.gemspec +16 -0
- data/lib/every_day_irb.rb +81 -0
- metadata +57 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010-2011 Jan Lelis
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'rubygems' unless defined? Gem
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'every_day_irb'
|
6
|
+
s.version = File.read('VERSION').chomp
|
7
|
+
|
8
|
+
s.authors = ["Jan Lelis"]
|
9
|
+
s.summary = 'every_day_irb defines some helper methods that might be useful in irb.'
|
10
|
+
s.description = 'every_day_irb defines some helper methods that might be useful in every-day irb usage, e.g.: ls, cat, rq, rrq, ld, session_history, reset!, clear, dbg'
|
11
|
+
s.email = 'mail@janlelis.de'
|
12
|
+
s.extra_rdoc_files = %w[LICENSE]
|
13
|
+
s.files = Dir.glob(%w[lib/every_day_irb.rb VERSION every_day_irb.gemspec])
|
14
|
+
s.homepage = 'http://github.com/janlelis/irbtools'
|
15
|
+
s.required_ruby_version = '>= 1.8.7'
|
16
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# every_day_irb defines some helper methods that might be useful in every-day irb usage
|
2
|
+
|
3
|
+
module EveryDayIrb
|
4
|
+
VERSION = File.read( File.dirname(__FILE__) + '/../VERSION' ).chomp
|
5
|
+
end
|
6
|
+
|
7
|
+
# shows the contents of your current directory (more such commands available by FileUtils)
|
8
|
+
def ls(path='.')
|
9
|
+
Dir[ File.join( path, '*' )].map{|filename| File.basename filename }
|
10
|
+
end
|
11
|
+
alias dir ls
|
12
|
+
|
13
|
+
# read file contents (also see ray for ruby source files ;) )
|
14
|
+
def cat(path)
|
15
|
+
File.read path
|
16
|
+
end
|
17
|
+
|
18
|
+
# allows concise syntax like rq:mathn and reloading/requiring
|
19
|
+
def rq(lib)
|
20
|
+
require lib.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
# rerequire, not suited for non-rb, please note: can have non-intended side effects in rare cases
|
24
|
+
def rerequire(lib)
|
25
|
+
$".dup.each{ |path|
|
26
|
+
if path =~ %r</#{lib}\.rb$>
|
27
|
+
$".delete path.to_s
|
28
|
+
require path.to_s
|
29
|
+
end
|
30
|
+
}
|
31
|
+
require lib.to_s
|
32
|
+
true
|
33
|
+
end
|
34
|
+
alias rrq rerequire
|
35
|
+
|
36
|
+
# load shortcut, not suited for non-rb
|
37
|
+
def ld(lib)
|
38
|
+
load lib.to_s + '.rb'
|
39
|
+
end
|
40
|
+
|
41
|
+
# returns the last lines, needed for some copy_ methods
|
42
|
+
def session_history(number_of_lines = nil)
|
43
|
+
if !number_of_lines
|
44
|
+
if defined?(Ripl) && Ripl.respond_to?(:started?) && Ripl.started?
|
45
|
+
number_of_lines = Ripl.shell.line
|
46
|
+
else
|
47
|
+
number_of_lines = context.instance_variable_get(:@line_no)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
Readline::HISTORY.entries[-number_of_lines...-1]*"\n"
|
51
|
+
end
|
52
|
+
|
53
|
+
# restart irb
|
54
|
+
def reset!
|
55
|
+
# remember history...
|
56
|
+
reset_irb = proc{ exec$0 }
|
57
|
+
if defined?(Ripl) && Ripl.respond_to?(:started?) && Ripl.started?
|
58
|
+
Ripl.shell.write_history if Ripl.shell.respond_to? :write_history
|
59
|
+
reset_irb.call
|
60
|
+
else
|
61
|
+
at_exit(&reset_irb)
|
62
|
+
exit
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# just clear the screen
|
67
|
+
def clear
|
68
|
+
system 'clear'
|
69
|
+
end
|
70
|
+
|
71
|
+
# load debugger, inspired by rdp
|
72
|
+
def dbg
|
73
|
+
begin
|
74
|
+
require 'ruby-debug'
|
75
|
+
debugger
|
76
|
+
rescue LoadError => err
|
77
|
+
throw "Sorry, unable to load ruby-debug gem for debugger: #{err}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# J-_-L
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: every_day_irb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jan Lelis
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-05-18 00:00:00 Z
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: "every_day_irb defines some helper methods that might be useful in every-day irb usage, e.g.: ls, cat, rq, rrq, ld, session_history, reset!, clear, dbg"
|
17
|
+
email: mail@janlelis.de
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
files:
|
25
|
+
- lib/every_day_irb.rb
|
26
|
+
- VERSION
|
27
|
+
- every_day_irb.gemspec
|
28
|
+
- LICENSE
|
29
|
+
homepage: http://github.com/janlelis/irbtools
|
30
|
+
licenses: []
|
31
|
+
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.8.7
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0"
|
49
|
+
requirements: []
|
50
|
+
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.8.1
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: every_day_irb defines some helper methods that might be useful in irb.
|
56
|
+
test_files: []
|
57
|
+
|