Class: Dotenv::EnvTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/dotenv/template.rb

Overview

Class for creating a template from a env file

Instance Method Summary collapse

Constructor Details

#initialize(env_file) ⇒ EnvTemplate

Returns a new instance of EnvTemplate.



4
5
6
# File 'lib/dotenv/template.rb', line 4

def initialize(env_file)
  @env_file = env_file
end

Instance Method Details

#create_templateObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/dotenv/template.rb', line 8

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|
        variable = line.split("=").first
        env_template.puts "#{variable}=#{variable}"
      end
    end
  end
end