This file is indexed.

/usr/lib/ruby/vendor_ruby/slim/command.rb is in ruby-slim 2.0.2-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
require 'slim'
require 'optparse'

module Slim
  Engine.set_default_options :pretty => false

  # Slim commandline interface
  # @api private
  class Command
    def initialize(args)
      @args = args
      @options = {}
    end

    # Run command
    def run
      @opts = OptionParser.new(&method(:set_opts))
      @opts.parse!(@args)
      process
      exit 0
    rescue Exception => ex
      raise ex if @options[:trace] || SystemExit === ex
      $stderr.print "#{ex.class}: " if ex.class != RuntimeError
      $stderr.puts ex.message
      $stderr.puts '  Use --trace for backtrace.'
      exit 1
    end

    private

    # Configure OptionParser
    def set_opts(opts)
      opts.on('-s', '--stdin', 'Read input from standard input instead of an input file') do
        @options[:input] = $stdin
      end

      opts.on('--trace', 'Show a full traceback on error') do
        @options[:trace] = true
      end

      opts.on('-c', '--compile', 'Compile only but do not run') do
        @options[:compile] = true
      end

      opts.on('-e', '--erb', 'Convert to ERB') do
        @options[:erb] = true
      end

      opts.on('-r', '--rails', 'Generate rails compatible code (Implies --compile)') do
        Engine.set_default_options :disable_capture => true, :generator => Temple::Generators::RailsOutputBuffer
        @options[:compile] = true
      end

      opts.on('-t', '--translator', 'Enable translator plugin') do
        require 'slim/translator'
      end

      opts.on('-l', '--logic-less', 'Enable logic less plugin') do
        require 'slim/logic_less'
      end

      opts.on('-p', '--pretty', 'Produce pretty html') do
        Engine.set_default_options :pretty => true
      end

      opts.on('-o', '--option [NAME=CODE]', String, 'Set slim option') do |str|
        parts = str.split('=', 2)
        Engine.default_options[parts.first.gsub(/\A:/, '').to_sym] = eval(parts.last)
      end

      opts.on_tail('-h', '--help', 'Show this message') do
        puts opts
        exit
      end

      opts.on_tail('-v', '--version', 'Print version') do
        puts "Slim #{VERSION}"
        exit
      end
    end

    # Process command
    def process
      args = @args.dup
      unless @options[:input]
        file = args.shift
        if file
          @options[:file] = file
          @options[:input] = File.open(file, 'r')
        else
          @options[:file] = 'STDIN'
          @options[:input] = $stdin
        end
      end

      unless @options[:output]
        file = args.shift
        @options[:output] = file ? File.open(file, 'w') : $stdout
      end

      result =
        if @options[:erb]
          require 'slim/erb_converter'
          ERBConverter.new(:file => @options[:file]).call(@options[:input].read)
        elsif @options[:compile]
          Engine.new(:file => @options[:file]).call(@options[:input].read)
        else
          Template.new(@options[:file]) { @options[:input].read }.render
        end

      @options[:output].puts(result)
    end
  end
end