<commit_before># frozen_string_literal: true

require 'yaml'
require 'date'
require_relative 'coffeeoutside/version'
require_relative 'coffeeoutside/locations'
require_relative 'coffeeoutside/weather'

# Dispatchers
require_relative 'coffeeoutside/dispatchers/json'
require_relative 'coffeeoutside/dispatchers/ical'
require_relative 'coffeeoutside/dispatchers/twitter'

module CoffeeOutside
  class Error < StandardError; end

  class Config
    attr_reader :dispatchers, :openweathermap

    def initialize(config_file = 'config.yaml')
      config = YAML.load_file(config_file)
      @production = config['production']
      @dispatchers = config['dispatchers']
      @openweathermap = config['openweathermap']
    end

    def production?
      @production
    end
  end

  def next_friday
    # TODO: this is gross...
    @next_friday ||= Date.today + [5, 4, 3, 2, 1, 7, 6][Date.today.wday]
  end

  def get_start_time
    DateTime.new(
      next_friday.year, next_friday.month, next_friday.day,
      7, 30, 0
    )
  end

  def get_end_time
    DateTime.new(
      next_friday.year, next_friday.month, next_friday.day,
      8, 30, 0
    )
  end

  def main
    config = Config.new
    if config.production?
      puts config.openweathermap
      owm = OWM.new config.openweathermap
      forecast = owm.get_forecast
    else
      forecast = Forecast.new(humidity: 0, temperature: 10)
    end

    destructive = config.production?
    location = LocationChooser.new(destructive, forecast).location
    puts "Chosen location is #{location}"

    dispatch = {
      start_time: get_start_time,
      end_time: get_end_time,
      forecast: forecast,
      location: location,
      production: config.production?
    }
    JsonDispatcher.new(dispatch).notify
    IcalDispatcher.new(dispatch).notify
    TwitterDispatcher.new(dispatch.merge(config.dispatchers['twitter'])).notify
  end
end<commit_msg>Stop printing OWM config to stdout<commit_after># frozen_string_literal: true

require 'yaml'
require 'date'
require_relative 'coffeeoutside/version'
require_relative 'coffeeoutside/locations'
require_relative 'coffeeoutside/weather'

# Dispatchers
require_relative 'coffeeoutside/dispatchers/json'
require_relative 'coffeeoutside/dispatchers/ical'
require_relative 'coffeeoutside/dispatchers/twitter'

module CoffeeOutside
  class Error < StandardError; end

  class Config
    attr_reader :dispatchers, :openweathermap

    def initialize(config_file = 'config.yaml')
      config = YAML.load_file(config_file)
      @production = config['production']
      @dispatchers = config['dispatchers']
      @openweathermap = config['openweathermap']
    end

    def production?
      @production
    end
  end

  def next_friday
    # TODO: this is gross...
    @next_friday ||= Date.today + [5, 4, 3, 2, 1, 7, 6][Date.today.wday]
  end

  def get_start_time
    DateTime.new(
      next_friday.year, next_friday.month, next_friday.day,
      7, 30, 0
    )
  end

  def get_end_time
    DateTime.new(
      next_friday.year, next_friday.month, next_friday.day,
      8, 30, 0
    )
  end

  def main
    config = Config.new
    if config.production?
      owm = OWM.new config.openweathermap
      forecast = owm.get_forecast
    else
      forecast = Forecast.new(humidity: 0, temperature: 10)
    end

    destructive = config.production?
    location = LocationChooser.new(destructive, forecast).location
    puts "Chosen location is #{location}"

    dispatch = {
      start_time: get_start_time,
      end_time: get_end_time,
      forecast: forecast,
      location: location,
      production: config.production?
    }
    JsonDispatcher.new(dispatch).notify
    IcalDispatcher.new(dispatch).notify
    TwitterDispatcher.new(dispatch.merge(config.dispatchers['twitter'])).notify
  end
end
{'fraction_non_alphanumeric': 0.09236842105263159, 'fraction_numerical': 0.009473684210526316, 'mean_word_length': 3.4560375146541618, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5272062', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1186, 'n_words': 262}