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
|
|
|
|
def self.from_args(cask, source)
|
|
|
|
section = source.split(".").last
|
2019-10-22 15:19:40 +03:00
|
|
|
|
|
|
|
raise CaskInvalidError, "section should be a positive number" unless section.to_i.positive?
|
|
|
|
|
2019-10-23 16:28:00 +03:00
|
|
|
new(cask, source)
|
|
|
|
end
|
2019-10-22 15:19:40 +03:00
|
|
|
|
2019-10-23 16:28:00 +03:00
|
|
|
def initialize(cask, source)
|
|
|
|
super
|
2019-10-22 15:19:40 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def resolve_target(_target)
|
|
|
|
config.manpagedir.join("man#{section}", target_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
def section
|
2019-10-23 16:28:00 +03:00
|
|
|
@source.extname.downcase[1..-1].to_s.to_i
|
2019-10-22 15:19:40 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
def target_name
|
|
|
|
"#{@source.basename(@source.extname)}.#{section}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|