Sha256: 310aa62a6cbfafaa92324e862b745eaff6e88db1bc9f6ebb9a00f1d077b1bff2

Contents?: true

Size: 633 Bytes

Versions: 2

Compression:

Stored size: 633 Bytes

Contents

require "pathname"

module Manpages
  class ManFiles
    attr_reader :man_dir

    def initialize(gem_dir, target_dir = "")
      @target_dir = Pathname(target_dir)
      @man_dir = Pathname(File.join(gem_dir, "man"))
    end

    def manpages_present?
      !manpages.empty?
    end

    def manpages
      return [] unless man_dir.directory?

      man_dir.children(false).select do |file|
        file.extname =~ /.\d$/
      end.map {|file| man_dir.join(file) }
    end

    def man_file_path(file)
      man_section = file.extname.match(/\.(\d*)/)
      @target_dir.join("man#{man_section[1]}", file.basename)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
manpages-0.5.2 lib/manpages/man_files.rb
manpages-0.5.1 lib/manpages/man_files.rb