403Webshell
Server IP : 66.29.132.122  /  Your IP : 3.141.4.167
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/self/root/proc/self/root/proc/thread-self/root/proc/thread-self/root/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/self/root/proc/self/root/proc/thread-self/root/proc/thread-self/root/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/reference.rb
require_relative '../../puppet/util/instance_loader'
require 'fileutils'

# Manage Reference Documentation.
class Puppet::Util::Reference
  include Puppet::Util
  include Puppet::Util::Docs

  extend Puppet::Util::InstanceLoader

  instance_load(:reference, 'puppet/reference')

  def self.modes
    %w{pdf text}
  end

  def self.newreference(name, options = {}, &block)
    ref = self.new(name, **options, &block)
    instance_hash(:reference)[name.intern] = ref

    ref
  end

  def self.page(*sections)
    depth = 4
    # Use the minimum depth
    sections.each do |name|
      section = reference(name) or raise _("Could not find section %{name}") % { name: name }
      depth = section.depth if section.depth < depth
    end
  end

  def self.pdf(text)
    puts _("creating pdf")
    rst2latex = which('rst2latex') || which('rst2latex.py') ||
      raise(_("Could not find rst2latex"))

    cmd = %{#{rst2latex} /tmp/puppetdoc.txt > /tmp/puppetdoc.tex}
    Puppet::Util.replace_file("/tmp/puppetdoc.txt") {|f| f.puts text }
    # There used to be an attempt to use secure_open / replace_file to secure
    # the target, too, but that did nothing: the race was still here.  We can
    # get exactly the same benefit from running this effort:
    Puppet::FileSystem.unlink('/tmp/puppetdoc.tex') rescue nil
    output = %x{#{cmd}}
    unless $CHILD_STATUS == 0
      $stderr.puts _("rst2latex failed")
      $stderr.puts output
      exit(1)
    end
    $stderr.puts output

    # Now convert to pdf
    Dir.chdir("/tmp") do
      %x{texi2pdf puppetdoc.tex >/dev/null 2>/dev/null}
    end

  end

  def self.references(environment)
    instance_loader(:reference).loadall(environment)
    loaded_instances(:reference).sort_by(&:to_s)
  end

  attr_accessor :page, :depth, :header, :title, :dynamic
  attr_writer :doc

  def doc
    if defined?(@doc)
      return "#{@name} - #{@doc}"
    else
      return @title
    end
  end

  def dynamic?
    self.dynamic
  end

  def initialize(name, title: nil, depth: nil, dynamic: nil, doc: nil, &block)
    @name = name
    @title = title
    @depth = depth
    @dynamic = dynamic
    @doc = doc

    meta_def(:generate, &block)

    # Now handle the defaults
    @title ||= _("%{name} Reference") % { name: @name.to_s.capitalize }
    @page ||= @title.gsub(/\s+/, '')
    @depth ||= 2
    @header ||= ""
  end

  # Indent every line in the chunk except those which begin with '..'.
  def indent(text, tab)
    text.gsub(/(^|\A)/, tab).gsub(/^ +\.\./, "..")
  end

  def option(name, value)
    ":#{name.to_s.capitalize}: #{value}\n"
  end

  def text
    puts output
  end

  def to_markdown(withcontents = true)
    # First the header
    text = markdown_header(@title, 1)
    text << _("\n\n**This page is autogenerated; any changes will get overwritten**\n\n")

    text << @header

    text << generate

    text
  end
end

Youez - 2016 - github.com/yon3zu
LinuXploit