Class: SafeNet::SD
- Inherits:
-
Object
- Object
- SafeNet::SD
- Defined in:
- lib/safenet.rb
Instance Method Summary collapse
- #create(id, tag_type, contents) ⇒ Object
- #get(id, tag_type) ⇒ Object
-
#initialize(client_obj) ⇒ SD
constructor
A new instance of SD.
- #update(id, tag_type, contents) ⇒ Object
Constructor Details
#initialize(client_obj) ⇒ SD
Returns a new instance of SD.
572 573 574 |
# File 'lib/safenet.rb', line 572 def initialize(client_obj) @client = client_obj end |
Instance Method Details
#create(id, tag_type, contents) ⇒ Object
576 577 578 579 580 581 582 583 584 |
# File 'lib/safenet.rb', line 576 def create(id, tag_type, contents) version = 1 new_id = Digest::SHA2.new(512).hexdigest("#{id}#{tag_type}") res = @client.nfs.create_directory("/#{new_id}", is_private: false) == true res &&= @client.nfs.file("/#{new_id}/data.#{version}", is_private: false) == true res &&= @client.nfs.update_file_content("/#{new_id}/data.#{version}", contents) == true res &&= @client.dns.register_service("#{new_id}", "sd", "/#{new_id}") == true res end |
#get(id, tag_type) ⇒ Object
593 594 595 596 597 |
# File 'lib/safenet.rb', line 593 def get(id, tag_type) version = 1 new_id = Digest::SHA2.new(512).hexdigest("#{id}#{tag_type}") @client.dns.get_file_unauth("#{new_id}", "sd", "data.#{version}") end |
#update(id, tag_type, contents) ⇒ Object
586 587 588 589 590 591 |
# File 'lib/safenet.rb', line 586 def update(id, tag_type, contents) version = 1 new_id = Digest::SHA2.new(512).hexdigest("#{id}#{tag_type}") res = @client.nfs.update_file_content("/#{new_id}/data.#{version}", contents) == true res end |