Sha256: 484d904cee4bba3dee03bdfeb3524efaf2ea23410c4818a8a2983fdc024056f0

Contents?: true

Size: 785 Bytes

Versions: 5

Compression:

Stored size: 785 Bytes

Contents

module Manpages
  class Install
    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).latest?
    end

  private

    def link_manpages
      ManFiles.new(@gem_dir, @target_dir).manpages.each do |file|
        link_manpage(file)
      end
    end

    def link_manpage(file)
      man_target_file = ManFiles.new(@gem_dir, @target_dir).man_file_path(file)
      return if man_target_file.exist?

      begin
        FileUtils.mkdir_p(man_target_file.dirname)
        FileUtils.ln_s(file, man_target_file, force: true)
      rescue
        puts "Problems creating symlink #{man_target_file}"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
manpages-0.6.0 lib/manpages/install.rb
manpages-0.5.2 lib/manpages/install.rb
manpages-0.5.1 lib/manpages/install.rb
manpages-0.5.0 lib/manpages/install.rb
manpages-0.4.0 lib/manpages/install.rb