32 lines
687 B
Ruby
Raw Normal View History

2020-10-10 14:16:11 +02:00
# typed: true
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
2020-08-19 10:23:41 +02:00
# Artifact corresponding to the `manpage` stanza.
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)
section = source.to_s[/\.([1-8]|n|l)(?:\.gz)?$/, 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