add ->has_encoding & ->is_encoded_content to files - #263
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
40e530a to
370397c
Compare
This is a followup to #254. In this version,
has_encodingacts as a normal Moose predicate (except forFromCodefiles, where it always returns true because the encoding attribute is read-only). The new methodis_encoded_contentindicates whether the "canonical" version isencoded_contentorcontent.If you're happy with this, I'll write up some docs.
The idea is that an EncodingProvider can use
has_encodingto determine whether it's possible to set the encoding, and then useis_encoded_contentto decide whether it can examine the file to determine an encoding.