Class: WSDL::Source Private

Inherits:
Object
  • Object
show all
Defined in:
lib/wsdl/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



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

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)


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

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



21
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
# File 'lib/wsdl/source.rb', line 21

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)


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

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)


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

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)


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

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)


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

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)


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

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)


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

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)


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

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)


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

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



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

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)


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

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)


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

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)


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

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