Class: ProjectGen::ProjectGenerator
- Inherits:
-
Object
- Object
- ProjectGen::ProjectGenerator
- Includes:
- Pod::Config::Mixin, Helper, SwiftModule
- Defined in:
- lib/cocoapods-project-gen/gen/project_gen.rb
Instance Attribute Summary collapse
-
#allow_warnings ⇒ Boolean
Whether the validator should fail on warnings, or only on errors.
-
#configuration ⇒ Object
Configuration.
-
#external_podspecs ⇒ String
A glob for podspecs to be used during building of the local Podfile via :podspec.
-
#fail_fast ⇒ Boolean
Whether the linter should fail as soon as the first build variant causes an error.
-
#include_podspecs ⇒ String
A glob for podspecs to be used during building of the local Podfile via :path.
-
#local ⇒ Boolean
(also: #local?)
Whether the validation should be performed against the root of the podspec instead to its original source.
-
#no_clean ⇒ Boolean
Whether the linter should not clean up temporary files for inspection.
-
#only_subspecs ⇒ String
Name of the subspec to check, if nil all subspecs are checked.
-
#results ⇒ Object
readonly
!@group results.
-
#source_urls ⇒ Array<String>
readonly
An array of source URLs used to create the Podfile used in the linting process.
-
#swift_version ⇒ String
--swift-versionparameter during validation. -
#use_frameworks ⇒ Boolean
Whether frameworks should be used for the installation.
-
#use_latest ⇒ Object
When multiple dependencies with different sources, use latest.
-
#use_modular_headers ⇒ Boolean
Whether modular headers should be used for the installation.
-
#use_static_frameworks ⇒ Boolean
Whether static frameworks should be used for the installation.
Class Method Summary collapse
-
.new_from_local(podspecs = [], source_urls = [Pod::TrunkSource::TRUNK_REPO_URL], platforms = [], product_type = :framework, configuration = :release, swift_version = nil, use_modular_headers: false) ⇒ Object
Initialize a new instance.
Instance Method Summary collapse
-
#generate!(work_dir, &block) ⇒ Object
Create app project.
-
#initialize(source_urls, platforms = []) ⇒ ProjectGenerator
constructor
Initialize a new instance.
-
#project_gen_dir ⇒ Pathname
The temporary directory used by the linter.
Methods included from Helper
Methods included from SwiftModule
#add_swift_library_compatibility_header, #derived_swift_version, #dot_swift_version, #validate_swift_version
Constructor Details
#initialize(source_urls, platforms = []) ⇒ ProjectGenerator
Initialize a new instance
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 136 def initialize(source_urls, platforms = []) @source_urls = source_urls.map { |url| config.sources_manager.source_with_name_or_url(url) }.map(&:url) @platforms = platforms.map do |platform| result = case platform.to_s.downcase # Platform doesn't recognize 'macos' as being the same as 'osx' when initializing when 'macos' then Pod::Platform.macos else Pod::Platform.new(platform, nil) end unless Constants.valid_platform?(result) raise Informative, "Unrecognized platform `#{platform}`. Valid platforms: #{VALID_PLATFORMS.join(', ')}" end result end @allow_warnings = true @use_frameworks = true @use_latest = true end |
Instance Attribute Details
#allow_warnings ⇒ Boolean
Returns Whether the validator should fail on warnings, or only on errors.
49 50 51 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 49 def allow_warnings @allow_warnings end |
#configuration ⇒ Object
Returns configuration.
86 87 88 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 86 def configuration @configuration end |
#external_podspecs ⇒ String
Returns A glob for podspecs to be used during building of the local Podfile via :podspec.
75 76 77 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 75 def external_podspecs @external_podspecs end |
#fail_fast ⇒ Boolean
Returns whether the linter should fail as soon as the first build variant causes an error. Helpful for i.e. multi-platforms specs, specs with subspecs.
38 39 40 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 38 def fail_fast @fail_fast end |
#include_podspecs ⇒ String
Returns A glob for podspecs to be used during building of the local Podfile via :path.
70 71 72 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 70 def include_podspecs @include_podspecs end |
#local ⇒ Boolean Also known as: local?
Returns whether the validation should be performed against the root of the podspec instead to its original source.
44 45 46 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 44 def local @local end |
#no_clean ⇒ Boolean
Returns whether the linter should not clean up temporary files for inspection.
32 33 34 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 32 def no_clean @no_clean end |
#only_subspecs ⇒ String
Returns name of the subspec to check, if nil all subspecs are checked.
53 54 55 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 53 def only_subspecs @only_subspecs end |
#results ⇒ Object (readonly)
!@group results
16 17 18 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 16 def results @results end |
#source_urls ⇒ Array<String> (readonly)
Returns an array of source URLs used to create the Podfile used in the linting process.
82 83 84 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 82 def source_urls @source_urls end |
#swift_version ⇒ String
--swift-version parameter during validation.
28 29 30 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 28 def swift_version @swift_version end |
#use_frameworks ⇒ Boolean
Returns Whether frameworks should be used for the installation.
57 58 59 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 57 def use_frameworks @use_frameworks end |
#use_latest ⇒ Object
When multiple dependencies with different sources, use latest.
23 24 25 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 23 def use_latest @use_latest end |
#use_modular_headers ⇒ Boolean
Returns Whether modular headers should be used for the installation.
61 62 63 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 61 def use_modular_headers @use_modular_headers end |
#use_static_frameworks ⇒ Boolean
Returns Whether static frameworks should be used for the installation.
65 66 67 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 65 def use_static_frameworks @use_static_frameworks end |
Class Method Details
.new_from_local(podspecs = [], source_urls = [Pod::TrunkSource::TRUNK_REPO_URL], platforms = [], product_type = :framework, configuration = :release, swift_version = nil, use_modular_headers: false) ⇒ Object
Initialize a new instance
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 112 def self.new_from_local(podspecs = [], source_urls = [Pod::TrunkSource::TRUNK_REPO_URL], platforms = [], product_type = :framework, configuration = :release, swift_version = nil, use_modular_headers: false) generator = new(source_urls, platforms) generator.local = true generator.no_subspecs = true generator.only_subspecs = nil generator.no_clean = false generator.allow_warnings = true generator.use_frameworks = product_type == :dynamic_framework generator.use_static_frameworks = product_type == :framework generator.include_podspecs = podspecs generator.configuration = configuration generator.use_modular_headers = use_modular_headers generator.swift_version = swift_version generator end |
Instance Method Details
#generate!(work_dir, &block) ⇒ Object
Create app project
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 161 def generate!(work_dir, &block) @project_gen_dir = Pathname(work_dir) @results = Results.new unless config.silent? podspecs.each do |spec| subspecs = determine_subspecs[spec] if subspecs && !subspecs.empty? subspecs.each { |s| Results.puts " -> #{s}\r\n" } else Results.puts " -> #{spec.name}\r\n" end end end $stdout.flush perform_linting platforms, pod_targets, valid = install @results.print_results block.call(platforms, pod_targets, @clean, @fail_fast) if !block.nil? && valid end |
#project_gen_dir ⇒ Pathname
Returns the temporary directory used by the linter.
183 184 185 |
# File 'lib/cocoapods-project-gen/gen/project_gen.rb', line 183 def project_gen_dir @project_gen_dir ||= Pathname(Dir.mktmpdir(['cocoapods-project-gen-', "-#{spec.name}"])) end |