Class: Flutter::Pub::ExternalSources::DownloaderSource

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-embed-flutter/flutter/external_sources.rb

Overview

Note:

The pubspec must be in the root of the repository or in directory with the name provided

Provides support for fetching a specification file from a source handled by the downloader. Supports all the options of the downloader

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, params, podfile_path, can_cache = true) ⇒ DownloaderSource

Initialize a new instance

Parameters:

  • name (String)

    @see #name

  • params (Hash)

    @see #params

  • podfile_path (String)

    @see #podfile_path

  • can_cache (Boolean) (defaults to: true)

    @see #can_cache



87
88
89
90
91
92
# File 'lib/cocoapods-embed-flutter/flutter/external_sources.rb', line 87

def initialize(name, params, podfile_path, can_cache = true)
  @name = name
  @params = params
  @podfile_path = podfile_path
  @can_cache = can_cache
end

Instance Attribute Details

#can_cacheBoolean (readonly) Also known as: can_cache?

Returns Whether the source is allowed to touch the cache.

Returns:

  • (Boolean)

    Whether the source is allowed to touch the cache.



77
78
79
# File 'lib/cocoapods-embed-flutter/flutter/external_sources.rb', line 77

def can_cache
  @can_cache
end

#nameString (readonly)

Returns the name of the Package described by this external source.

Returns:

  • (String)

    the name of the Package described by this external source.



63
64
65
# File 'lib/cocoapods-embed-flutter/flutter/external_sources.rb', line 63

def name
  @name
end

#paramsHash{Symbol => String} (readonly)

Returns the hash representation of the external source.

Returns:

  • (Hash{Symbol => String})

    the hash representation of the external source.



68
69
70
# File 'lib/cocoapods-embed-flutter/flutter/external_sources.rb', line 68

def params
  @params
end

#podfile_pathString (readonly)

Returns the path where the podfile is defined to resolve relative paths.

Returns:

  • (String)

    the path where the podfile is defined to resolve relative paths.



73
74
75
# File 'lib/cocoapods-embed-flutter/flutter/external_sources.rb', line 73

def podfile_path
  @podfile_path
end

Instance Method Details

#==(other) ⇒ Boolean

Returns whether an external source source is equal to another according to the #name and to the #params.

Returns:

  • (Boolean)

    whether an external source source is equal to another according to the #name and to the #params.



97
98
99
100
# File 'lib/cocoapods-embed-flutter/flutter/external_sources.rb', line 97

def ==(other)
  return false if other.nil?
  name == other.name && params == other.params
end

#descriptionString

Returns a string representation of the source suitable for UI.

Returns:

  • (String)

    a string representation of the source suitable for UI.



118
119
120
121
122
123
124
125
126
127
# File 'lib/cocoapods-embed-flutter/flutter/external_sources.rb', line 118

def description
  strategy = Pod::Downloader.strategy_from_options(download_params)
  options = download_params.dup
  url = options.delete(strategy)
  result = "from `#{url}`"
  options.each do |key, value|
    result << ", #{key} `#{value}`"
  end
  result
end

#fetch(sandbox) ⇒ void

This method returns an undefined value.

Fetches the external source from the remote according to the params.

Parameters:

  • sandbox (Pod::Sandbox)

    the sandbox where the specification should be stored.



112
113
114
# File 'lib/cocoapods-embed-flutter/flutter/external_sources.rb', line 112

def fetch(sandbox)
  pre_download(sandbox)
end

#normalized_pubspec_pathString

Return the normalized path for a pubspec assuming sandbox pod folder as location.

Returns:

  • (String)

    The uri of the pubspec appending the name of the file and expanding it if necessary.



140
141
142
# File 'lib/cocoapods-embed-flutter/flutter/external_sources.rb', line 140

def normalized_pubspec_path(declared_path)
  Spec.find_file(name, declared_path)
end