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 CHANGED
@@ -1,3 +1,5 @@
1
1
  pkg/*
2
2
  *.gem
3
3
  .bundle
4
+ .yardoc
5
+ doc
data/README.textile CHANGED
@@ -1,21 +1,21 @@
1
1
  h2. Description
2
2
 
3
- _YAIH_ is an acronym that stands for *Y*et *A*nother *I*RB *H*istory.
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 irb history.
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 irb history.
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 irb history.
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
@@ -1,3 +1,3 @@
1
1
  module Yaih
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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{a bash like history}
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.2
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-16 00:00:00 +01:00
13
+ date: 2011-03-19 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
17
- description: a bash like history
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: []