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'

55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 55

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

#cocoapods_versionRequirement


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

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

#convert_keys_to_symbol(value) ⇒ Hash (private)

Converts the keys of the given hash to a string.


193
194
195
196
197
198
199
200
201
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 193

def convert_keys_to_symbol(value)
  return unless value
  result = {}
  value.each do |key, subvalue|
    subvalue = convert_keys_to_symbol(subvalue) if subvalue.is_a?(Hash)
    result[key.to_sym] = subvalue
  end
  result
end

#deprecatedBool


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

def deprecated
  attributes_hash['deprecated']
end

#deprecated?Bool


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

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

#deprecated_in_favor_ofString


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

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.


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

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

#docset_urlString


82
83
84
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 82

def docset_url
  attributes_hash['docset_url']
end

#documentation_urlString, Nil


144
145
146
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 144

def documentation_url
  attributes_hash['documentation_url']
end

#homepageString


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

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.


90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 90

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

#module_mapString, Nil


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

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


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

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

#screenshotsArray<String>

Note:

The value is coerced to an array.

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


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

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

#social_media_urlString


76
77
78
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 76

def social_media_url
  attributes_hash['social_media_url']
end

#sourceHash{Symbol=>String}


112
113
114
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 112

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

#summaryString


118
119
120
121
# File 'lib/cocoapods-core/specification/root_attribute_accessors.rb', line 118

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

#versionVersion


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

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