add more documentation

This commit is contained in:
Benjamin Neff 2015-12-13 01:22:17 +01:00
parent e9c299f993
commit 73fab4d01c
6 changed files with 20 additions and 8 deletions

View file

@ -33,7 +33,6 @@ module DiasporaFederation
# {Callbacks} instance with defined callbacks # {Callbacks} instance with defined callbacks
# @see Callbacks#on # @see Callbacks#on
# @see Callbacks#trigger # @see Callbacks#trigger
#
attr_reader :callbacks attr_reader :callbacks
# the pod url # the pod url
@ -122,6 +121,7 @@ module DiasporaFederation
# @param [String] guid of the entity # @param [String] guid of the entity
# @return [String] Diaspora ID of the person # @return [String] Diaspora ID of the person
# #
# @see Callbacks#on
# #
# @example # @example
# config.define_callbacks do # config.define_callbacks do

View file

@ -1,6 +1,6 @@
module DiasporaFederation module DiasporaFederation
module Entities module Entities
# this entity represents a claim of deletion of a previously federated # this entity represents a claim of deletion of a previously federated entity
# #
# @see Validators::RetractionValidator # @see Validators::RetractionValidator
class Retraction < Entity class Retraction < Entity

View file

@ -25,9 +25,17 @@ module DiasporaFederation
# author_pubkey = however_you_retrieve_the_authors_public_key(slap.author_id) # author_pubkey = however_you_retrieve_the_authors_public_key(slap.author_id)
# #
# entity = slap.entity(author_pubkey) # entity = slap.entity(author_pubkey)
#
class Slap class Slap
attr_accessor :author_id, :magic_envelope, :cipher_params # the author of the slap
# @overload author_id
# @return [String] the author diaspora id
# @overload author_id=
# @param [String] the author diaspora id
attr_accessor :author_id
# the key and iv if it is an encrypted slap
# @param [Hash] value hash containing the key and iv
attr_writer :cipher_params
# Namespaces # Namespaces
NS = {d: Salmon::XMLNS, me: MagicEnvelope::XMLNS} NS = {d: Salmon::XMLNS, me: MagicEnvelope::XMLNS}
@ -47,7 +55,7 @@ module DiasporaFederation
return @entity unless @entity.nil? return @entity unless @entity.nil?
raise ArgumentError unless pubkey.instance_of?(OpenSSL::PKey::RSA) raise ArgumentError unless pubkey.instance_of?(OpenSSL::PKey::RSA)
@entity = MagicEnvelope.unenvelop(magic_envelope, pubkey, @cipher_params) @entity = MagicEnvelope.unenvelop(@magic_envelope, pubkey, @cipher_params)
@entity @entity
end end

View file

@ -3,8 +3,9 @@ module DiasporaFederation
# This is included to validatros which validate entities which include {Entities::Relayable} # This is included to validatros which validate entities which include {Entities::Relayable}
module RelayableValidator module RelayableValidator
# when this module is included in a Validator child it adds rules for relayable validation # when this module is included in a Validator child it adds rules for relayable validation
def self.included(model) # @param [Validation::Validator] validator the validator in which it is included
model.class_eval do def self.included(validator)
validator.class_eval do
rule :parent_guid, :guid rule :parent_guid, :guid
end end
end end

View file

@ -3,8 +3,11 @@ module Validation
# Rule for validating the number of Diaspora* ids in a string. # Rule for validating the number of Diaspora* ids in a string.
# The evaluated string is split at ";" and the result will be counted. # The evaluated string is split at ";" and the result will be counted.
class DiasporaIdCount class DiasporaIdCount
# This rule must have a +maximum+ param
# @return [Hash] params
attr_reader :params attr_reader :params
# create a new rule for a maximum diaspora id count validation
# @param [Hash] params # @param [Hash] params
# @option params [Fixnum] :maximum maximum allowed id count # @option params [Fixnum] :maximum maximum allowed id count
def initialize(params) def initialize(params)

View file

@ -118,7 +118,7 @@ XML
subject { Salmon::EncryptedSlap.from_xml(slap_xml, okey) } subject { Salmon::EncryptedSlap.from_xml(slap_xml, okey) }
it "should have cipher params set" do it "should have cipher params set" do
expect(subject.cipher_params).to_not be_nil expect(subject.instance_variable_get(:@cipher_params)).to_not be_nil
end end
it_behaves_like "a Slap instance" it_behaves_like "a Slap instance"