Sha256: 0cfaafe722eb198c2df264618036d713c1b6defa89a54a3718715e5ea3bbec4a

Contents?: true

Size: 675 Bytes

Versions: 1

Compression:

Stored size: 675 Bytes

Contents

module PopulateEnv
  module Formatters
    class EnvShellSection
      attr_reader :attribute, :export

      def initialize(attribute, export: false)
        @attribute = attribute
        @export = export
      end

      def prefix
        export ? "export " : ""
      end

      def to_s
        output = ''
        
        if attribute.description
          attribute.description.each_line do |line|
            output << "# #{line}\n"
          end
        end
        
        if attribute.optional? && attribute.value.nil?
          output << "# "
        end
        
        output << "#{prefix}#{attribute.name}=#{attribute.value}\n"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
populate-env-0.1.1 lib/populate_env/formatters/env_shell_section.rb