Class: ManParser
- Inherits:
-
Object
- Object
- ManParser
- Defined in:
- lib/man_parser.rb
Class Method Summary collapse
Class Method Details
.available_commands ⇒ Object
2 3 4 |
# File 'lib/man_parser.rb', line 2 def self.available_commands `ls #{root}`.split("\n").map{|c| c.sub('.1.gz','')} end |
.parse(cmd) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/man_parser.rb', line 10 def self.parse(cmd) sections = sections(source(cmd)) return {} if not sections['OPTIONS'] and not sections['DESCRIPTION'] description, = (sections['OPTIONS']||sections['DESCRIPTION']) description = sections['DESCRIPTION'] if description.to_s.empty? = () {:description => description.map{|l|l.strip}.join(''), :options=>, :sections=>sections} end |
.source(cmd) ⇒ Object
6 7 8 |
# File 'lib/man_parser.rb', line 6 def self.source(cmd) `gzip -dc #{root}/#{cmd}.1.gz` end |