Class: Pod::BuildType

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

Constant Summary collapse

KNOWN_PACKAGING_OPTIONS =

Returns known packaging options.

Returns:

  • (Array<Symbol>)

    known packaging options.

%i(library framework).freeze
KNOWN_LINKAGE_OPTIONS =

Returns known linking options.

Returns:

  • (Array<Symbol>)

    known linking options.

%i(static dynamic).freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(linkage: :static, packaging: :library) ⇒ BuildType

Returns a new instance of BuildType.



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cocoapods-core/build_type.rb', line 21

def initialize(linkage: :static, packaging: :library)
  unless KNOWN_LINKAGE_OPTIONS.include?(linkage)
    raise ArgumentError, "Invalid linkage option #{linkage.inspect}, valid options are #{KNOWN_LINKAGE_OPTIONS.inspect}"
  end
  unless KNOWN_PACKAGING_OPTIONS.include?(packaging)
    raise ArgumentError, "Invalid packaging option #{packaging.inspect}, valid options are #{KNOWN_PACKAGING_OPTIONS.inspect}"
  end
  @packaging = packaging
  @linkage = linkage
  @hash = packaging.hash ^ linkage.hash
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



19
20
21
# File 'lib/cocoapods-core/build_type.rb', line 19

def hash
  @hash
end

#linkageSymbol (readonly)

Returns the linkage for this build type, one of #KNOWN_LINKAGE_OPTIONS.

Returns:

  • (Symbol)

    the linkage for this build type, one of #KNOWN_LINKAGE_OPTIONS



17
18
19
# File 'lib/cocoapods-core/build_type.rb', line 17

def linkage
  @linkage
end

#packagingSymbol (readonly)

Returns the packaging for this build type, one of #KNOWN_PACKAGING_OPTIONS.

Returns:

  • (Symbol)

    the packaging for this build type, one of #KNOWN_PACKAGING_OPTIONS



13
14
15
# File 'lib/cocoapods-core/build_type.rb', line 13

def packaging
  @packaging
end

Class Method Details

.dynamic_frameworkBuildType

Returns the build type for a dynamic framework.

Returns:

  • (BuildType)

    the build type for a dynamic framework



46
47
48
# File 'lib/cocoapods-core/build_type.rb', line 46

def self.dynamic_framework
  new(:linkage => :dynamic, :packaging => :framework)
end

.dynamic_libraryBuildType

Returns the build type for a dynamic library.

Returns:

  • (BuildType)

    the build type for a dynamic library



34
35
36
# File 'lib/cocoapods-core/build_type.rb', line 34

def self.dynamic_library
  new(:linkage => :dynamic, :packaging => :library)
end

.static_frameworkBuildType

Returns the build type for a static framework.

Returns:

  • (BuildType)

    the build type for a static framework



52
53
54
# File 'lib/cocoapods-core/build_type.rb', line 52

def self.static_framework
  new(:linkage => :static, :packaging => :framework)
end

.static_libraryBuildType

Returns the build type for a static library.

Returns:

  • (BuildType)

    the build type for a static library



40
41
42
# File 'lib/cocoapods-core/build_type.rb', line 40

def self.static_library
  new(:linkage => :static, :packaging => :library)
end

Instance Method Details

#==(other) ⇒ Object



116
117
118
119
# File 'lib/cocoapods-core/build_type.rb', line 116

def ==(other)
  linkage == other.linkage &&
    packaging == other.packaging
end

#dynamic?Boolean

Returns whether the target is built dynamically.

Returns:

  • (Boolean)

    whether the target is built dynamically



58
59
60
# File 'lib/cocoapods-core/build_type.rb', line 58

def dynamic?
  linkage == :dynamic
end

#dynamic_framework?Boolean

Returns whether the target is built as a dynamic framework.

Returns:

  • (Boolean)

    whether the target is built as a dynamic framework



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

def dynamic_framework?
  dynamic? && framework?
end

#dynamic_library?Boolean

Returns whether the target is built as a dynamic library.

Returns:

  • (Boolean)

    whether the target is built as a dynamic library



88
89
90
# File 'lib/cocoapods-core/build_type.rb', line 88

def dynamic_library?
  dynamic? && library?
end

#framework?Boolean

Returns whether the target is built as a framework.

Returns:

  • (Boolean)

    whether the target is built as a framework



70
71
72
# File 'lib/cocoapods-core/build_type.rb', line 70

def framework?
  packaging == :framework
end

#inspectObject



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

def inspect
  "#<#{self.class} linkage=#{linkage} packaging=#{packaging}>"
end

#library?Boolean

Returns whether the target is built as a library.

Returns:

  • (Boolean)

    whether the target is built as a library



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

def library?
  packaging == :library
end

#static?Boolean

Returns whether the target is built statically.

Returns:

  • (Boolean)

    whether the target is built statically



64
65
66
# File 'lib/cocoapods-core/build_type.rb', line 64

def static?
  linkage == :static
end

#static_framework?Boolean

Returns whether the target is built as a static framework.

Returns:

  • (Boolean)

    whether the target is built as a static framework



94
95
96
# File 'lib/cocoapods-core/build_type.rb', line 94

def static_framework?
  static? && framework?
end

#static_library?Boolean

Returns whether the target is built as a static library.

Returns:

  • (Boolean)

    whether the target is built as a static library



100
101
102
# File 'lib/cocoapods-core/build_type.rb', line 100

def static_library?
  static? && library?
end

#to_hashObject



108
109
110
# File 'lib/cocoapods-core/build_type.rb', line 108

def to_hash
  { :linkage => linkage, :packaging => packaging }
end

#to_sObject



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

def to_s
  "#{linkage} #{packaging}"
end