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'


77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 77

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



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

def base_name
  attributes_hash['name']
end

#changelogString



110
111
112
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 110

def changelog
  attributes_hash['changelog']
end

#cocoapods_versionRequirement



61
62
63
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 61

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

#deprecatedBoolean



197
198
199
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 197

def deprecated
  attributes_hash['deprecated']
end

#deprecated?Boolean



211
212
213
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 211

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

#deprecated_in_favor_ofString



204
205
206
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 204

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.



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

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

#documentation_urlString, Nil



177
178
179
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 177

def documentation_url
  attributes_hash['documentation_url']
end

#homepageString



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

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.



118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 118

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



218
219
220
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 218

def module_map
  attributes_hash['module_map']
end

#nameString



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



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

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

#readmeString



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

def readme
  attributes_hash['readme']
end

#requires_arcBool, ...



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.



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

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

#social_media_urlString



98
99
100
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 98

def social_media_url
  attributes_hash['social_media_url']
end

#sourceHash{Symbol=>String}



140
141
142
143
144
145
146
147
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 140

def source
  value = attributes_hash['source']
  if value && value.is_a?(Hash)
    Specification.convert_keys_to_symbol(value)
  else
    value
  end
end

#static_frameworkBoolean



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

def static_framework
  attributes_hash['static_framework']
end

#summaryString



151
152
153
154
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 151

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.



42
43
44
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 42

def swift_version
  swift_versions.last
end

#swift_versionsArray<Version>



48
49
50
51
52
53
54
55
56
57
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 48

def swift_versions
  @swift_versions ||= begin
    swift_versions = Array(attributes_hash['swift_versions']).dup
    # 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



30
31
32
33
34
35
36
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 30

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