Class: Pod::Specification::Consumer

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods-core/specification/consumer.rb

Overview

Allows to conveniently access a Specification programmatically.

It takes care of:

  • standardizing the attributes

  • handling multi-platform values

  • handle default values

  • handle inherited values

This class allows to store the values of the attributes in the Specification as specified in the DSL. The benefits is reduced reliance on meta programming to access the attributes and the possibility of serializing a specification back exactly as defined in a file.

Instance Attribute Summary collapse

Regular attributes collapse

File patterns collapse

Dependencies collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec, platform) ⇒ Consumer

Returns a new instance of Consumer.

Parameters:

  • spec (Specification)

    @see spec

  • platform (Symbol, Platform)

    The platform for which the specification needs to be consumed.



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

def initialize(spec, platform)
  @spec = spec
  @platform_name = platform.is_a?(Symbol) ? platform : platform.name

  unless spec.supported_on_platform?(platform)
    raise StandardError, "#{to_s} is not compatible with #{platform}."
  end
end

Instance Attribute Details

#platform_nameSymbol (readonly)

Returns The name of the platform for which the specification needs to be consumed.

Returns:

  • (Symbol)

    The name of the platform for which the specification needs to be consumed.



29
30
31
# File 'lib/cocoapods-core/specification/consumer.rb', line 29

def platform_name
  @platform_name
end

#specSpecification (readonly)

Returns The specification to consume.

Returns:



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

def spec
  @spec
end

Class Method Details

.spec_attr_accessor(name) ⇒ Object

Creates a method to access the contents of the attribute.

Parameters:

  • name (Symbol)

    the name of the attribute.



52
53
54
55
56
# File 'lib/cocoapods-core/specification/consumer.rb', line 52

def self.spec_attr_accessor(name)
  define_method(name) do
    value_for_attribute(name)
  end
end

Instance Method Details

#compiler_flagsArray<String>

Returns the list of compiler flags needed by the specification files.

Returns:

  • (Array<String>)

    the list of compiler flags needed by the specification files.



86
# File 'lib/cocoapods-core/specification/consumer.rb', line 86

spec_attr_accessor :compiler_flags

#dependenciesArray<Dependency>

Returns the dependencies on other Pods.

Returns:

  • (Array<Dependency>)

    the dependencies on other Pods.



164
165
166
167
168
169
# File 'lib/cocoapods-core/specification/consumer.rb', line 164

def dependencies
  value = value_for_attribute(:dependencies)
  value.map do |name, requirements|
    Dependency.new(name, requirements)
  end
end

#exclude_filesArray<String>

Returns The file patterns that the Pod should ignore.

Returns:

  • (Array<String>)

    The file patterns that the Pod should ignore.



151
# File 'lib/cocoapods-core/specification/consumer.rb', line 151

spec_attr_accessor :exclude_files

#frameworksArray<String>

Returns A list of frameworks that the user’s target needs to link against.

Returns:

  • (Array<String>)

    A list of frameworks that the user’s target needs to link against



71
# File 'lib/cocoapods-core/specification/consumer.rb', line 71

spec_attr_accessor :frameworks

#header_dirString

Returns the headers directory.

Returns:

  • (String)

    the headers directory.



103
# File 'lib/cocoapods-core/specification/consumer.rb', line 103

spec_attr_accessor :header_dir

#header_mappings_dirString

Returns the directory from where to preserve the headers namespacing.

Returns:

  • (String)

    the directory from where to preserve the headers namespacing.



108
# File 'lib/cocoapods-core/specification/consumer.rb', line 108

spec_attr_accessor :header_mappings_dir

#librariesArray<String>

Returns A list of libraries that the user’s target needs to link against.

Returns:

  • (Array<String>)

    A list of libraries that the user’s target needs to link against



81
# File 'lib/cocoapods-core/specification/consumer.rb', line 81

spec_attr_accessor :libraries

#prefix_header_contentsString

Returns The contents of the prefix header.

Returns:

  • (String)

    The contents of the prefix header.



95
# File 'lib/cocoapods-core/specification/consumer.rb', line 95

spec_attr_accessor :prefix_header_contents

#prefix_header_fileString

Returns The path of the prefix header file.

Returns:

  • (String)

    The path of the prefix header file.



99
# File 'lib/cocoapods-core/specification/consumer.rb', line 99

spec_attr_accessor :prefix_header_file

#preserve_pathsArray<String>

Returns The paths that should be not cleaned.

Returns:

  • (Array<String>)

    The paths that should be not cleaned.



156
# File 'lib/cocoapods-core/specification/consumer.rb', line 156

spec_attr_accessor :preserve_paths

#private_header_filesArray<String>

Returns the private headers of the Pod.

Returns:

  • (Array<String>)

    the private headers of the Pod.



124
# File 'lib/cocoapods-core/specification/consumer.rb', line 124

spec_attr_accessor :private_header_files

#public_header_filesArray<String>

Returns the public headers of the Pod.

Returns:

  • (Array<String>)

    the public headers of the Pod.



120
# File 'lib/cocoapods-core/specification/consumer.rb', line 120

spec_attr_accessor :public_header_files

#requires_arcBool Also known as: requires_arc?

Returns Whether the source files of the specification require to be compiled with ARC.

Returns:

  • (Bool)

    Whether the source files of the specification require to be compiled with ARC.



65
# File 'lib/cocoapods-core/specification/consumer.rb', line 65

spec_attr_accessor :requires_arc

#resource_bundlesHash{String=>String}

Returns ] hash where the keys are the names of the resource bundles and the values are their relative file patterns.

Returns:

  • (Hash{String=>String})

    ] hash where the keys are the names of the resource bundles and the values are their relative file patterns.



140
# File 'lib/cocoapods-core/specification/consumer.rb', line 140

spec_attr_accessor :resource_bundles

#resourcesArray<String>

Returns A hash where the key represents the paths of the resources to copy and the values the paths of the resources that should be copied.

Returns:

  • (Array<String>)

    A hash where the key represents the paths of the resources to copy and the values the paths of the resources that should be copied.



146
# File 'lib/cocoapods-core/specification/consumer.rb', line 146

spec_attr_accessor :resources

#source_filesArray<String>

Returns the source files of the Pod.

Returns:

  • (Array<String>)

    the source files of the Pod.



116
# File 'lib/cocoapods-core/specification/consumer.rb', line 116

spec_attr_accessor :source_files

#vendored_frameworksArray<String>

Returns The paths of the framework bundles shipped with the Pod.

Returns:

  • (Array<String>)

    The paths of the framework bundles shipped with the Pod.



129
# File 'lib/cocoapods-core/specification/consumer.rb', line 129

spec_attr_accessor :vendored_frameworks

#vendored_librariesArray<String>

Returns The paths of the libraries shipped with the Pod.

Returns:

  • (Array<String>)

    The paths of the libraries shipped with the Pod.



134
# File 'lib/cocoapods-core/specification/consumer.rb', line 134

spec_attr_accessor :vendored_libraries

#weak_frameworksArray<String>

Returns A list of frameworks that the user’s target needs to weakly link against.

Returns:

  • (Array<String>)

    A list of frameworks that the user’s target needs to weakly link against



76
# File 'lib/cocoapods-core/specification/consumer.rb', line 76

spec_attr_accessor :weak_frameworks

#xcconfigHash{String => String}

Returns the xcconfig flags for the current specification.

Returns:

  • (Hash{String => String})

    the xcconfig flags for the current specification.



91
# File 'lib/cocoapods-core/specification/consumer.rb', line 91

spec_attr_accessor :xcconfig