-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add ->has_encoding & ->is_encoded_content to files #263
base: main
Are you sure you want to change the base?
Conversation
The name "is_encoded_content" is a bit confusing - it sounds like it means "isn't decodable", but doesn't it really mean "has decodable content"? |
Not exactly. There's 2 ways to populate a File object. Either you give it bytes, or you give it characters. I'm open to suggestions for a better name. |
No, it looks like I think |
I'm not sure what you're talking about. Are you reading |
Yes, I was. Oops! Still, I suppose my original point was made... ENEEDMOREDOCS ;) |
As I said in the request, I'll write docs if @rjbs thinks the approach is acceptable. |
Maybe |
I have put this PR off because I've never felt good about the names, nor did I have any better ones to suggest. Now I suggest this: File will require:
An auto-detector of encodings can look for: if ($file->has_encoded_content && ! $file->has_content && ! $file->has_encoding) { ... } I will code that all up myself if you agree this is still useful and sane, @madsen. |
That seems like a viable approach to me. Looks like I'll finally get to release the SmartEncoding plugin I've been sitting on for 2 years 😕. Thanks. 😃 |
Can we get this into v6 before it leaves trial status? This sort of API change seems tailor-made for a major-version bump. |
9361f28
to
f825e3b
Compare
This is a followup to #254. In this version,
has_encoding
acts as a normal Moose predicate (except forFromCode
files, where it always returns true because the encoding attribute is read-only). The new methodis_encoded_content
indicates whether the "canonical" version isencoded_content
orcontent
.If you're happy with this, I'll write up some docs.
The idea is that an EncodingProvider can use
has_encoding
to determine whether it's possible to set the encoding, and then useis_encoded_content
to decide whether it can examine the file to determine an encoding.