Class: WeatherSage::CLI::Env::Context

Inherits:
WeatherSage::Context show all
Defined in:
lib/weather-sage/cli/env/context.rb

Overview

Create Context from environment variables.

Instance Attribute Summary

Attributes inherited from WeatherSage::Context

#log

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Context

Create Context from environment variables.

The following environment variables are supported:

  • WEATHER_SAGE_LOG_LEVEL: Log level. One of “fatal”, “error”, “warning”, “info”, or “debug”. Defaults to “warn”.

  • WEATHER_SAGE_LOG_PATH: Path to log file. Defaults to standard error.

  • WEATHER_SAGE_CACHE_PATH: Path to HTTP cache file. Defaults to “~/.config/weather-sage/http-cache.pstore”.



19
20
21
22
23
24
25
26
27
28
# File 'lib/weather-sage/cli/env/context.rb', line 19

def initialize(env)
  # create log from environment
  log = ::WeatherSage::CLI::Env::Log.new(env)

  # create cache from environment and log
  cache = ::WeatherSage::CLI::Env::Cache.new(env, log)

  # create context
  super(log, cache)
end