class Dotenvious::CLI::EnvFileConsolidator

Attributes

env_file[R]
example_file[R]
filename[R]

Public Class Methods

new(example_file: DEFAULT_EXAMPLE_ENV_FILE, env_file: DEFAULT_ENV_FILE) click to toggle source
# File lib/dotenvious/cli/env_file_consolidator.rb, line 9
def initialize(example_file: DEFAULT_EXAMPLE_ENV_FILE, env_file: DEFAULT_ENV_FILE)
  @example_file = example_file
  @env_file = env_file
end

Public Instance Methods

run() click to toggle source
# File lib/dotenvious/cli/env_file_consolidator.rb, line 14
def run
  Loaders::Configuration.new.load
  Loaders::Environments.new({example_file: example_file, env_file: env_file}).load_environments
  unless all_vars_present? && all_vars_match?
    alert_user
    decision = STDIN.gets.strip
    Prompter.new(env_file).run if decision.downcase == 'y'
  end
end

Private Instance Methods

alert_user() click to toggle source
# File lib/dotenvious/cli/env_file_consolidator.rb, line 28
def alert_user
  puts "You have missing ENV variables. Examime them? [y/n]"
end
all_vars_match?() click to toggle source
# File lib/dotenvious/cli/env_file_consolidator.rb, line 36
def all_vars_match?
  !MismatchedVariableFinder.mismatched_vars?
end
all_vars_present?() click to toggle source
# File lib/dotenvious/cli/env_file_consolidator.rb, line 32
def all_vars_present?
  !MissingVariableFinder.required_vars_missing?
end