1
0
mirror of https://github.com/danog/gift.git synced 2025-01-21 21:41:13 +01:00

add Actor#hash

This commit is contained in:
sentientwaffle 2012-02-16 19:26:24 -07:00
parent 5486623300
commit ce62b82899
2 changed files with 11 additions and 0 deletions

View File

@ -1,5 +1,9 @@
crypto = require 'crypto'
module.exports = class Actor
constructor: (@name, @email) ->
if email
@hash = crypto.createHash("md5").update(@email, "ascii").digest("hex")
# Public: Get a string representation of the Actor.
toString: ->

View File

@ -18,6 +18,13 @@ describe "Actor", ->
actor.toString().should.eql "bob <bob@example.com>"
describe "#hash", ->
actor = new Actor "bob", "bob@example.com"
it "is the md5 hash of the email", ->
actor.hash.should.eql "4b9bb80620f03eb3719e0a061c14283d"
describe ".from_string", ->
describe "with a name and email", ->
actor = Actor.from_string "bob <bob@example.com>"