lib/manpages/install.rb in manpages-0.2.1 vs lib/manpages/install.rb in manpages-0.3.0
- old
+ new
@@ -1,25 +1,36 @@
module Manpages
class Install
- def initialize(gem_dir, target_dir)
+ def initialize(gem_spec, gem_dir, target_dir)
+ @gem_spec = gem_spec
@gem_dir = gem_dir
@target_dir = target_dir
end
def install_manpages
+ link_manpages if GemVersion.new(@gem_spec).is_latest?
+ end
+
+ private
+
+ def link_manpages
ManFiles.new(@gem_dir, @target_dir).manpages.each do |file|
link_manpage(file)
end
end
- private
-
def link_manpage(file)
man_target_file = ManFiles.new(@gem_dir, @target_dir).man_file_path(file)
- FileUtils.mkdir_p(File.dirname(man_target_file))
- FileUtils.ln_s(file, man_target_file, force: true)
+ return if File.exist? man_target_file
+
+ begin
+ FileUtils.mkdir_p(File.dirname(man_target_file))
+ FileUtils.ln_s(file, man_target_file, force: true)
+ rescue => e
+ puts "Problems creating symlink #{man_target_file}"
+ end
end
end
end