The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
full text searching for ri content

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ryan Davis

Posts: 651
Nickname: zenspider
Registered: Oct, 2004

Ryan Davis is a ruby nerd.
full text searching for ri content Posted: Aug 15, 2006 6:16 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Ryan Davis.
Original Post: full text searching for ri content
Feed Title: Polishing Ruby
Feed URL: http://blog.zenspider.com/index.rdf
Feed Description: Musings on Ruby and the Ruby Community...
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Ryan Davis
Latest Posts From Polishing Ruby

Advertisement
Check it out. Quick and dirty searching of ri content:
#!/usr/local/bin/ruby -w

require 'find'
require 'yaml'

search = ARGV.shift

puts "Searching for #{search}"
puts

Dir.chdir '/usr/local/share/ri/1.8/system' do
  Find.find('.') do |path|
    next unless test ?f, path
    yaml = File.read path
    if yaml =~ /#{search}/io then
      full_name = $1 if yaml[/full_name: (.*)/]
      puts "** FOUND IN: #{full_name}"
      
      data = YAML.load yaml.gsub(/ \!.*/, '')
      desc = data['comment'].map { |x| x.values }.flatten.join("\n").gsub(/"/, "'").gsub(/</, "<").gsub(/>/, ">").gsub(/&/, "&")
      puts
      puts desc
      puts
    end
  end
end
Lets you do stuff like:
% ./risearch.rb duplicate
Searching for duplicate
[...]
** FOUND IN: Array#uniq!

Removes duplicate elements from self. Returns nil if no changes are made (that is, no duplicates are found).
   a = [ 'a', 'a', 'b', 'b', 'c' ]
   a.uniq!   #=> ['a', 'b', 'c']
   b = [ 'a', 'b', 'c' ]
   b.uniq!   #=> nil

** FOUND IN: Array#|

Set Union---Returns a new array by joining this array with other_array, removing duplicates.
   [ 'a', 'b', 'c' ] | [ 'c', 'd', 'a' ]
          #=> [ 'a', 'b', 'c', 'd' ]
[...]

Read: full text searching for ri content

Topic: Ruby On Rails and Transactions? (or no consistency) Previous Topic   Next Topic Topic: Autorequire is Basically Gone, Everyone

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use