Class: Nora::Core
Constant Summary collapse
- PAIRINGS_FILE =
"past_pairings.txt"
- PAIRINGS_FILE_SEPARATOR =
" "
- OOB_URI =
"urn:ietf:wg:oauth:2.0:oob"
- CLIENT_SECRETS_PATH =
"nora_client_secret.json"
- CREDENTIALS_PATH =
"calendar-ruby-quickstart.yaml"
- SCOPE =
Google::Apis::CalendarV3::AUTH_CALENDAR
- FREE_BUSY_QUERY_BATCH_SIZE =
5
- CONFIGURATION =
JSON.parse(File.read("nora_configuration.json"))
Instance Method Summary collapse
-
#initialize(weeks_ahead:, test:) ⇒ Core
constructor
A new instance of Core.
- #run! ⇒ Object
Constructor Details
#initialize(weeks_ahead:, test:) ⇒ Core
Returns a new instance of Core.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/nora/core.rb', line 48 def initialize(weeks_ahead:, test:) @weeks_ahead = weeks_ahead @test = test FileUtils.touch(PAIRINGS_FILE) # Make sure pairings file exists. # Set global Chronic parsing time zone. Time.zone = "UTC" Chronic.time_class = Time.zone # Initialize the API @service = Google::Apis::CalendarV3::CalendarService.new @service..application_name = CONFIGURATION["calendar"]["application_name"] @service. = end |
Instance Method Details
#run! ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/nora/core.rb', line 65 def run! load_history! # Populate @history for load_calendars! load_calendars! # Outside the loop to reduce calls to Google API. begin shuffle_emails! create_groups! rescue SystemStackError remove_oldest_pair! retry end send_emails( template_emails_for( schedule_meetings! ) ) puts "Done." end |