<commit_before>use v6;

use Net::Curl;

class Net::Curl::Easy {
	has $.url;
	
	method download {
	
		my $curl = curl_easy_init;
		my $body = Buf.new; # or use Str

		if $curl {
			curl_easy_setopt($curl, CURLOPT_URL, $.url);
			curl_easy_setopt($curl, CURLOPT_WRITEDATA, $body);
			curl_easy_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);
	 
				# Perform the request, res will get the return code
			my $res = curl_easy_perform($curl);

			# Check for errors
			if $res != CURLE_OK {
				say "Error: curl_easy_perform() failed: " ~ 
				curl_easy_strerror($res);
			}

			# always cleanup 
			curl_easy_cleanup($curl);
		}

		return $body.decode('latin1');
	}
}

# vim: ft=perl6
<commit_msg>Convert to unit class for consistency<commit_after>use v6;

use Net::Curl;

unit class Net::Curl::Easy;

has $.url;

method download {

	my $curl = curl_easy_init;
	my $body = Buf.new; # or use Str

	if $curl {
		curl_easy_setopt($curl, CURLOPT_URL, $.url);
		curl_easy_setopt($curl, CURLOPT_WRITEDATA, $body);
		curl_easy_setopt($curl, CURLOPT_FOLLOWLOCATION, 0);

			# Perform the request, res will get the return code
		my $res = curl_easy_perform($curl);

		# Check for errors
		if $res != CURLE_OK {
			say "Error: curl_easy_perform() failed: " ~
			curl_easy_strerror($res);
		}

		# always cleanup
		curl_easy_cleanup($curl);
	}

	return $body.decode('latin1');
}

# vim: ft=perl6

{'fraction_non_alphanumeric': 0.13018181818181818, 'fraction_numerical': 0.005818181818181818, 'mean_word_length': 3.879432624113475, 'pattern_counts': {'":': 0, '<': 3, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6233163', 'n_tokens_mistral': 646, 'n_tokens_neox': 517, 'n_words': 126}