Class: Pod::SPM::MacroFetcher
- Inherits:
-
Object
- Object
- Pod::SPM::MacroFetcher
- Includes:
- Config::Mixin
- Defined in:
- lib/cocoapods-spm/macro/fetcher.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #download_macro_source ⇒ Object
-
#initialize(options = {}) ⇒ MacroFetcher
constructor
A new instance of MacroFetcher.
- #run ⇒ Object
Methods included from Config::SPMConfigMixin
Methods included from Config::PodConfigMixin
Methods included from Config::ProjectConfigMixin
Constructor Details
#initialize(options = {}) ⇒ MacroFetcher
Returns a new instance of MacroFetcher.
8 9 10 11 12 13 |
# File 'lib/cocoapods-spm/macro/fetcher.rb', line 8 def initialize( = {}) @name = [:name] @specs_by_platform = [:specs_by_platform] @can_cache = [:can_cache] @podfile = Pod::Config.instance.podfile end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/cocoapods-spm/macro/fetcher.rb', line 6 def name @name end |
Instance Method Details
#download_macro_source ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cocoapods-spm/macro/fetcher.rb', line 25 def download_macro_source @specs_by_platform ||= @podfile.root_target_definitions.to_h do |definition| spec = Pod::Spec.from_file(spm_config.macro_root_dir / name / "#{name}.podspec") [definition.platform, [spec]] end # When `can_cache` is true, PodSourceDownloader only keeps the contents # according to its `source_files` declared in the podspec. # However, we wish to keep all contents (including Package.swift...). # --> We alter the spec when downloading the source. altered_specs_by_platform = @specs_by_platform.to_h do |platform, specs| altered_specs = specs.map do |spec| spec.with { |s| s.source_files = "**/*" } end [platform, altered_specs] end downloader = Pod::Installer::PodSourceDownloader.new( spm_config.macro_downloaded_sandbox, @podfile, altered_specs_by_platform, can_cache: @can_cache ) downloader.download! end |
#run ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/cocoapods-spm/macro/fetcher.rb', line 15 def run download_macro_source macro_dir = spm_config.macro_root_dir / name macro_downloaded_dir = spm_config.macro_downloaded_root_dir / name FileUtils.copy_entry( macro_downloaded_dir / "Sources" / name, macro_dir / "Sources" / name ) end |