manpages 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/manpages.rb +1 -0
- data/lib/manpages/gem_version.rb +24 -0
- data/lib/manpages/install.rb +16 -5
- data/lib/manpages/uninstall.rb +8 -3
- data/lib/manpages/version.rb +1 -1
- data/lib/rubygems_plugin.rb +4 -4
- metadata +3 -3
- data/lib/rubygems/commands/manpages_command.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ab7800ca095338322550d7af194a1c438cf6e15
|
4
|
+
data.tar.gz: c614993dc6ee596338851261ccfa32fe811ed06d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14886da88e27fd091701ab9903b4ed81ef8b3fb55f3ef75034675e6c196071beb5767b727ad2ac5606cb7caa0f8edf140a74be8560a868ff7e3178c9806b61bc
|
7
|
+
data.tar.gz: 50eca018decc731ca8c55638e3308141a6821cb4fabca3e5e99b4674295582ae1ed4488b8075603b7ab8f8209cacc5f50e0b541b30225609daa8c6e8ba952a94
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
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
|
+
[![Gem](https://img.shields.io/gem/v/manpages.svg?maxAge=2592000)](https://rubygems.org/gems/manpages)
|
5
5
|
|
6
6
|
This plugin will add man pages support to ruby gems. Instead
|
7
7
|
of adding a new command like [gem-man](https://github.com/defunkt/gem-man)
|
data/lib/manpages.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Manpages
|
2
|
+
|
3
|
+
class GemVersion
|
4
|
+
|
5
|
+
def initialize(gem_spec)
|
6
|
+
@gem_spec = gem_spec
|
7
|
+
end
|
8
|
+
|
9
|
+
def is_latest?
|
10
|
+
latest_gem.nil? || latest_gem <= @gem_spec.version
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def latest_gem
|
16
|
+
all_gem_versions.sort.last
|
17
|
+
end
|
18
|
+
|
19
|
+
def all_gem_versions
|
20
|
+
Gem::Specification.each.select { |spec| @gem_spec.name === spec.name }.map(&:version)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
data/lib/manpages/install.rb
CHANGED
@@ -2,23 +2,34 @@ module Manpages
|
|
2
2
|
|
3
3
|
class Install
|
4
4
|
|
5
|
-
def initialize(gem_dir, target_dir)
|
5
|
+
def initialize(gem_spec, gem_dir, target_dir)
|
6
|
+
@gem_spec = gem_spec
|
6
7
|
@gem_dir = gem_dir
|
7
8
|
@target_dir = target_dir
|
8
9
|
end
|
9
10
|
|
10
11
|
def install_manpages
|
12
|
+
link_manpages if GemVersion.new(@gem_spec).is_latest?
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def link_manpages
|
11
18
|
ManFiles.new(@gem_dir, @target_dir).manpages.each do |file|
|
12
19
|
link_manpage(file)
|
13
20
|
end
|
14
21
|
end
|
15
22
|
|
16
|
-
private
|
17
|
-
|
18
23
|
def link_manpage(file)
|
19
24
|
man_target_file = ManFiles.new(@gem_dir, @target_dir).man_file_path(file)
|
20
|
-
|
21
|
-
|
25
|
+
return if File.exist? man_target_file
|
26
|
+
|
27
|
+
begin
|
28
|
+
FileUtils.mkdir_p(File.dirname(man_target_file))
|
29
|
+
FileUtils.ln_s(file, man_target_file, force: true)
|
30
|
+
rescue => e
|
31
|
+
puts "Problems creating symlink #{man_target_file}"
|
32
|
+
end
|
22
33
|
end
|
23
34
|
|
24
35
|
end
|
data/lib/manpages/uninstall.rb
CHANGED
@@ -2,19 +2,24 @@ module Manpages
|
|
2
2
|
|
3
3
|
class Uninstall
|
4
4
|
|
5
|
-
def initialize(gem_dir, target_dir)
|
5
|
+
def initialize(gem_spec, gem_dir, target_dir)
|
6
|
+
@gem_spec = gem_spec
|
6
7
|
@gem_dir = gem_dir
|
7
8
|
@target_dir = target_dir
|
8
9
|
end
|
9
10
|
|
10
11
|
def uninstall_manpages
|
12
|
+
unlink_manpages if GemVersion.new(@gem_spec).is_latest?
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def unlink_manpages
|
11
18
|
ManFiles.new(@gem_dir, @target_dir).manpages.each do |file|
|
12
19
|
unlink_manpage(file)
|
13
20
|
end
|
14
21
|
end
|
15
22
|
|
16
|
-
private
|
17
|
-
|
18
23
|
def unlink_manpage(file)
|
19
24
|
man_target_file = ManFiles.new(@gem_dir, @target_dir).man_file_path(file)
|
20
25
|
if File.symlink?(man_target_file) && File.readlink(man_target_file) == file
|
data/lib/manpages/version.rb
CHANGED
data/lib/rubygems_plugin.rb
CHANGED
@@ -5,15 +5,15 @@ Gem::CommandManager.instance.register_command(:manpages)
|
|
5
5
|
|
6
6
|
Gem.post_install do |installer|
|
7
7
|
source_dir = installer.spec.gem_dir
|
8
|
-
target_dir = File.
|
8
|
+
target_dir = File.expand_path(installer.bin_dir, "../share/man")
|
9
9
|
|
10
|
-
Manpages::Install.new(source_dir, target_dir).install_manpages
|
10
|
+
Manpages::Install.new(installer.spec, source_dir, target_dir).install_manpages
|
11
11
|
end
|
12
12
|
|
13
13
|
Gem.pre_uninstall do |uninstaller|
|
14
14
|
bin_dir = uninstaller.bin_dir || Gem.bindir(uninstaller.spec.base_dir)
|
15
15
|
source_dir = uninstaller.spec.gem_dir
|
16
|
-
target_dir = File.
|
16
|
+
target_dir = File.expand_path(bin_dir, "../share/man")
|
17
17
|
|
18
|
-
Manpages::Uninstall.new(source_dir, target_dir).uninstall_manpages
|
18
|
+
Manpages::Uninstall.new(uninstaller.spec, source_dir, target_dir).uninstall_manpages
|
19
19
|
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.
|
4
|
+
version: 0.3.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-
|
11
|
+
date: 2016-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -82,11 +82,11 @@ files:
|
|
82
82
|
- README.md
|
83
83
|
- Rakefile
|
84
84
|
- lib/manpages.rb
|
85
|
+
- lib/manpages/gem_version.rb
|
85
86
|
- lib/manpages/install.rb
|
86
87
|
- lib/manpages/man_files.rb
|
87
88
|
- lib/manpages/uninstall.rb
|
88
89
|
- lib/manpages/version.rb
|
89
|
-
- lib/rubygems/commands/manpages_command.rb
|
90
90
|
- lib/rubygems_plugin.rb
|
91
91
|
- manpages.gemspec
|
92
92
|
homepage: https://github.com/bitboxer/manpages
|
@@ -1,15 +0,0 @@
|
|
1
|
-
class Gem::Commands::ManpagesCommand < Gem::Command
|
2
|
-
def initialize
|
3
|
-
super("manpages", "Add a description here")
|
4
|
-
end
|
5
|
-
|
6
|
-
def execute
|
7
|
-
# TODO: Add command to install
|
8
|
-
# to rbenv and rvm
|
9
|
-
|
10
|
-
|
11
|
-
# here goes the code that will be executed
|
12
|
-
# when someone runs "gem manpages"
|
13
|
-
say "It works!"
|
14
|
-
end
|
15
|
-
end
|