Module: CoffeeOutside

Defined in:
lib/coffeeoutside.rb,
lib/coffeeoutside/version.rb,
lib/coffeeoutside/weather.rb,
lib/coffeeoutside/locations.rb,
lib/coffeeoutside/event_time.rb,
lib/coffeeoutside/dispatchers/rss.rb,
lib/coffeeoutside/dispatchers/ical.rb,
lib/coffeeoutside/dispatchers/json.rb,
lib/coffeeoutside/dispatchers/stdout.rb,
lib/coffeeoutside/dispatchers/dispatcher.rb

Defined Under Namespace

Modules: EventTime Classes: Config, DispatcherBase, Error, Forecast, IcalDispatcher, JsonDispatcher, Location, LocationChooser, LocationFile, OWM, OverrideFile, PriorLocationsFile, RssDispatcher, StdoutDispatcher

Constant Summary collapse

VERSION =
"1.0.0"
HUMIDITY_LIMIT =
75

Instance Method Summary collapse

Instance Method Details

#mainObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/coffeeoutside.rb', line 33

def main
  config = Config.new
  if config.production?
    owm = OWM.new config.openweathermap, EventTime.start_time
    forecast = owm.forecast
  else
    # stub a forecast in since OWM is rate-limited
    forecast = Forecast.new(humidity: 0, temperature: 10)
  end

  location = LocationChooser.new(forecast, destructive: config.production?).location

  dispatch = {
    start_time: EventTime.start_time,
    end_time: EventTime.end_time,
    forecast: forecast,
    location: location,
    production: config.production?
  }
  StdoutDispatcher.new(dispatch).notify
  JsonDispatcher.new(dispatch).notify
  RssDispatcher.new(dispatch).notify
  IcalDispatcher.new(dispatch).notify
end