Skip Menu |

This queue is for tickets about the MooseX-Types-Digest CPAN distribution.

Report information
The Basics
Id: 50850
Status: resolved
Priority: 0/
Queue: MooseX-Types-Digest

People
Owner: Nobody in particular
Requestors: stevan.little [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Patch to support more SHA formats
Michael, Thanks for uploading this module to CPAN, it is very helpful to me on my current project. I have enclosed a patch to add support for the other SHA formats (224, 256, 384 and 512) and tests for those. If you have a public repository (github or something) I would be happy to apply the patch there if that would be easier. Also, would you be interested in adding support for coercions? It should be pretty simple to coerce from a Str type. I could also supply a patch for this as well, just let me know. Thanks, - Stevan Little
Subject: mx-types-digest.patch
diff -r MooseX-Types-Digest-0.01-orig/lib/MooseX/Types/Digest.pm MooseX-Types-Digest-0.01/lib/MooseX/Types/Digest.pm 21c21 < --- > 40c40 < use MooseX::Types -declare => [qw/ MD5 SHA1 /]; --- > use MooseX::Types -declare => [qw/ MD5 SHA1 SHA224 SHA256 SHA384 SHA512 /]; 52a53,72 > subtype SHA224, > as "Str", > where { (m/^[0-9a-f]{56}$/i) }, > message {"Must be 56 chars, and contain only [0-9a-f]" }; > > subtype SHA256, > as "Str", > where { (m/^[0-9a-f]{64}$/i) }, > message {"Must be 64 chars, and contain only [0-9a-f]" }; > > subtype SHA384, > as "Str", > where { (m/^[0-9a-f]{96}$/i) }, > message {"Must be 96 chars, and contain only [0-9a-f]" }; > > subtype SHA512, > as "Str", > where { (m/^[0-9a-f]{128}$/i) }, > message {"Must be 128 chars, and contain only [0-9a-f]" }; > diff -r MooseX-Types-Digest-0.01-orig/t/01-digest.t MooseX-Types-Digest-0.01/t/01-digest.t 1c1 < use Test::More tests => 2*7; --- > use Test::More tests => 6*8; 8,11c8,15 < use MooseX::Types::Digest qw( MD5 SHA1 ); < < has md5 => ( is => 'rw', isa => MD5 ); < has sha1 => ( is => 'rw', isa => SHA1 ); --- > use MooseX::Types::Digest qw( MD5 SHA1 SHA224 SHA256 SHA384 SHA512 ); > > has md5 => ( is => 'rw', isa => MD5 ); > has sha1 => ( is => 'rw', isa => SHA1 ); > has sha224 => ( is => 'rw', isa => SHA224 ); > has sha256 => ( is => 'rw', isa => SHA256 ); > has sha384 => ( is => 'rw', isa => SHA384 ); > has sha512 => ( is => 'rw', isa => SHA512 ); 23c27,28 < '3a59124cfcc7ce26274174c962094a20000' --- > '3a59124cfcc7ce26274174c962094a200ab', > '3a59124cfcc7ce26274174c96209' 34c39,40 < '1dff4026f8d3449cc83980e0e6d6cec075303ae333' --- > '1dff4026f8d3449cc83980e0e6d6cec075303ae333', > '1dff4026f8d3449cc83980e0e6d6cec07533' 36c42,90 < } --- > }, > SHA224 => { > ok => [ > '906bbee30415aab29f8309b829b521bb4275de9a302b37480ab129e9', > 'df9e8421b7a93a4e91a54918efa9eab6d1a14772760649ff8f574eda' > ], > fail => [ > 'df9e8421b7a93a4e91a54918efa9eab6d1a14772760649ff8f574edx', > 'df9e8421b7a93a4e91a54918efa9eab6d1a14772760649ff8f574ed-', > '1dff4026f8d3449cc83980e0e6d6cec075303ae333', > 'df9e8421b7a93a4e91a54918efa9eab6d1a14772760649ff8f574edaabdc' > ] > }, > SHA256 => { > ok => [ > '718d54b2f9f41ef058c45f5bd0fec9730e40661f0c4dc256fb7f16b901fb1317', > '787ec76dcafd20c1908eb0936a12f91edd105ab5cd7ecc2b1ae2032648345dff' > ], > fail => [ > '718d54b2f9f41ef058c45f5bd0fec9730e40661f0c4dc256fb7f16b901fb131x', > '718d54b2f9f41ef058c45f5bd0fec9730e40661f0c4dc256fb7f16b901fb131-', > '718d54b2f9f41ef058c45f5bd0fec9730e40661f0c4dc2', > '718d54b2f9f41ef058c45f5bd0fec9730e40661f0c4dc256fb7f16b901fb13179999999' > ] > }, > SHA384 => { > ok => [ > 'd3e23b4f16ea11c71aba0d23ba04a5625482a33bdcc69e63e2b86122470d22cf906bdbbcb204e73ec1338c8508bb2e2a', > 'd601486016cb1550e607e8d9b78c7a4b9afb5f96572a28f497960d3fbd31de0ffc3012ce875f84db8e1a32928a9f66cb' > ], > fail => [ > 'd601486016cb1550e607e8d9b78c7a4b9afb5f96572a28f497960d3fbd31de0ffc3012ce875f84db8e1a32928a9f66cx', > 'd601486016cb1550e607e8d9b78c7a4b9afb5f96572a28f497960d3fbd31de0ffc3012ce875f84db8e1a32928a9f66c-', > '718d54b2f9f41ef058c45f5bd0fec9730e40661f0c4dc2', > 'd601486016cb1550e607e8d9b78c7a4b9afb5f96572a28f497960d3fbd31de0ffc3012ce875f84db8e1a32928a9f66cbabc398' > ] > }, > SHA512 => { > ok => [ > 'f5a1114e161b25c70469124edce3dc800a929aaca4d2640cdb66afdeb0225e118f773434beb2d5eba908a0c2a8ab5843362c382eaaa5eb5233a24398df6d2a69', > '13d6c73ac8cceeff9ff6b0ba2ce19c5fc47ac21f9fd403c151fe88e0fd39f4223c29bc9bded59e1e3f272fd969fd6e2e6e35be35072e742c4b36fec48feb87df' > ], > fail => [ > '13d6c73ac8cceeff9ff6b0ba2ce19c5fc47ac21f9fd403c151fe88e0fd39f4223c29bc9bded59e1e3f272fd969fd6e2e6e35be35072e742c4b36fec48feb87dx', > '13d6c73ac8cceeff9ff6b0ba2ce19c5fc47ac21f9fd403c151fe88e0fd39f4223c29bc9bded59e1e3f272fd969fd6e2e6e35be35072e742c4b36fec48feb87d-', > '13d6c73ac8cceeff9ff6b0ba2ce19c5fc47ac21f9fd403c151fe88e0fd39f4223c29bc9bded59e1e3f27', > '13d6c73ac8cceeff9ff6b0ba2ce19c5fc47ac21f9fd403c151fe88e0fd39f4223c29bc9bded59e1e3f272fd969fd6e2e6e35be35072e742c4b36fec48feb87dfabcdef' > ] > },
Thanks for your patch! I created an google code project at http://code.google.com/p/moosex-types-digest/ Show quoted text
> Also, would you be interested in adding support for coercions? It > should be pretty simple to coerce from a Str type. I could also > supply a patch for this as well, just let me know.
ok, just check it in. i'll send you a password.
release 0.03 is on cpan, now!
Michael, Excellent, much thanks. - Stevan