manpages 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48917ea5351910664e322885c4d4467a064775cf
4
- data.tar.gz: 97675264536cbdc896d9de852436bcd8f354f7b6
3
+ metadata.gz: 21e36c15f7ec3120e81a728ea1e6e17c3ee63da1
4
+ data.tar.gz: fa166fe6763c98a8e19985615b99ddae2a122d3e
5
5
  SHA512:
6
- metadata.gz: 2ad744d3592e6d7e88e7189f1eb7fb425f6eea69c11bedb263659ec9bdb955c68726687049a54f17e9d795559384410d26ee38b8101175e564efc4be0d3746dc
7
- data.tar.gz: 228abcb34f4219c4853a6b79ad8d9c333b429abdee5682d7e8ef304668e22b6693ce43e6f23397b47ad2342fe285596a11efe746029af38678e1f027aeebc275
6
+ metadata.gz: 1944db02ad4a705a23157e13a305b159d33a26a522a243c375d0b6856f1ac5b5a315243a6afe65dc65c4f92f0dbdbc6ff476ac0d309e831602facaf46996b93b
7
+ data.tar.gz: 231a6acb8428e0c465ccaff04b19f87e268527558f5364f65f1de0697dd3a30d30e323349ca7b1707ead1353a59a253ae7e816dd8897b57a4055b19068755c33
data/Gemfile.lock CHANGED
@@ -1,13 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- manpages (0.1.0)
4
+ manpages (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ coderay (1.1.1)
9
10
  diff-lcs (1.2.5)
10
- minitest (5.9.1)
11
+ method_source (0.8.2)
12
+ pry (0.10.3)
13
+ coderay (~> 1.1.0)
14
+ method_source (~> 0.8.1)
15
+ slop (~> 3.4)
11
16
  rake (10.5.0)
12
17
  rspec (3.5.0)
13
18
  rspec-core (~> 3.5.0)
@@ -22,6 +27,7 @@ GEM
22
27
  diff-lcs (>= 1.2.0, < 2.0)
23
28
  rspec-support (~> 3.5.0)
24
29
  rspec-support (3.5.0)
30
+ slop (3.6.0)
25
31
 
26
32
  PLATFORMS
27
33
  ruby
@@ -29,7 +35,7 @@ PLATFORMS
29
35
  DEPENDENCIES
30
36
  bundler (~> 1.8)
31
37
  manpages!
32
- minitest (~> 5.0)
38
+ pry
33
39
  rake (~> 10.0)
34
40
  rspec (~> 3.0)
35
41
 
data/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # Manpages
2
2
 
3
3
  [![Build Status](https://travis-ci.org/bitboxer/manpages.svg?branch=master)](https://travis-ci.org/bitboxer/manpages)
4
+ [![Gem](https://img.shields.io/gem/v/manpages.svg?maxAge=2592000)]()
4
5
 
5
6
  This plugin will add man pages support to ruby gems. Instead
6
7
  of adding a new command like [gem-man](https://github.com/defunkt/gem-man)
7
8
  it will try to link the files to place that the `man` command can find.
8
9
 
9
- With rvm it works out of the box, but sadly this means that for rbenv we
10
- need to add hooks that modify the `MANPATH` depending on the ruby version
11
- currently used.
10
+ With rvm and chruby it works out of the box, but sadly for rbenv we need to add
11
+ hooks that modify the `MANPATH` depending on the ruby version currently used.
12
12
 
13
13
  # Installation
14
14
 
@@ -28,4 +28,9 @@ simply use `man guard` and you will see the man page the gem provided.
28
28
 
29
29
  # Using this with rbenv
30
30
 
31
- ...coming soon
31
+ Sadly rbenv uses shims to hide the actual executables. This makes it impossible for
32
+ man to find the pages. The only solution is to add hooks that modify the `MANPATH`
33
+ environment variable.
34
+
35
+ This gem will provide a hook soon to fix this issue.
36
+
data/lib/manpages.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require "manpages/version"
2
2
  require "manpages/install"
3
+ require "manpages/uninstall"
4
+ require "manpages/man_files"
3
5
 
4
6
  module Manpages
5
7
 
@@ -8,7 +8,7 @@ module Manpages
8
8
  end
9
9
 
10
10
  def install_manpages
11
- manpages.each do |file|
11
+ ManFiles.new(@gem_dir, @target_dir).manpages.each do |file|
12
12
  link_manpage(file)
13
13
  end
14
14
  end
@@ -16,21 +16,9 @@ module Manpages
16
16
  private
17
17
 
18
18
  def link_manpage(file)
19
- man_dir = File.join(@target_dir, "man#{File.extname(file)[1..-1]}")
20
- FileUtils.mkdir_p(man_dir)
21
- FileUtils.ln_s(file, man_dir, force: true)
22
- end
23
-
24
- def manpages
25
- return [] unless File.directory?(man_dir)
26
-
27
- Dir.entries(man_dir).select do |file|
28
- file =~ /(.+).\d$/
29
- end.map {|file| File.join(man_dir, file) }
30
- end
31
-
32
- def man_dir
33
- @man_dir ||= File.join(@gem_dir, 'man')
19
+ man_target_file = ManFiles.new(@gem_dir, @target_dir).man_file_path(file)
20
+ FileUtils.mkdir_p(File.dirname(man_target_file))
21
+ FileUtils.ln_s(file, man_target_file, force: true)
34
22
  end
35
23
 
36
24
  end
@@ -0,0 +1,28 @@
1
+ module Manpages
2
+ class ManFiles
3
+
4
+ def initialize(gem_dir, target_dir)
5
+ @gem_dir = gem_dir
6
+ @target_dir = target_dir
7
+ end
8
+
9
+ def manpages
10
+ return [] unless File.directory?(man_dir)
11
+
12
+ Dir.entries(man_dir).select do |file|
13
+ file =~ /(.+).\d$/
14
+ end.map {|file| File.join(man_dir, file) }
15
+ end
16
+
17
+ def man_dir
18
+ @man_dir ||= File.join(@gem_dir, 'man')
19
+ end
20
+
21
+ def man_file_path(file)
22
+ basename = File.basename(file)
23
+ man_section = file.match(/.*\.(\d*)/)
24
+ File.join(@target_dir, "man#{man_section[1]}", basename)
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,26 @@
1
+ module Manpages
2
+
3
+ class Uninstall
4
+
5
+ def initialize(gem_dir, target_dir)
6
+ @gem_dir = gem_dir
7
+ @target_dir = target_dir
8
+ end
9
+
10
+ def uninstall_manpages
11
+ ManFiles.new(@gem_dir, @target_dir).manpages.each do |file|
12
+ unlink_manpage(file)
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def unlink_manpage(file)
19
+ man_target_file = ManFiles.new(@gem_dir, @target_dir).man_file_path(file)
20
+ if File.symlink?(man_target_file) && File.readlink(man_target_file) == file
21
+ FileUtils.rm(man_target_file)
22
+ end
23
+ end
24
+
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module Manpages
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -9,3 +9,10 @@ Gem.post_install do |installer|
9
9
 
10
10
  Manpages::Install.new(source_dir, target_dir).install_manpages
11
11
  end
12
+
13
+ Gem.post_uninstall do |uninstaller|
14
+ source_dir = uninstaller.spec.gem_dir
15
+ target_dir = File.join(uninstaller.bin_dir, "../share/man")
16
+
17
+ Manpages::Uninstall.new(source_dir, target_dir).uninstall_manpages
18
+ end
data/manpages.gemspec CHANGED
@@ -23,6 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "bundler", "~> 1.8"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "rspec", "~> 3.0"
26
-
27
- spec.add_development_dependency "minitest", "~> 5.0"
26
+ spec.add_development_dependency "pry"
28
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manpages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bodo Tasche
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-03 00:00:00.000000000 Z
11
+ date: 2016-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -53,19 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: minitest
56
+ name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '5.0'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '5.0'
68
+ version: '0'
69
69
  description: This is a little experiment that adds man pages support to rubygems
70
70
  email:
71
71
  - bodo@tasche.me
@@ -83,6 +83,8 @@ files:
83
83
  - Rakefile
84
84
  - lib/manpages.rb
85
85
  - lib/manpages/install.rb
86
+ - lib/manpages/man_files.rb
87
+ - lib/manpages/uninstall.rb
86
88
  - lib/manpages/version.rb
87
89
  - lib/rubygems/commands/manpages_command.rb
88
90
  - lib/rubygems_plugin.rb
@@ -112,4 +114,3 @@ signing_key:
112
114
  specification_version: 4
113
115
  summary: Adds support for man pages to rubygems
114
116
  test_files: []
115
- has_rdoc: