Class: Pod::SPM::Package
- Inherits:
-
Object
- Object
- Pod::SPM::Package
- Defined in:
- lib/cocoapods-spm/def/spm_package.rb
Instance Attribute Summary collapse
-
#linking_opts ⇒ Object
readonly
Returns the value of attribute linking_opts.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#relative_path ⇒ Object
readonly
Returns the value of attribute relative_path.
-
#requirement ⇒ Object
readonly
Returns the value of attribute requirement.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #absolute_path ⇒ Object
- #create_pkg_ref(project) ⇒ Object
-
#initialize(name, options = {}) ⇒ Package
constructor
A new instance of Package.
- #inspect ⇒ Object (also: #to_s)
- #linker_flags ⇒ Object
- #local? ⇒ Boolean
- #parse_options(options) ⇒ Object
- #relative_path_from(options) ⇒ Object
- #slug ⇒ Object
- #to_dependencies ⇒ Object
- #use_default_xcode_linking? ⇒ Boolean
Constructor Details
#initialize(name, options = {}) ⇒ Package
Returns a new instance of Package.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/cocoapods-spm/def/spm_package.rb', line 9 def initialize(name, = {}) @name = name @_options = @relative_path = nil @linkage = nil @url = nil @requirement = nil @linking_opts = {} () end |
Instance Attribute Details
#linking_opts ⇒ Object (readonly)
Returns the value of attribute linking_opts.
7 8 9 |
# File 'lib/cocoapods-spm/def/spm_package.rb', line 7 def linking_opts @linking_opts end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/cocoapods-spm/def/spm_package.rb', line 7 def name @name end |
#relative_path ⇒ Object (readonly)
Returns the value of attribute relative_path.
7 8 9 |
# File 'lib/cocoapods-spm/def/spm_package.rb', line 7 def relative_path @relative_path end |
#requirement ⇒ Object (readonly)
Returns the value of attribute requirement.
7 8 9 |
# File 'lib/cocoapods-spm/def/spm_package.rb', line 7 def requirement @requirement end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/cocoapods-spm/def/spm_package.rb', line 7 def url @url end |
Instance Method Details
#absolute_path ⇒ Object
31 32 33 |
# File 'lib/cocoapods-spm/def/spm_package.rb', line 31 def absolute_path (Pathname("Pods") / relative_path).realpath.to_s end |
#create_pkg_ref(project) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/cocoapods-spm/def/spm_package.rb', line 70 def create_pkg_ref(project) cls = local? ? Object::XCLocalSwiftPackageReference : Object::XCRemoteSwiftPackageReference ref = project.new(cls) ref.name = name if local? ref.relative_path = relative_path else ref.repositoryURL = url ref.requirement = requirement end ref end |
#inspect ⇒ Object Also known as: to_s
44 45 46 |
# File 'lib/cocoapods-spm/def/spm_package.rb', line 44 def inspect "#<#{self.class} #{name}>" end |
#linker_flags ⇒ Object
58 59 60 |
# File 'lib/cocoapods-spm/def/spm_package.rb', line 58 def linker_flags @linking_opts[:linker_flags] || [] end |
#local? ⇒ Boolean
50 51 52 |
# File 'lib/cocoapods-spm/def/spm_package.rb', line 50 def local? @relative_path != nil end |
#parse_options(options) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/cocoapods-spm/def/spm_package.rb', line 20 def () @url = [:url] || [:git] @relative_path = relative_path_from() @requirement = requirement_from() @linking_opts = [:linking] || {} end |
#relative_path_from(options) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/cocoapods-spm/def/spm_package.rb', line 35 def relative_path_from() if (relative_path = [:relative_path]) relative_path elsif (path = [:path]) path = Pathname(path). path.relative_path_from(File.absolute_path("Pods")).to_s end end |
#slug ⇒ Object
27 28 29 |
# File 'lib/cocoapods-spm/def/spm_package.rb', line 27 def slug @slug ||= File.basename(@url || @relative_path, ".*") end |
#to_dependencies ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/cocoapods-spm/def/spm_package.rb', line 62 def to_dependencies if (products = @_options[:products]) products.map { |product| Dependency.new(@name, product: product, pkg: self) } else [Dependency.new(@name, pkg: self)] end end |
#use_default_xcode_linking? ⇒ Boolean
54 55 56 |
# File 'lib/cocoapods-spm/def/spm_package.rb', line 54 def use_default_xcode_linking? @linking_opts.fetch(:use_default_xcode_linking, false) end |