Module: Flutter::Pub::ExternalSources

Defined in:
lib/cocoapods-embed-flutter/flutter/external_sources.rb

Overview

The ExternalSources modules name-spaces all the classes for accessing remote Flutter projects.

Defined Under Namespace

Classes: DownloaderSource

Constant Summary collapse

SOURCE_KEYS =

The keys accepted by the hash of the source attribute.

{
  :git  => [:tag, :branch, :commit, :submodules].freeze,
  :svn  => [:folder, :tag, :revision].freeze,
  :hg   => [:revision].freeze,
  :http => [:flatten, :type, :sha256, :sha1, :headers].freeze,
}.freeze

Class Method Summary collapse

Class Method Details

.fetchWithNameAndOptions(name, options) ⇒ Spec

Note:

the source of project can either be local or all the remotes supported by ‘cocoapods-downloader`.

Returns the path to ‘pubspec` with the given name and location to search.

Parameters:

  • name (String)

    the name of the project declared in ‘pubspec`.

  • options (Hash)

    requirement opttions for the source of project.

Returns:

  • (Spec)

    the ‘pubspec` with the given name satisfying requirement options.

Raises:

  • (StandardError)


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/cocoapods-embed-flutter/flutter/external_sources.rb', line 35

def self.fetchWithNameAndOptions(name, options)
  raise StandardError, 'A flutter module requires a name.' unless name

  options = options.last if options.is_a?(Array)
  raise StandardError, "No options specified for flutter module: '#{name}'." unless options.is_a?(Hash)

  if SOURCE_KEYS.keys.any? { |key| options.key?(key) }
    source = DownloaderSource.new(name, options, Pod::Config.instance.podfile_path)
    source.fetch(Pod::Config.instance.sandbox)
    path = source.normalized_pubspec_path
  elsif options.key?(:path)
    path = options[:path]
  else
    raise StandardError, "Invalid flutter module: '#{name}'."
  end

  return Spec.find(name, path)
end