every_day_irb 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0
1
+ 1.4.0
@@ -6,11 +6,12 @@ Gem::Specification.new do |s|
6
6
  s.version = File.read('VERSION').chomp
7
7
 
8
8
  s.authors = ["Jan Lelis"]
9
- s.summary = 'every_day_irb defines some helper methods that simplify life in irb.'
10
- s.description = 'every_day_irb defines some helper methods that simplify life in irb.: ls, cat, rq, rrq, ld, session_history, reset!, clear'
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, ...'
11
11
  s.email = 'mail@janlelis.de'
12
12
  s.extra_rdoc_files = %w[LICENSE]
13
13
  s.files = Dir.glob(%w[lib/every_day_irb.rb VERSION every_day_irb.gemspec])
14
14
  s.homepage = 'http://github.com/janlelis/irbtools'
15
15
  s.required_ruby_version = '>= 1.8.7'
16
+ s.add_development_dependency %q<rspec>
16
17
  end
data/lib/every_day_irb.rb CHANGED
@@ -2,70 +2,73 @@
2
2
 
3
3
  module EveryDayIrb
4
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
5
+ extend self
12
6
 
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
19
- def rq(lib)
20
- require lib.to_s
21
- end
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
22
12
 
23
- # load shortcut, not suited for non-rb
24
- def ld(lib)
25
- load lib.to_s + '.rb'
26
- end
13
+ # read file contents (also see ray for ruby source files ;) )
14
+ def cat(path)
15
+ File.read path
16
+ end
27
17
 
28
- # rerequire, not suited for non-rb, please note: can have non-intended side effects in rare cases
29
- def rerequire(lib)
30
- $".dup.each{ |path|
31
- if path =~ %r</#{lib}\.rb$>
32
- $".delete path.to_s
33
- require path.to_s
34
- end
35
- }
36
- require lib.to_s
37
- true
38
- end
39
- alias rrq rerequire
18
+ # allows concise syntax like rq:mathn
19
+ def rq(lib)
20
+ require lib.to_s
21
+ end
40
22
 
41
- # restart irb
42
- def reset!
43
- # remember history...
44
- reset_irb = proc{ exec$0 }
45
- if defined?(Ripl) && Ripl.respond_to?(:started?) && Ripl.started?
46
- Ripl.shell.write_history if Ripl.shell.respond_to? :write_history
47
- reset_irb.call
48
- else
49
- at_exit(&reset_irb)
50
- exit
23
+ # load shortcut, not suited for non-rb
24
+ def ld(lib)
25
+ load lib.to_s + '.rb'
51
26
  end
52
- end
53
27
 
54
- # just clear the screen
55
- def clear
56
- system 'clear'
57
- end
28
+ # rerequire, not suited for non-rb, please note: can have non-intended side effects in rare cases
29
+ def rerequire(lib)
30
+ $".dup.each{ |path|
31
+ if path =~ %r</#{lib}\.rb$>
32
+ $".delete path.to_s
33
+ require path.to_s
34
+ end
35
+ }
36
+ require lib.to_s
37
+ true
38
+ end
39
+ alias rrq rerequire
58
40
 
59
- # returns the last lines, needed for some copy_ methods
60
- def session_history(number_of_lines = nil)
61
- if !number_of_lines
41
+ # restart irb
42
+ def reset!
43
+ # remember history...
44
+ reset_irb = proc{ exec$0 }
62
45
  if defined?(Ripl) && Ripl.respond_to?(:started?) && Ripl.started?
63
- number_of_lines = Ripl.shell.line
46
+ Ripl.shell.write_history if Ripl.shell.respond_to? :write_history
47
+ reset_irb.call
64
48
  else
65
- number_of_lines = context.instance_variable_get(:@line_no)
49
+ at_exit(&reset_irb)
50
+ exit
51
+ end
52
+ end
53
+
54
+ # just clear the screen
55
+ def clear
56
+ system 'clear'
57
+ end
58
+
59
+ # returns the last lines, needed for some copy_ methods
60
+ def session_history(number_of_lines = nil)
61
+ if !number_of_lines
62
+ if defined?(Ripl) && Ripl.respond_to?(:started?) && Ripl.started?
63
+ number_of_lines = Ripl.shell.line
64
+ else
65
+ number_of_lines = context.instance_variable_get(:@line_no)
66
+ end
66
67
  end
68
+ Readline::HISTORY.entries[-number_of_lines...-1]*"\n"
67
69
  end
68
- Readline::HISTORY.entries[-number_of_lines...-1]*"\n"
69
70
  end
70
71
 
72
+ include EveryDayIrb
73
+
71
74
  # J-_-L
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: every_day_irb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,10 +9,26 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-26 00:00:00.000000000 Z
13
- dependencies: []
14
- description: ! 'every_day_irb defines some helper methods that simplify life in irb.:
15
- ls, cat, rq, rrq, ld, session_history, reset!, clear'
12
+ date: 2012-12-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: ! 'every_day_irb defines helper methods that simplify life in irb.: ls,
31
+ cat, rq, rrq, ld, session_history, reset!, clear, ...'
16
32
  email: mail@janlelis.de
17
33
  executables: []
18
34
  extensions: []
@@ -43,9 +59,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
43
59
  version: '0'
44
60
  requirements: []
45
61
  rubyforge_project:
46
- rubygems_version: 1.8.23
62
+ rubygems_version: 1.8.24
47
63
  signing_key:
48
64
  specification_version: 3
49
- summary: every_day_irb defines some helper methods that simplify life in irb.
65
+ summary: every_day_irb defines helper methods that simplify life in irb.
50
66
  test_files: []
51
67
  has_rdoc: