30 lines
610 B
Ruby
Raw Normal View History

2019-10-22 15:19:40 +03:00
# frozen_string_literal: true
2019-10-23 16:28:00 +03:00
require "cask/artifact/symlinked"
2019-10-22 15:19:40 +03:00
module Cask
module Artifact
2019-10-23 16:28:00 +03:00
class Manpage < Symlinked
2019-10-23 18:34:16 +03:00
attr_reader :section
2019-10-23 16:28:00 +03:00
def self.from_args(cask, source)
2019-10-23 18:34:16 +03:00
section = source.to_s[/\.([1-8]|n|l)$/, 1]
2019-10-22 15:19:40 +03:00
2019-10-23 18:34:16 +03:00
raise CaskInvalidError, "'#{source}' is not a valid man page name" unless section
2019-10-22 15:19:40 +03:00
2019-10-23 18:34:16 +03:00
new(cask, source, section)
2019-10-23 16:28:00 +03:00
end
2019-10-22 15:19:40 +03:00
2019-10-23 18:34:16 +03:00
def initialize(cask, source, section)
@section = section
super(cask, source)
2019-10-22 15:19:40 +03:00
end
2019-10-24 09:43:59 +03:00
def resolve_target(target)
config.manpagedir.join("man#{section}", target)
2019-10-22 15:19:40 +03:00
end
end
end
end