gem-man 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -34,7 +34,7 @@ you'd like to view. If only a single man page is found it will be
34
34
  displayed.
35
35
 
36
36
  Man pages are any files whose extension is a single digit [0-9],
37
- e.g. `ron.1`.
37
+ e.g. `ronn.1`.
38
38
 
39
39
  ## SECTION
40
40
 
@@ -80,15 +80,15 @@ See `gem help man` to view the options at any time.
80
80
  ## EXAMPLES
81
81
 
82
82
  gem man mustache
83
- gem man 1 ron
83
+ gem man 1 ronn
84
84
  gem man -a
85
85
 
86
86
  ## AUTHORING
87
87
 
88
- For information on authoring man pages, see [`ron(7)`][r7]:
88
+ For information on authoring man pages, see [`ronn(7)`][r7]:
89
89
 
90
- gem install ron
91
- gem man 7 ron
90
+ gem install ronn
91
+ gem man 7 ronn
92
92
 
93
93
  ## CHEATING
94
94
 
@@ -115,7 +115,7 @@ Please report other bugs at <http://github.com/defunkt/gem-man/issues>
115
115
  ## THANKS
116
116
 
117
117
  * adamsanderson for open_gem
118
- * rtomayko for ron
118
+ * rtomayko for ronn
119
119
 
120
120
  ## COPYRIGHT
121
121
 
@@ -124,8 +124,8 @@ Sanderson.
124
124
 
125
125
  ## SEE ALSO
126
126
 
127
- ron(7), man(1), less(1), roff(7), groff(1),
127
+ ronn(7), man(1), less(1), roff(7), groff(1),
128
128
  <http://en.wikipedia.org/wiki/Man_page>,
129
129
  <http://github.com/defunkt/gem-man>
130
130
 
131
- [r7]: http://rtomayko.github.com/ron/
131
+ [r7]: http://rtomayko.github.com/ronn/
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ end
11
11
  begin
12
12
  require 'mg'
13
13
  MG.new('gem-man.gemspec')
14
- rescue Loaderror
14
+ rescue LoadError
15
15
  warn "gem install mg to get gem tasks"
16
16
  end
17
17
 
@@ -62,7 +62,10 @@ class Gem::Commands::ManCommand < Gem::Command
62
62
 
63
63
  if options[:all]
64
64
  puts "These gems have man pages:", ''
65
- Gem.source_index.gems.each do |name, spec|
65
+
66
+ specs = Gem::Specification.respond_to?(:each) ? Gem::Specification : Gem.source_index.gems
67
+ specs.each do |*name_and_spec|
68
+ spec = name_and_spec.pop
66
69
  puts "#{spec.name} #{spec.version}" if spec.has_manpage?
67
70
  end
68
71
  else
@@ -104,7 +107,7 @@ class Gem::Commands::ManCommand < Gem::Command
104
107
  end
105
108
 
106
109
  if manpath
107
- exec "man #{File.join(gem_path(spec), manpath)}"
110
+ exec "man #{File.join(spec.man_dir, manpath)}"
108
111
  else
109
112
  abort "no manuals found for #{spec.name}"
110
113
  end
@@ -115,14 +118,19 @@ class Gem::Commands::ManCommand < Gem::Command
115
118
  end
116
119
 
117
120
  def get_spec(name, &block)
118
- dep = Gem::Dependency.new(name, options[:version])
119
- specs = Gem.source_index.search(dep)
121
+ # Since Gem::Dependency.new doesn't want a Regexp
122
+ # We'll do it ourself!
123
+ specs = if Gem::Specification.respond_to?(:each)
124
+ Gem::Specification.each.select { |spec| name === spec.name }
125
+ else
126
+ Gem.source_index.search Gem::Dependency.new(name, options[:version])
127
+ end
120
128
 
121
129
  if block
122
130
  specs = specs.select { |spec| yield spec }
123
131
  end
124
132
 
125
- if specs.length == 0
133
+ if specs.empty?
126
134
  # If we have not tried to do a pattern match yet, fall back on it.
127
135
  if !options[:exact] && !name.is_a?(Regexp)
128
136
  pattern = /#{Regexp.escape name}/
@@ -130,7 +138,7 @@ class Gem::Commands::ManCommand < Gem::Command
130
138
  else
131
139
  nil
132
140
  end
133
- elsif specs.length == 1 || options[:latest]
141
+ elsif specs.size == 1 || options[:latest]
134
142
  specs.last
135
143
  else
136
144
  choices = specs.map { |s| "#{s.name} #{s.version}" }
@@ -1,13 +1,25 @@
1
1
  class Gem::Specification
2
+
3
+ ##
4
+ # Returns the full path to installed gem's manual directory.
5
+
6
+ def man_dir
7
+ @man_dir ||= File.join(respond_to?(:gem_dir) ? gem_dir : full_gem_path, 'man')
8
+ end
9
+
10
+ ##
2
11
  # Does this specification include a manpage?
12
+
3
13
  def has_manpage?(section = nil)
4
- manpages(section).any?
14
+ File.directory?(man_dir) && manpages(section).any?
5
15
  end
6
16
 
17
+ ##
7
18
  # Paths to the manpages included in this gem.
19
+
8
20
  def manpages(section = nil)
9
- @files.select do |file|
10
- file =~ /man\/(.+).#{section || '\d'}$/
21
+ Dir.entries(man_dir).select do |file|
22
+ file =~ /(.+).#{section || '\d'}$/
11
23
  end
12
24
  end
13
25
  end
@@ -1,5 +1,5 @@
1
1
  require 'rubygems/command_manager'
2
- require "rubygems/version_option"
2
+ require 'rubygems/version_option'
3
3
  require 'rubygems/gem/specification'
4
4
 
5
5
  Gem::CommandManager.instance.register_command :man
@@ -34,7 +34,7 @@ you'd like to view. If only a single man page is found it will be
34
34
  displayed.
35
35
 
36
36
  Man pages are any files whose extension is a single digit [0-9],
37
- e.g. `ron.1`.
37
+ e.g. `ronn.1`.
38
38
 
39
39
  ## SECTION
40
40
 
@@ -80,15 +80,15 @@ See `gem help man` to view the options at any time.
80
80
  ## EXAMPLES
81
81
 
82
82
  gem man mustache
83
- gem man 1 ron
83
+ gem man 1 ronn
84
84
  gem man -a
85
85
 
86
86
  ## AUTHORING
87
87
 
88
- For information on authoring man pages, see [`ron(7)`][r7]:
88
+ For information on authoring man pages, see [`ronn(7)`][r7]:
89
89
 
90
- gem install ron
91
- gem man 7 ron
90
+ gem install ronn
91
+ gem man 7 ronn
92
92
 
93
93
  ## CHEATING
94
94
 
@@ -115,7 +115,7 @@ Please report other bugs at <http://github.com/defunkt/gem-man/issues>
115
115
  ## THANKS
116
116
 
117
117
  * adamsanderson for open_gem
118
- * rtomayko for ron
118
+ * rtomayko for ronn
119
119
 
120
120
  ## COPYRIGHT
121
121
 
@@ -124,8 +124,8 @@ Sanderson.
124
124
 
125
125
  ## SEE ALSO
126
126
 
127
- ron(7), man(1), less(1), roff(7), groff(1),
127
+ ronn(7), man(1), less(1), roff(7), groff(1),
128
128
  <http://en.wikipedia.org/wiki/Man_page>,
129
129
  <http://github.com/defunkt/gem-man>
130
130
 
131
- [r7]: http://rtomayko.github.com/ron/
131
+ [r7]: http://rtomayko.github.com/ronn/
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem-man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ hash: 19
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Chris Wanstrath
@@ -9,7 +15,7 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-03-06 00:00:00 -08:00
18
+ date: 2011-08-15 00:00:00 -07:00
13
19
  default_executable:
14
20
  dependencies: []
15
21
 
@@ -22,17 +28,17 @@ extensions: []
22
28
  extra_rdoc_files: []
23
29
 
24
30
  files:
25
- - README.md
26
- - Rakefile
27
- - LICENSE
28
31
  - lib/rubygems/commands/man_command.rb
29
32
  - lib/rubygems/gem/specification.rb
30
33
  - lib/rubygems_plugin.rb
31
34
  - man/gem-man.1
32
35
  - man/gem-man.1.html
33
- - man/gem-man.1.ron
36
+ - man/gem-man.1.ronn
37
+ - README.md
38
+ - Rakefile
39
+ - LICENSE
34
40
  has_rdoc: true
35
- homepage: http://github.com/defunkt/gem-man
41
+ homepage: https://github.com/defunkt/gem-man
36
42
  licenses: []
37
43
 
38
44
  post_install_message:
@@ -41,21 +47,27 @@ rdoc_options: []
41
47
  require_paths:
42
48
  - lib
43
49
  required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
44
51
  requirements:
45
52
  - - ">="
46
53
  - !ruby/object:Gem::Version
54
+ hash: 3
55
+ segments:
56
+ - 0
47
57
  version: "0"
48
- version:
49
58
  required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
50
60
  requirements:
51
61
  - - ">="
52
62
  - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
53
66
  version: "0"
54
- version:
55
67
  requirements: []
56
68
 
57
69
  rubyforge_project:
58
- rubygems_version: 1.3.5
70
+ rubygems_version: 1.5.2
59
71
  signing_key:
60
72
  specification_version: 3
61
73
  summary: View a gem's man page.