Class: WSDL::Resolver::Source Private

Inherits:
Object
  • Object
show all
Defined in:
lib/wsdl/resolver/source.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Classifies WSDL and schema locations.

Supported location forms:

  • HTTP(S) URL
  • local file path (absolute or relative)

Constant Summary collapse

HTTP_URL_PATTERN =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Pattern for matching HTTP/HTTPS URLs.

/\Ahttps?:/i
FILE_URL_PATTERN =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Pattern for matching file:// URLs.

/\Afile:/i
INLINE_XML_PATTERN =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Pattern for matching inline XML content.

/\A\s*</
URI_SCHEME_PATTERN =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Pattern for matching URI schemes.

/\A[a-z][a-z0-9+\-.]*:/i
WINDOWS_DRIVE_PREFIX_PATTERN =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Pattern for matching Windows drive prefixes (e.g., C:foo or C:\foo).

/\A[A-Za-z]:/
WINDOWS_DRIVE_ABSOLUTE_PATTERN =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Pattern for matching absolute Windows drive paths (e.g., C:\path or C:/path).

%r{\A[A-Za-z]:[\\/]}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Source

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Source.

Parameters:

  • value (String)

    source location



69
70
71
# File 'lib/wsdl/resolver/source.rb', line 69

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueString (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


74
75
76
# File 'lib/wsdl/resolver/source.rb', line 74

def value
  @value
end

Class Method Details

.validate_wsdl!(value) ⇒ Source

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Validates a WSDL source input and returns a classified source.

Parameters:

  • value (Object)

    WSDL source input

Returns:

Raises:

  • (ArgumentError)

    when source is invalid



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/wsdl/resolver/source.rb', line 22

def validate_wsdl!(value)
  unless value.is_a?(String) && !value.empty?
    raise ArgumentError, 'WSDL source must be a non-empty String URL or file path'
  end

  source = new(value)

  if source.inline_xml?
    raise ArgumentError,
      'Inline XML WSDL is not supported. Provide an HTTP(S) URL or a local file path.'
  end

  if source.file_url?
    raise ArgumentError,
      "file:// URLs are not supported: #{value.inspect}. " \
      'Provide an HTTP(S) URL or a local file path.'
  end

  if source.unsupported_scheme?
    raise ArgumentError,
      "Unsupported URL scheme for WSDL source #{value.inspect}. " \
      'Only HTTP(S) URLs and local file paths are supported.'
  end

  source
end

Instance Method Details

#absolute_file_path?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


97
98
99
100
101
# File 'lib/wsdl/resolver/source.rb', line 97

def absolute_file_path?
  return false unless file_path?

  Pathname.new(@value).absolute? || windows_drive_absolute_path?
end

#default_sandbox_pathsArray<String>?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Array<String>, nil)


131
132
133
134
135
136
# File 'lib/wsdl/resolver/source.rb', line 131

def default_sandbox_paths
  return nil if url?
  return [sandbox_directory] if file_path?

  nil
end

#expanded_file_pathString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


114
115
116
# File 'lib/wsdl/resolver/source.rb', line 114

def expanded_file_path
  File.expand_path(@value)
end

#file_path?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


92
93
94
# File 'lib/wsdl/resolver/source.rb', line 92

def file_path?
  !url? && !inline_xml? && !scheme?
end

#file_url?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


82
83
84
# File 'lib/wsdl/resolver/source.rb', line 82

def file_url?
  @value.match?(FILE_URL_PATTERN)
end

#inline_xml?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


87
88
89
# File 'lib/wsdl/resolver/source.rb', line 87

def inline_xml?
  @value.match?(INLINE_XML_PATTERN)
end

#normalized_urlString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


124
125
126
127
128
# File 'lib/wsdl/resolver/source.rb', line 124

def normalized_url
  URI.parse(@value).normalize.to_s
rescue URI::InvalidURIError
  @value
end

#relative_file_path?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


104
105
106
# File 'lib/wsdl/resolver/source.rb', line 104

def relative_file_path?
  file_path? && !absolute_file_path?
end

#resolve_sandbox_paths(sandbox_paths) ⇒ Array<String>?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Resolves sandbox paths for this source.

When nil, falls back to #default_sandbox_paths which returns the WSDL's parent directory for file sources or nil for URLs.

Parameters:

  • sandbox_paths (Array<String>, nil)

    explicit paths, or nil to use defaults

Returns:

  • (Array<String>, nil)

    resolved sandbox paths



145
146
147
148
149
# File 'lib/wsdl/resolver/source.rb', line 145

def resolve_sandbox_paths(sandbox_paths)
  return sandbox_paths if sandbox_paths

  default_sandbox_paths
end

#sandbox_directoryString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


119
120
121
# File 'lib/wsdl/resolver/source.rb', line 119

def sandbox_directory
  File.dirname(expanded_file_path)
end

#unsupported_scheme?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


109
110
111
# File 'lib/wsdl/resolver/source.rb', line 109

def unsupported_scheme?
  scheme? && !url? && !file_url?
end

#url?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


77
78
79
# File 'lib/wsdl/resolver/source.rb', line 77

def url?
  @value.match?(HTTP_URL_PATTERN)
end