yaih 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.textile +5 -5
- data/lib/yaih/core.rb +4 -1
- data/lib/yaih/kernel.rb +11 -1
- data/lib/yaih/version.rb +1 -1
- data/yaih.gemspec +1 -1
- metadata +3 -3
data/README.textile
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
h2. Description
|
2
2
|
|
3
|
-
|
3
|
+
YAIH is an acronym that stands for Yet Another IRB History. It's a gem that
|
4
|
+
provides bash like methods for interfacing with IRB history.
|
4
5
|
|
5
6
|
h2. Features
|
6
7
|
|
7
8
|
The aim of this gem is providing a bash like history to IRB. If you require it in your irbrc you'll get the following methods:
|
8
9
|
|
9
10
|
* h
|
10
|
-
The h method prints the last _n_(10 as default) lines of your
|
11
|
+
The h method prints the last _n_(10 as default) lines of your IRB history.
|
11
12
|
* hgrep
|
12
|
-
It takes a string as only argument and greps your
|
13
|
+
It takes a string as only argument and greps your IRB history.
|
13
14
|
* h!
|
14
|
-
It takes a range of lines to execute from your
|
15
|
+
It takes a range of lines to execute from your IRB history.
|
15
16
|
|
16
17
|
h2. Roadmap
|
17
18
|
|
18
|
-
* document source code
|
19
19
|
* write some tests
|
20
20
|
* includes a proc to erase history duplicate lines
|
21
21
|
* make the gem configurable with some options like default printed lines number, history _decoration_ type, etc.
|
data/lib/yaih/core.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
1
|
module Yaih
|
2
|
-
module Core
|
2
|
+
module Core # This module contains methods for interefacing with IRB history
|
3
3
|
|
4
4
|
extend self
|
5
5
|
|
6
|
+
# Returns an array of IRB history entries
|
7
|
+
# bases of the given n.
|
6
8
|
def entries(n=Readline::HISTORY.size)
|
7
9
|
size=Readline::HISTORY.size
|
8
10
|
Readline::HISTORY.to_a[(size - n)..size-1]
|
9
11
|
end
|
10
12
|
|
13
|
+
# Returns an array of strings
|
11
14
|
def decorate(n)
|
12
15
|
size=Readline::HISTORY.size
|
13
16
|
((size - n)..size-1).zip(entries(n)).map {|e| e.join(" ")}
|
data/lib/yaih/kernel.rb
CHANGED
@@ -1,17 +1,27 @@
|
|
1
|
-
module Kernel
|
1
|
+
module Kernel # Adding methods to Kernel module makes possible to use them in irb.
|
2
2
|
|
3
|
+
# Prints the latest n lines from IRB
|
4
|
+
# history. It decorates each line with
|
5
|
+
# the correspondent command number.
|
6
|
+
# @return [Fixnum] number of printed lines.
|
3
7
|
def h(n=10)
|
4
8
|
entries = Yaih::Core.decorate(n)
|
5
9
|
puts entries
|
6
10
|
entries.size
|
7
11
|
end
|
8
12
|
|
13
|
+
# It greps history and prints matched lines.
|
14
|
+
# @return [Fixnum] number of printed lines.
|
15
|
+
# @todo Consider to highlight matched part.
|
9
16
|
def hgrep(word)
|
10
17
|
matched=Yaih::Core.decorate(Readline::HISTORY.size - 1).select {|h| h.match(word)}
|
11
18
|
puts matched
|
12
19
|
matched.size
|
13
20
|
end
|
14
21
|
|
22
|
+
# It takes the range of lines to execute,
|
23
|
+
# evals the lines and prints them.
|
24
|
+
# @return [nil]
|
15
25
|
def h!(start, stop=nil)
|
16
26
|
stop=start unless stop
|
17
27
|
lines = Yaih::Core.entries[start..stop]
|
data/lib/yaih/version.rb
CHANGED
data/yaih.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.email = ["lucapette@gmail.com"]
|
11
11
|
s.homepage = "https://github.com/lucapette/yaih"
|
12
12
|
s.summary = %q{Yet Another IRB History}
|
13
|
-
s.description = %q{
|
13
|
+
s.description = %q{Require it in your irbrc if you want to get bash like commands for history}
|
14
14
|
|
15
15
|
s.rubyforge_project = "yaih"
|
16
16
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: yaih
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- lucapette
|
@@ -10,11 +10,11 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-03-
|
13
|
+
date: 2011-03-19 00:00:00 +01:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
17
|
-
description:
|
17
|
+
description: Require it in your irbrc if you want to get bash like commands for history
|
18
18
|
email:
|
19
19
|
- lucapette@gmail.com
|
20
20
|
executables: []
|