yaih 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +29 -0
- data/lib/yaih.rb +1 -0
- data/lib/yaih/core.rb +17 -0
- data/lib/yaih/kernel.rb +6 -16
- data/lib/yaih/version.rb +1 -1
- metadata +5 -12
- data/README +0 -1
data/README.textile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
h2. Description
|
2
|
+
|
3
|
+
_YAIH_ is an acronym that stands for *Y*et *A*nother *I*RB *H*istory.
|
4
|
+
|
5
|
+
h2. Features
|
6
|
+
|
7
|
+
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
|
+
* h
|
10
|
+
The h method prints the last _n_(10 as default) lines of your irb history.
|
11
|
+
* hgrep
|
12
|
+
It takes a string as only argument and greps your irb history.
|
13
|
+
* h!
|
14
|
+
It takes a range of lines to execute from your irb history.
|
15
|
+
|
16
|
+
h2. Roadmap
|
17
|
+
|
18
|
+
* document source code
|
19
|
+
* write some tests
|
20
|
+
* includes a proc to erase history duplicate lines
|
21
|
+
* make the gem configurable with some options like default printed lines number, history _decoration_ type, etc.
|
22
|
+
|
23
|
+
h2. Copyright
|
24
|
+
|
25
|
+
This program is free software. It comes without any warranty,
|
26
|
+
to the extent permitted by applicable law. You can redistribute
|
27
|
+
it and/or modify it under the terms of the Do What The Fuck You
|
28
|
+
Want To Public License, Version 2, as published by Sam Hocevar.
|
29
|
+
See http://sam.zoy.org/wtfpl/COPYING for more details.
|
data/lib/yaih.rb
CHANGED
data/lib/yaih/core.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Yaih
|
2
|
+
module Core
|
3
|
+
|
4
|
+
extend self
|
5
|
+
|
6
|
+
def entries(n=Readline::HISTORY.size)
|
7
|
+
size=Readline::HISTORY.size
|
8
|
+
Readline::HISTORY.to_a[(size - n)..size-1]
|
9
|
+
end
|
10
|
+
|
11
|
+
def decorate(n)
|
12
|
+
size=Readline::HISTORY.size
|
13
|
+
((size - n)..size-1).zip(entries(n)).map {|e| e.join(" ")}
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/lib/yaih/kernel.rb
CHANGED
@@ -1,38 +1,28 @@
|
|
1
1
|
module Kernel
|
2
2
|
|
3
|
-
def history_a(n=Readline::HISTORY.size)
|
4
|
-
size=Readline::HISTORY.size
|
5
|
-
Readline::HISTORY.to_a[(size - n)..size-1]
|
6
|
-
end
|
7
|
-
|
8
|
-
def decorate_h(n)
|
9
|
-
size=Readline::HISTORY.size
|
10
|
-
((size - n)..size-1).zip(history_a(n)).map {|e| e.join(" ")}
|
11
|
-
end
|
12
|
-
|
13
3
|
def h(n=10)
|
14
|
-
entries =
|
4
|
+
entries = Yaih::Core.decorate(n)
|
15
5
|
puts entries
|
16
6
|
entries.size
|
17
7
|
end
|
18
8
|
|
19
9
|
def hgrep(word)
|
20
|
-
matched=
|
10
|
+
matched=Yaih::Core.decorate(Readline::HISTORY.size - 1).select {|h| h.match(word)}
|
21
11
|
puts matched
|
22
12
|
matched.size
|
23
13
|
end
|
24
14
|
|
25
15
|
def h!(start, stop=nil)
|
26
16
|
stop=start unless stop
|
27
|
-
|
28
|
-
|
17
|
+
lines = Yaih::Core.entries[start..stop]
|
18
|
+
lines.each_with_index { |e,i|
|
29
19
|
irb_context.evaluate(e,i)
|
30
20
|
}
|
31
21
|
Readline::HISTORY.pop
|
32
|
-
|
22
|
+
lines.each { |l|
|
33
23
|
Readline::HISTORY.push l
|
34
24
|
}
|
35
|
-
puts
|
25
|
+
puts lines
|
36
26
|
end
|
37
27
|
|
38
28
|
end
|
data/lib/yaih/version.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yaih
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 0.0.1
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.2
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- lucapette
|
@@ -30,9 +26,10 @@ extra_rdoc_files: []
|
|
30
26
|
files:
|
31
27
|
- .gitignore
|
32
28
|
- Gemfile
|
33
|
-
- README
|
29
|
+
- README.textile
|
34
30
|
- Rakefile
|
35
31
|
- lib/yaih.rb
|
32
|
+
- lib/yaih/core.rb
|
36
33
|
- lib/yaih/kernel.rb
|
37
34
|
- lib/yaih/version.rb
|
38
35
|
- yaih.gemspec
|
@@ -50,21 +47,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
47
|
requirements:
|
51
48
|
- - ">="
|
52
49
|
- !ruby/object:Gem::Version
|
53
|
-
segments:
|
54
|
-
- 0
|
55
50
|
version: "0"
|
56
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
52
|
none: false
|
58
53
|
requirements:
|
59
54
|
- - ">="
|
60
55
|
- !ruby/object:Gem::Version
|
61
|
-
segments:
|
62
|
-
- 0
|
63
56
|
version: "0"
|
64
57
|
requirements: []
|
65
58
|
|
66
59
|
rubyforge_project: yaih
|
67
|
-
rubygems_version: 1.
|
60
|
+
rubygems_version: 1.5.2
|
68
61
|
signing_key:
|
69
62
|
specification_version: 3
|
70
63
|
summary: Yet Another IRB History
|
data/README
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
I'm currently writing it
|