Module: Pod::Specification::DSL::RootAttributesAccessors

Defined in:
lib/cocoapods-core/specification/root_attribute_accessors.rb

Overview

Provides the accessors methods for the root attributes. Root attributes do not support multi-platform values and inheritance.

Instance Method Summary collapse

Instance Method Details

#authorsHash

Note:

The value is coerced to a hash with a nil email if needed.

Returns a hash containing the authors as the keys and their email address as the values.

Examples:

Possible values


{ 'Author' => '[email protected]' }
[ 'Author', { 'Author_2' => '[email protected]' } ]
[ 'Author', 'Author_2' ]
'Author'

Returns:

  • (Hash)

    a hash containing the authors as the keys and their email address as the values.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 82

def authors
  authors = attributes_hash['authors']
  if authors.is_a?(Hash)
    authors
  elsif authors.is_a?(Array)
    result = {}
    authors.each do |name_or_hash|
      if name_or_hash.is_a?(String)
        result[name_or_hash] = nil
      else
        result.merge!(name_or_hash)
      end
    end
    result
  elsif authors.is_a?(String)
    { authors => nil }
  end
end

#base_nameString

Returns The name of the specification not including the names of the parents, in case of ‘sub-specifications’.

Returns:

  • (String)

    The name of the specification not including the names of the parents, in case of ‘sub-specifications’.



11
12
13
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 11

def base_name
  attributes_hash['name']
end

#cocoapods_versionRequirement

Returns The CocoaPods version required to use the specification.

Returns:

  • (Requirement)

    The CocoaPods version required to use the specification.



66
67
68
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 66

def cocoapods_version
  @cocoapods_version ||= Requirement.create(attributes_hash['cocoapods_version'])
end

#deprecatedBool

Returns Whether the Pod has been deprecated.

Returns:

  • (Bool)

    Whether the Pod has been deprecated.



185
186
187
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 185

def deprecated
  attributes_hash['deprecated']
end

#deprecated?Bool

Returns Wether the pod is deprecated either in favor of some other pod or simply deprecated.

Returns:

  • (Bool)

    Wether the pod is deprecated either in favor of some other pod or simply deprecated.



199
200
201
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 199

def deprecated?
  deprecated || !deprecated_in_favor_of.nil?
end

#deprecated_in_favor_ofString

Returns The name of the Pod that this one has been deprecated in favor of.

Returns:

  • (String)

    The name of the Pod that this one has been deprecated in favor of.



192
193
194
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 192

def deprecated_in_favor_of
  attributes_hash['deprecated_in_favor_of']
end

#descriptionString

Note:

The indentation is stripped from the description.

Returns A longer description of the Pod.

Returns:

  • (String)

    A longer description of the Pod.



148
149
150
151
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 148

def description
  description = attributes_hash['description']
  description.strip_heredoc.chomp if description
end

#documentation_urlString, Nil

Returns The documentation URL of the Pod if specified.

Returns:

  • (String, Nil)

    The documentation URL of the Pod if specified.



165
166
167
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 165

def documentation_url
  attributes_hash['documentation_url']
end

#homepageString

Returns The URL of the homepage of the Pod.

Returns:

  • (String)

    The URL of the homepage of the Pod.



126
127
128
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 126

def homepage
  attributes_hash['homepage']
end

#licenseHash

Note:

The indentation is stripped from the license text.

Returns A hash containing the license information of the Pod.

Returns:

  • (Hash)

    A hash containing the license information of the Pod.



111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 111

def license
  license = attributes_hash['license']
  if license.is_a?(String)
    { :type => license }
  elsif license.is_a?(Hash)
    license = Specification.convert_keys_to_symbol(license)
    license[:text] = license[:text].strip_heredoc if license[:text]
    license
  else
    {}
  end
end

#module_mapString, Nil

Returns The custom module map file of the Pod, if specified.

Returns:

  • (String, Nil)

    The custom module map file of the Pod, if specified.



206
207
208
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 206

def module_map
  attributes_hash['module_map']
end

#nameString

Returns The name of the specification including the names of the parents, in case of ‘sub-specifications’.

Returns:

  • (String)

    The name of the specification including the names of the parents, in case of ‘sub-specifications’.



18
19
20
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 18

def name
  parent ? "#{parent.name}/#{base_name}" : base_name
end

#prepare_commandString, Nil

Returns The prepare command of the Pod if specified.

Returns:

  • (String, Nil)

    The prepare command of the Pod if specified.



171
172
173
174
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 171

def prepare_command
  command = attributes_hash['prepare_command']
  command.strip_heredoc.chomp if command
end

#requires_arcBool, ...

Returns The requires_arc value.

Returns:

  • (Bool, String, Array<String>)

    The requires_arc value.



24
25
26
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 24

def requires_arc
  attributes_hash['requires_arc']
end

#screenshotsArray<String>

Note:

The value is coerced to an array.

Returns The list of the URL for the screenshots of the Pod.

Returns:

  • (Array<String>)

    The list of the URL for the screenshots of the Pod.



158
159
160
161
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 158

def screenshots
  value = attributes_hash['screenshots']
  [*value]
end

#social_media_urlString

Returns The social media URL.

Returns:

  • (String)

    The social media URL.



103
104
105
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 103

def social_media_url
  attributes_hash['social_media_url']
end

#sourceHash{Symbol=>String}

Returns The location from where the library should be retrieved.

Returns:

  • (Hash{Symbol=>String})

    The location from where the library should be retrieved.



133
134
135
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 133

def source
  Specification.convert_keys_to_symbol(attributes_hash['source'])
end

#static_frameworkBool

Returns Indicates, that if use_frameworks! is specified, the framework should include a static library.

Returns:

  • (Bool)

    Indicates, that if use_frameworks! is specified, the framework should include a static library.



179
180
181
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 179

def static_framework
  attributes_hash['static_framework']
end

#summaryString

Returns A short description of the Pod.

Returns:

  • (String)

    A short description of the Pod.



139
140
141
142
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 139

def summary
  summary = attributes_hash['summary']
  summary.strip_heredoc.chomp if summary
end

#swift_versionVersion

Deprecated.

in favor of #swift_versions

Returns The Swift version specified by the specification.

Returns:

  • (Version)

    The Swift version specified by the specification.



47
48
49
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 47

def swift_version
  swift_versions.last
end

#swift_versionsArray<Version>

Returns The Swift versions supported by the specification.

Returns:

  • (Array<Version>)

    The Swift versions supported by the specification.



53
54
55
56
57
58
59
60
61
62
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 53

def swift_versions
  @swift_versions ||= begin
    swift_versions = Array(attributes_hash['swift_versions'])
    # Pre 1.7.0, the DSL was singularized as it supported only a single version of Swift. In 1.7.0 the DSL
    # is now pluralized always and a specification can support multiple versions of Swift. This ensures
    # we parse the old JSON serialized format and include it as part of the Swift versions supported.
    swift_versions << attributes_hash['swift_version'] unless attributes_hash['swift_version'].nil?
    swift_versions.map { |swift_version| Version.new(swift_version) }.uniq.sort
  end
end

#versionVersion

TODO:

The version is memoized because the Resolvers sets the head state on it. This information should be stored in the specification instance and the lockfile should have a more robust handling of head versions (like a dedicated section).

Returns The version of the Pod.

Returns:

  • (Version)

    The version of the Pod.



35
36
37
38
39
40
41
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 35

def version
  if root?
    @version ||= Version.new(attributes_hash['version'])
  else
    @version ||= root.version
  end
end