Sha256: dadb17a720eb050f0f5c5ae7ebd63d7fb52e0549c1d47461edba8339bf3c8b9d

Contents?: true

Size: 684 Bytes

Versions: 10

Compression:

Stored size: 684 Bytes

Contents

module Dotenv
  EXPORT_COMMAND = "export ".freeze
  # Class for creating a template from a env file
  class EnvTemplate
    def initialize(env_file)
      @env_file = env_file
    end

    def create_template
      File.open(@env_file, "r") do |env_file|
        File.open("#{@env_file}.template", "w") do |env_template|
          env_file.each do |line|
            env_template.puts template_line(line)
          end
        end
      end
    end

    def template_line(line)
      var, value = line.split("=")
      template = var.gsub(EXPORT_COMMAND, "")
      is_a_comment = var.strip[0].eql?("#")
      value.nil? || is_a_comment ? line : "#{var}=#{template}"
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
study_line-0.2.7 vendor/bundle/ruby/3.2.0/gems/dotenv-2.8.1/lib/dotenv/template.rb
study_line-0.2.6 vendor/bundle/ruby/3.2.0/gems/dotenv-2.8.1/lib/dotenv/template.rb
study_line-0.2.5 vendor/bundle/ruby/3.2.0/gems/dotenv-2.8.1/lib/dotenv/template.rb
study_line-0.2.4 vendor/bundle/ruby/3.2.0/gems/dotenv-2.8.1/lib/dotenv/template.rb
study_line-0.2.3 vendor/bundle/ruby/3.2.0/gems/dotenv-2.8.1/lib/dotenv/template.rb
study_line-0.2.2 vendor/bundle/ruby/3.2.0/gems/dotenv-2.8.1/lib/dotenv/template.rb
study_line-0.2.1 vendor/bundle/ruby/3.2.0/gems/dotenv-2.8.1/lib/dotenv/template.rb
study_line-0.2.0 vendor/bundle/ruby/3.2.0/gems/dotenv-2.8.1/lib/dotenv/template.rb
dotenv-2.8.1 lib/dotenv/template.rb
dotenv-2.8.0 lib/dotenv/template.rb