Project

ruby_grep

0.0
No commit activity in last 3 years
No release in over 3 years
Implementing full functionality of the "grep" command in Unix/Linux system with Ruby. Specification goes to http://www.opengroup.org/onlinepubs/9699919799/utilities/grep.html.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 1.2.9
 Project Readme

ruby_grep¶ ↑

Module to search file(s) for lines that match a given pattern. It (will) implements full functionality of the “grep” command in Unix/Linux system with Ruby. Specification goes to www.opengroup.org/onlinepubs/9699919799/utilities/grep.html.

Note on Patches/Pull Requests¶ ↑

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history.(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Install¶ ↑

$ gem install ruby_grep

Examples¶ ↑

require 'ruby_grep'

# grep content in a file
file = File.open(file_path)
file.grep(/example/, {:recursive => false}) do |path, line|
  puts "#{path}: #{line}"
end

# grep content by recursively traversing a folder
File.grep(folder_path, 'example', {:recursive => true}).each do |match|
  puts "#{match.path}: #{match.line}" # match is a Struct object with path and line as attributes
end

Copyright © 2010 Jingwen Owen Ou. See LICENSE for details.