Sha256: df08376ef4993234f28bf32bdccc24884d52f5d353368cc813c3d2bb1226fa71

Contents?: true

Size: 849 Bytes

Versions: 2

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

require 'avm/files/formatter/formats/base'

module Avm
  module Files
    class Formatter
      module Formats
        class GenericPlain < ::Avm::Files::Formatter::Formats::Base
          VALID_EXTENSIONS = %w[.bat .css.coffee .java .js .json .rb .scss .sql .tex .url .yml
                                .yaml].freeze

          VALID_TYPES = %w[plain x-shellscript].freeze

          def internal_apply(files)
            files.each { |file| file_apply(file) }
          end

          def file_apply(file)
            file.write(string_apply(file.read))
          end

          def string_apply(string)
            b = ''
            string.each_line do |line|
              b += "#{line.rstrip}\n"
            end
            "#{b.strip}\n".gsub(/\t/, '  ')
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
avm-tools-0.39.0 lib/avm/files/formatter/formats/generic_plain.rb
avm-tools-0.38.0 lib/avm/files/formatter/formats/generic_plain.rb