Class: TriggerSwitchD::ConfigFactory::ProperEnvironmentFile

Inherits:
Object
  • Object
show all
Defined in:
lib/trigger_switch_d/config.rb

Overview

Verifies proper path to environment.rb

Instance Method Summary collapse

Constructor Details

#initializeProperEnvironmentFile

Returns a new instance of ProperEnvironmentFile.



23
24
25
26
27
# File 'lib/trigger_switch_d/config.rb', line 23

def initialize
  @paths_to_look = %w{~/.trigger_switch_d/config/ /etc/trigger_switch_d/config/ config/}
  @paths_to_look[0].gsub!("~",File.expand_path("~"))
  @env_name = "environment.rb"
end

Instance Method Details

#pathObject



29
30
31
32
33
34
35
# File 'lib/trigger_switch_d/config.rb', line 29

def path
  env_path = @paths_to_look.find do |path|
    File.exist?("#{path}#{@env_name}")
  end
  return offer_to_create if env_path == nil
  "#{env_path}#{@env_name}"
end