man_parser 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +1 -1
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/lib/man_parser.rb +2 -1
- data/man_parser.gemspec +7 -6
- data/spec/man_parser_spec.rb +9 -1
- metadata +3 -3
data/README.markdown
CHANGED
data/Rakefile
CHANGED
@@ -15,7 +15,8 @@ begin
|
|
15
15
|
gem.homepage = "http://github.com/grosser/#{project_name}"
|
16
16
|
gem.authors = ["Michael Grosser"]
|
17
17
|
end
|
18
|
+
|
18
19
|
Jeweler::GemcutterTasks.new
|
19
20
|
rescue LoadError
|
20
21
|
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
21
|
-
end
|
22
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/man_parser.rb
CHANGED
@@ -9,6 +9,7 @@ class ManParser
|
|
9
9
|
|
10
10
|
def self.parse(cmd)
|
11
11
|
sections = sections(source(cmd))
|
12
|
+
return {} if not sections['OPTIONS'] and not sections['DESCRIPTION']
|
12
13
|
description, options = find_options(sections['OPTIONS']||sections['DESCRIPTION'])
|
13
14
|
description = sections['DESCRIPTION'] if description.to_s.empty?
|
14
15
|
options = parse_options(options)
|
@@ -95,7 +96,7 @@ class ManParser
|
|
95
96
|
temp = []
|
96
97
|
|
97
98
|
lines.each do |line|
|
98
|
-
if line =~ /^\.
|
99
|
+
if line =~ /^\.S[hH] (.*)$/
|
99
100
|
sections[name] = temp * "\n"
|
100
101
|
temp = []
|
101
102
|
name = $1.gsub('"','').strip
|
data/man_parser.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{man_parser}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Michael Grosser"]
|
12
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-11-22}
|
13
13
|
s.email = %q{grosser.michael@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.markdown"
|
@@ -30,8 +30,8 @@ Gem::Specification.new do |s|
|
|
30
30
|
s.rubygems_version = %q{1.3.5}
|
31
31
|
s.summary = %q{Parse unix man pages into ruby-readable format}
|
32
32
|
s.test_files = [
|
33
|
-
"spec/
|
34
|
-
"spec/
|
33
|
+
"spec/spec_helper.rb",
|
34
|
+
"spec/man_parser_spec.rb"
|
35
35
|
]
|
36
36
|
|
37
37
|
if s.respond_to? :specification_version then
|
@@ -44,3 +44,4 @@ Gem::Specification.new do |s|
|
|
44
44
|
else
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
data/spec/man_parser_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec/spec_helper'
|
|
2
2
|
|
3
3
|
describe ManParser do
|
4
4
|
describe :parse do
|
5
|
-
it "
|
5
|
+
it "clens the description" do
|
6
6
|
d = ManParser.parse('ls')[:description]
|
7
7
|
d.should =~ /^\.\\\" Add any additional description here\.PPList infor/
|
8
8
|
d.should =~ /problems, 2 if serious trouble\.$/
|
@@ -11,6 +11,14 @@ describe ManParser do
|
|
11
11
|
d.should_not include(" ")
|
12
12
|
end
|
13
13
|
|
14
|
+
it "returns an empty hash for unknown commands" do
|
15
|
+
ManParser.parse('xxxx').should == {}
|
16
|
+
end
|
17
|
+
|
18
|
+
it "also parse .Sh section heads" do
|
19
|
+
ManParser.parse('acpi_fakekey')[:description].should_not be_empty
|
20
|
+
end
|
21
|
+
|
14
22
|
describe 'options in description' do
|
15
23
|
def options
|
16
24
|
ManParser.parse('ls')[:options]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: man_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-22 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -59,5 +59,5 @@ signing_key:
|
|
59
59
|
specification_version: 3
|
60
60
|
summary: Parse unix man pages into ruby-readable format
|
61
61
|
test_files:
|
62
|
-
- spec/man_parser_spec.rb
|
63
62
|
- spec/spec_helper.rb
|
63
|
+
- spec/man_parser_spec.rb
|