<commit_before>#!/usr/bin/env ruby

# Name: driver.rb
# Description: Send ride summary to Citi Bike User.
# Author: <NAME>
# Updated: 4/15/14
# License: MIT

require_relative 'bike_trip'
require_relative 'citi_scraper'
require_relative 'notify'

LOGIN_SUCCESS = 'Welcome To Citi Bike!'
CITIBIKE_CONFIG = YAML.load_file(File.join(__dir__, 'config.yml'))
SLEEP_DURATION = 300 # in seconds

user = CitiScraper.new
username = CITIBIKE_CONFIG['citibike_username']
password = CITIBIKE_CONFIG['citibike_password']

unless user.login(username, password) == LOGIN_SUCCESS
  fail 'Incorrect username or password'
end

puts 'Successfully logged in to Citi Bike website'

loop do
  trip = user.trips.first
  unless trip
    user.login(username, password)
    trip = user.trips.first
  end

  # check if ride completed in last SLEEP_DURATION secs
  if (DateTime.now.to_time.to_i - trip.end_time.to_time.to_i) < SLEEP_DURATION
    puts 'Recent trip found!'
    notify_me
  else
    puts 'No recent trip found.'
  end

  puts "Sleeping for #{SLEEP_DURATION} seconds"<commit_msg>Redirect stdout and stderr to log files<commit_after>#!/usr/bin/env ruby

# Name: driver.rb
# Description: Send ride summary to Citi Bike User.
# Author: <NAME>
# Updated: 4/15/14
# License: MIT

require_relative 'bike_trip'
require_relative 'citi_scraper'
require_relative 'notify'

$stdout.reopen('out.log', 'w')
$stderr.reopen('err.log', 'w')

LOGIN_SUCCESS = 'Welcome To Citi Bike!'
CITIBIKE_CONFIG = YAML.load_file(File.join(__dir__, 'config.yml'))
SLEEP_DURATION = 300 # in seconds

user = CitiScraper.new
username = CITIBIKE_CONFIG['citibike_username']
password = <PASSWORD>KE_CONFIG['<PASSWORD>']

unless user.login(username, password) == LOGIN_SUCCESS
  fail 'Incorrect username or password'
end

puts 'Successfully logged in to Citi Bike website'

loop do
  print "#{DateTime.now}: "
  trip = user.trips.first
  unless trip
    user.login(username, password)
    trip = user.trips.first
  end

  # check if ride completed in last SLEEP_DURATION secs
  if (DateTime.now.to_time.to_i - trip.end_time.to_time.to_i) < SLEEP_DURATION
    print 'Recent trip found! '
    notify_me
  else
    print 'No recent trip found. '
  end

  puts "Sleeping for #{SLEEP_DURATION} seconds"
{'fraction_non_alphanumeric': 0.10383244206773619, 'fraction_numerical': 0.0071301247771836, 'mean_word_length': 4.58457711442786, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '1809363', 'n_tokens_mistral': 835, 'n_tokens_neox': 795, 'n_words': 211}