lib/pdk/report/event.rb
def sanitise_file(value)
        if value.nil? || (value.is_a?(String) && value.empty?)
          raise ArgumentError, _('File not specified.')
        end

        unless value.is_a?(String)
          raise ArgumentError, _('File must be a String.')
        end

        path = Pathname.new(value)

        if path.absolute?
          module_root = Pathname.new(PDK::Util.module_root)
          path = path.relative_path_from(module_root).to_path
          path << '/' if path == '.'
          path
        else
          path.to_path
        end
      end
# Munges and validates the file path used to instantiate the event.
#
# If the path is an absolute path, it will be rewritten so that it is
# relative to the module root instead.
#
# @param value [String] The path to the file that the event is
#   describing.
#
# @return [String] The path to the file, relative to the module root.
#
# @raise [ArgumentError] if the value is nil, an empty String, or not
#   a String.
Munges and validates the file path used to instantiate the event.
If the path is an absolute path, it will be rewritten so that it is
relative to the module root instead.
Munges and validates the file path used to instantiate the event . If the path is an absolute path it will be rewritten so that it is relative to the module root instead .
def sanitise_file(value)
        if value.nil? || (value.is_a?(String) && value.empty?)
          raise ArgumentError, _('File not specified.')
        end
        unless value.is_a?(String)
          raise ArgumentError, _('File must be a String.')
        end
        path = Pathname.new(value)
        if path.absolute?
          module_root = Pathname.new(PDK::Util.module_root)
          path = path.relative_path_from(module_root).to_path
          path << '/' if path == '.'
          path
        else
          path.to_path
        end
      end
def sanitise_file ( value ) if value . nil? || ( value . is_a? ( String ) && value . empty? ) raise ArgumentError , _ ( 'File not specified.' ) end unless value . is_a? ( String ) raise ArgumentError , _ ( 'File must be a String.' ) end path = Pathname . new ( value ) if path . absolute? module_root = Pathname . new ( PDK :: Util . module_root ) path = path . relative_path_from ( module_root ) . to_path path << '/' if path == '.' path else path . to_path end end
Munges and validates the file path used to instantiate the event.
Munges and validates the file path used to instantiate the event .
The path to the file, relative to the module root.
The path to the file relative to the module root .
String
[ArgumentError] if the value is nil, an empty String, or not a String.
[ ArgumentError ] if the value is nil an empty String or not a String .
value
The path to the file that the event is describing.
The path to the file that the event is describing .