class Remotenv::Adapters::Base

Attributes

data[R]
options[R]
uri[R]

Public Class Methods

new(uri, options = {}) click to toggle source
# File lib/remotenv/adapters/base.rb, line 10
def initialize(uri, options = {})
  @uri = uri
  @options = options
  @data = {}
  @content = nil
end

Public Instance Methods

after_load() click to toggle source
# File lib/remotenv/adapters/base.rb, line 33
def after_load
end
apply_environment() click to toggle source
# File lib/remotenv/adapters/base.rb, line 40
def apply_environment
  Remotenv.logger.debug("Applying environment variables")
  @data = Dotenv::Parser.call(@content)
  Remotenv.logger.debug("ENV: #{@data.keys.join(', ')}")
  @data.each do |key, value|
    ENV[key] ||= value
  end
end
before_load() click to toggle source
# File lib/remotenv/adapters/base.rb, line 26
def before_load
end
get(key) click to toggle source
# File lib/remotenv/adapters/base.rb, line 49
def get(key)
  @data[key]
end
load() click to toggle source
# File lib/remotenv/adapters/base.rb, line 29
def load
  raise "Remotenv::Adapter::Base should not be used directly"
end
load!() click to toggle source
# File lib/remotenv/adapters/base.rb, line 17
def load!
  Remotenv.logger.debug("Adapter: #{self.class.name}")
  before_load
  load
  after_load
  apply_environment
  set_refresh_timestamp
end
set_refresh_timestamp() click to toggle source
# File lib/remotenv/adapters/base.rb, line 36
def set_refresh_timestamp
  ENV['REMOTENV_REFRESHED_AT'] = Time.now.to_s
end