Use last instead of [-1]
This commit is contained in:
@@ -222,7 +222,7 @@ module Calligraphy
|
||||
def refresh_lock
|
||||
if locked?
|
||||
@store.transaction do
|
||||
@store[:lockdiscovery][-1][:timeout] = timeout_node
|
||||
@store[:lockdiscovery].last[:timeout] = timeout_node
|
||||
end
|
||||
|
||||
fetch_lock_info
|
||||
@@ -416,7 +416,8 @@ module Calligraphy
|
||||
end
|
||||
|
||||
def lockscope
|
||||
@lock_info[-1][:lockscope]
|
||||
@lock_info
|
||||
.last[:lockscope]
|
||||
.children
|
||||
.select { |x| x.is_a? Nokogiri::XML::Element }
|
||||
.last
|
||||
@@ -439,7 +440,7 @@ module Calligraphy
|
||||
|
||||
def locking_ancestor?(ancestor_path, ancestors, headers = nil)
|
||||
ancestor_info = ancestor_lock_info headers
|
||||
ancestor_store_path = "#{ancestor_path}/#{ancestors[-1]}.pstore"
|
||||
ancestor_store_path = "#{ancestor_path}/#{ancestors.last}.pstore"
|
||||
|
||||
ancestors.pop
|
||||
|
||||
@@ -669,7 +670,7 @@ module Calligraphy
|
||||
end
|
||||
|
||||
def refresh_ancestor_locks(ancestor_path, ancestors)
|
||||
ancestor_store_path = "#{ancestor_path}/#{ancestors[-1]}.pstore"
|
||||
ancestor_store_path = "#{ancestor_path}/#{ancestors.last}.pstore"
|
||||
ancestors.pop
|
||||
|
||||
if File.exist? ancestor_store_path
|
||||
@@ -686,7 +687,7 @@ module Calligraphy
|
||||
ancestor_store = PStore.new ancestor_store_path
|
||||
|
||||
ancestor_store.transaction do
|
||||
ancestor_store[:lockdiscovery][-1][:timeout] = timeout_node
|
||||
ancestor_store[:lockdiscovery].last[:timeout] = timeout_node
|
||||
ancestor_store[:lockdiscovery]&.map do |lock_info|
|
||||
lock_info.transform_values do |xml_fragment|
|
||||
parse_serialized_fragment xml_fragment
|
||||
|
||||
@@ -16,7 +16,7 @@ module Calligraphy
|
||||
@full_request_path = req&.original_url
|
||||
@mount_point = mount || req&.path&.tap { |s| s.slice! resource }
|
||||
@request_body = req&.body&.read || ''
|
||||
@request_path = mount.nil? ? resource : resource.split(mount)[-1]
|
||||
@request_path = mount.nil? ? resource : resource.split(mount).last
|
||||
@root_dir = root_dir
|
||||
end
|
||||
|
||||
|
||||
@@ -32,11 +32,11 @@ module Calligraphy
|
||||
end
|
||||
|
||||
def destination_header
|
||||
@headers['Destination'].split(@headers['Host'])[-1]
|
||||
@headers['Destination'].split(@headers['Host']).last
|
||||
end
|
||||
|
||||
def remove_trailing_slash(input)
|
||||
input[-1] == '/' ? input[0..-2] : input
|
||||
input.last == '/' ? input[0..-2] : input
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -69,7 +69,8 @@ module Calligraphy
|
||||
end
|
||||
|
||||
def extract_lock_token(properties)
|
||||
properties[-1]
|
||||
properties
|
||||
.last
|
||||
.select { |x| x.name == 'locktoken' }[0]
|
||||
.children
|
||||
.text
|
||||
|
||||
@@ -7,6 +7,8 @@ module Calligraphy
|
||||
|
||||
# Executes the WebDAV request for a particular resource.
|
||||
def execute
|
||||
# The `propfind` tag contains the properties to retrieve for a
|
||||
# particular resource.
|
||||
xml = xml_for body: body, node: 'propfind'
|
||||
return :bad_request if xml == :bad_request
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ module Calligraphy
|
||||
xml_str = fragment.is_a?(Array) ? fragment.join : fragment
|
||||
|
||||
xml = Nokogiri::XML.fragment(xml_str).children
|
||||
fragment.is_a?(Array) ? xml : xml[-1]
|
||||
fragment.is_a?(Array) ? xml : xml.last
|
||||
end
|
||||
|
||||
# Iterates through each property in `properties` hash and deserializes
|
||||
|
||||
@@ -20,9 +20,9 @@ module Calligraphy
|
||||
def lock_response(activelock_properties)
|
||||
build :prop do |xml|
|
||||
xml.lockdiscovery do
|
||||
activelock_properties.each do |properties|
|
||||
activelock_properties.each do |property_set|
|
||||
xml.activelock do
|
||||
iterate_and_drilldown xml, properties
|
||||
iterate_and_drilldown xml, property_set
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user