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

$:.unshift('.')
require 'lib/contributions'
require 'rugged'

gitconfig = Rugged::Config

contrib = Contributions.new(ARGV.first || gitconfig.global['github.user'] || 'akerl')

puts "Contribution data for #{contrib.user}:
    Today's score: #{contrib.today}
    Current streak: #{contrib.streak.length}
    High score: #{contrib.max.score} on #{contrib.max.date}"

<commit_msg>handle no rugged gracefully<commit_after>#!/usr/bin/env ruby

$:.unshift('.')
require 'lib/contributions'

names = [ARGV.first]
begin
    require 'rugged'
    names << Rugged::Config.global['github.user']
rescue LoadError
end
names << ENV['USER']

names.reject! {|name| name.nil? }
abort "No user provided" if names.empty?

contrib = Contributions.new names.first

puts "Contribution data for #{contrib.user}:
    Today's score: #{contrib.today}
    Current streak: #{contrib.streak.length}
    High score: #{contrib.max.score} on #{contrib.max.date}"


{'fraction_non_alphanumeric': 0.16252587991718426, 'fraction_numerical': 0.0, 'mean_word_length': 4.688235294117647, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2285020', 'n_tokens_mistral': 332, 'n_tokens_neox': 316, 'n_words': 77}