Class: Noteshred::Note
- Inherits:
-
Object
- Object
- Noteshred::Note
- Defined in:
- lib/noteshred/note.rb
Constant Summary collapse
- SHRED_AFTER_READING =
Shred Methods
1
- SHRED_LATER =
2
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#encrypted_content ⇒ Object
Returns the value of attribute encrypted_content.
-
#encrypted_content_iv ⇒ Object
Returns the value of attribute encrypted_content_iv.
-
#encrypted_content_salt ⇒ Object
Returns the value of attribute encrypted_content_salt.
-
#hint ⇒ Object
Returns the value of attribute hint.
-
#password ⇒ Object
Returns the value of attribute password.
-
#password_hash ⇒ Object
Returns the value of attribute password_hash.
-
#recipients ⇒ Object
Returns the value of attribute recipients.
-
#shred_by ⇒ Object
Returns the value of attribute shred_by.
-
#shred_method ⇒ Object
Returns the value of attribute shred_method.
-
#title ⇒ Object
Returns the value of attribute title.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
4 5 6 |
# File 'lib/noteshred/note.rb', line 4 def content @content end |
#encrypted_content ⇒ Object
Returns the value of attribute encrypted_content.
4 5 6 |
# File 'lib/noteshred/note.rb', line 4 def encrypted_content @encrypted_content end |
#encrypted_content_iv ⇒ Object
Returns the value of attribute encrypted_content_iv.
4 5 6 |
# File 'lib/noteshred/note.rb', line 4 def encrypted_content_iv @encrypted_content_iv end |
#encrypted_content_salt ⇒ Object
Returns the value of attribute encrypted_content_salt.
4 5 6 |
# File 'lib/noteshred/note.rb', line 4 def encrypted_content_salt @encrypted_content_salt end |
#hint ⇒ Object
Returns the value of attribute hint.
4 5 6 |
# File 'lib/noteshred/note.rb', line 4 def hint @hint end |
#password ⇒ Object
Returns the value of attribute password.
4 5 6 |
# File 'lib/noteshred/note.rb', line 4 def password @password end |
#password_hash ⇒ Object
Returns the value of attribute password_hash.
4 5 6 |
# File 'lib/noteshred/note.rb', line 4 def password_hash @password_hash end |
#recipients ⇒ Object
Returns the value of attribute recipients.
4 5 6 |
# File 'lib/noteshred/note.rb', line 4 def recipients @recipients end |
#shred_by ⇒ Object
Returns the value of attribute shred_by.
4 5 6 |
# File 'lib/noteshred/note.rb', line 4 def shred_by @shred_by end |
#shred_method ⇒ Object
Returns the value of attribute shred_method.
4 5 6 |
# File 'lib/noteshred/note.rb', line 4 def shred_method @shred_method end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/noteshred/note.rb', line 4 def title @title end |
#version ⇒ Object
Returns the value of attribute version.
4 5 6 |
# File 'lib/noteshred/note.rb', line 4 def version @version end |
Class Method Details
.share(token, recipients, comments) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/noteshred/note.rb', line 70 def self.share(token,recipients,comments) # Receive comma seperated list of recipients if recipients.nil? raise ArgumentError.new('Recipients are required') end if token.nil? raise ArgumentError.new('Token is required') end Noteshred::API.post("/notes/#{token}/share", {:dest_email => recipients, :comments => comments}) end |
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 |
# File 'lib/noteshred/note.rb', line 21 def create # For creating notes that are encrypted on the server validate_content Noteshred::API.post('/notes', Noteshred::Tools.hashify(self)) end |
#decrypt ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/noteshred/note.rb', line 60 def decrypt validate_encrypted_content self.content = Noteshred::Crypto::V4.decrypt(self.encrypted_content, self.password, self.encrypted_content_salt, self.encrypted_content_iv) self.encrypted_content_iv = nil self.encrypted_content_salt = nil self.encrypted_content = nil self.password_hash = nil return self end |
#encrypt ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/noteshred/note.rb', line 47 def encrypt validate_content crypt = Noteshred::Crypto::V4.encrypt(self.content, self.password) self.encrypted_content = crypt[:content] self.encrypted_content_iv = crypt[:iv] self.encrypted_content_salt = crypt[:salt] self.version = crypt[:version] self.password_hash = BCrypt::Password.create(self.password) self.content = nil self.password = nil return self end |
#pull(token, pass) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/noteshred/note.rb', line 38 def pull(token,pass) # For pulling raw encrypted notes from the server # TODO: Implement server side portion if token.nil? || password.nil? raise ArgumentError.new('token and password params are required') end Noteshred::API.get('/notes/pull', {:password => pass, :token => token}) end |
#push ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/noteshred/note.rb', line 28 def push # For creating notes that are encrypted by the gem first then pushed to the server if self.encrypted_content_salt.nil? || encrypted_content_iv.nil? raise ArgumentError.new('No encrypted content found. Must call .encrypt before pushing') end Noteshred::API.post('/notes/push', Noteshred::Tools.hashify(self)) end |