Module: TxCatcher::Initializer::ConfigFile

Defined in:
lib/txcatcher/initializer.rb

Class Method Summary collapse

Class Method Details

.pathObject



40
41
42
# File 'lib/txcatcher/initializer.rb', line 40

def path
  @@config_file
end

.set!(path = nil) ⇒ Object

Determine config dir or set default. Useful when we want to have different settings for production or staging or development environments.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/txcatcher/initializer.rb', line 20

def set!(path=nil)
  @@config_file = path
  unless path
    @@config_file = ENV['HOME'] + '/.txcatcher/config.yml'
    ARGV.each_with_index do |a,i|
      if a =~ /\A--config-file=.+/
        @@config_file = File.expand_path(a.sub('--config-file=', ''))
        ARGV.delete_at(i)
        break
      elsif a =~ /\A-c\Z/
        @@config_file = File.expand_path(ARGV[1])
        ARGV.delete_at(i) and ARGV.delete_at(i+1)
        break
      end
    end
  end
  TxCatcher::Config.config_dir = File.dirname(@@config_file)
  puts "Using config file: #{@@config_file}"
end