diff --git a/src/oca/ruby/opennebula/document.rb b/src/oca/ruby/opennebula/document.rb index c57c1034a0..2f65834eb1 100644 --- a/src/oca/ruby/opennebula/document.rb +++ b/src/oca/ruby/opennebula/document.rb @@ -38,16 +38,16 @@ module OpenNebula ####################################################################### DOCUMENT_METHODS = { - :allocate => "document.allocate", - :delete => "document.delete", - :info => "document.info", - :update => "document.update", - :chown => "document.chown", - :chmod => "document.chmod", - :clone => "document.clone", - :rename => "document.rename", - :lock => "document.lock", - :unlock => "document.unlock" + :allocate => 'document.allocate', + :delete => 'document.delete', + :info => 'document.info', + :update => 'document.update', + :chown => 'document.chown', + :chmod => 'document.chmod', + :clone => 'document.clone', + :rename => 'document.rename', + :lock => 'document.lock', + :unlock => 'document.unlock' } # Creates a Document Object description with just its identifier @@ -55,14 +55,14 @@ module OpenNebula # @param [Integer] pe_id the id of the object # # @return [Nokogiri::XML::Node, REXML::Element] the empty xml - def Document.build_xml(pe_id=nil) + def self.build_xml(pe_id = nil) if pe_id obj_xml = "#{pe_id}" else - obj_xml = "" + obj_xml = '' end - XMLElement.build_xml(obj_xml,'DOCUMENT') + XMLElement.build_xml(obj_xml, 'DOCUMENT') end # Class constructor @@ -78,7 +78,7 @@ module OpenNebula def initialize(xml, client) LockableExt.make_lockable(self, DOCUMENT_METHODS) - super(xml,client) + super(xml, client) end ####################################################################### @@ -99,7 +99,7 @@ module OpenNebula return rc end - alias_method :info!, :info + alias info! info # Allocates a new Document in OpenNebula # @@ -111,14 +111,14 @@ module OpenNebula super(DOCUMENT_METHODS[:allocate], description, document_type) end - alias_method :allocate_xml, :allocate + alias allocate_xml allocate # Deletes the Document # # @return [nil, OpenNebula::Error] nil in case of success, Error # otherwise - def delete() - rc = check_type() + def delete + rc = check_type return rc if OpenNebula.is_error?(rc) return call(DOCUMENT_METHODS[:delete], @pe_id) @@ -132,8 +132,8 @@ module OpenNebula # # @return [nil, OpenNebula::Error] nil in case of success, Error # otherwise - def update(new_template, append=false) - rc = check_type() + def update(new_template, append = false) + rc = check_type return rc if OpenNebula.is_error?(rc) super(DOCUMENT_METHODS[:update], new_template, append ? 1 : 0) @@ -147,8 +147,8 @@ module OpenNebula # # @return [nil, OpenNebula::Error] nil in case of success, Error # otherwise - def update_raw(template_raw, append=false) - rc = check_type() + def update_raw(template_raw, append = false) + rc = check_type return rc if OpenNebula.is_error?(rc) return call(DOCUMENT_METHODS[:update], @pe_id, template_raw, append ? 1 : 0) @@ -162,7 +162,7 @@ module OpenNebula # @return [nil, OpenNebula::Error] nil in case of success, Error # otherwise def chown(uid, gid) - rc = check_type() + rc = check_type return rc if OpenNebula.is_error?(rc) super(DOCUMENT_METHODS[:chown], uid, gid) @@ -175,7 +175,7 @@ module OpenNebula # @return [nil, OpenNebula::Error] nil in case of success, Error # otherwise def chmod_octet(octet) - rc = check_type() + rc = check_type return rc if OpenNebula.is_error?(rc) super(DOCUMENT_METHODS[:chmod], octet) @@ -187,8 +187,8 @@ module OpenNebula # @return [nil, OpenNebula::Error] nil in case of success, Error # otherwise def chmod(owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, - other_m, other_a) - rc = check_type() + other_m, other_a) + rc = check_type return rc if OpenNebula.is_error?(rc) super(DOCUMENT_METHODS[:chmod], owner_u, owner_m, owner_a, group_u, @@ -202,10 +202,10 @@ module OpenNebula # @return [Integer, OpenNebula::Error] The new Document ID in case # of success, Error otherwise def clone(name) - rc = check_type() + rc = check_type return rc if OpenNebula.is_error?(rc) - return Error.new('ID not defined') if !@pe_id + return Error.new('ID not defined') unless @pe_id rc = @client.call(DOCUMENT_METHODS[:clone], @pe_id, name) @@ -241,7 +241,7 @@ module OpenNebula # Returns true if the GROUP_U permission bit is set # @return [true, false] true if the GROUP_U permission bit is set def public? - if self['PERMISSIONS/GROUP_U'] == "1" || self['PERMISSIONS/OTHER_U'] == "1" + if self['PERMISSIONS/GROUP_U'] == '1' || self['PERMISSIONS/OTHER_U'] == '1' true else false @@ -252,7 +252,7 @@ module OpenNebula self.class::DOCUMENT_TYPE end - private + private def set_publish(published) group_u = published ? 1 : 0 @@ -260,7 +260,7 @@ module OpenNebula chmod(-1, -1, -1, group_u, -1, -1, -1, -1, -1) end - def check_type() + def check_type type = self['TYPE'] if type.nil? && @pe_id @@ -276,10 +276,13 @@ module OpenNebula if !type.nil? && type.to_i != document_type return OpenNebula::Error.new( - "[DocumentInfo] Error getting document [#{@pe_id}].") + "[DocumentInfo] Error getting document [#{@pe_id}]." + ) end - return nil + return end + end + end diff --git a/src/oca/ruby/opennebula/document_pool.rb b/src/oca/ruby/opennebula/document_pool.rb index 223fda6cf8..786428cc00 100644 --- a/src/oca/ruby/opennebula/document_pool.rb +++ b/src/oca/ruby/opennebula/document_pool.rb @@ -41,7 +41,7 @@ module OpenNebula ####################################################################### DOCUMENT_POOL_METHODS = { - :info => "documentpool.info" + :info => 'documentpool.info' } ####################################################################### @@ -55,10 +55,10 @@ module OpenNebula # http://docs.opennebula.io/stable/integration/system_interfaces/api.html # # @return [DocumentPool] the new object - def initialize(client, user_id=-1) - super('DOCUMENT_POOL','DOCUMENT',client) + def initialize(client, user_id = -1) + super('DOCUMENT_POOL', 'DOCUMENT', client) - @user_id = user_id + @user_id = user_id end ####################################################################### @@ -99,4 +99,5 @@ module OpenNebula self.class::DOCUMENT_TYPE end end + end