Class: Pod::SpecBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/spec_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(spec, source) ⇒ SpecBuilder

Returns a new instance of SpecBuilder.



3
4
5
6
# File 'lib/spec_builder.rb', line 3

def initialize(spec, source)
  @spec = spec
  @source = source.nil? ? '{}' : source
end

Instance Method Details

#spec_closeObject



25
26
27
# File 'lib/spec_builder.rb', line 25

def spec_close
  "end\n"
end

#spec_headerObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/spec_builder.rb', line 31

def spec_header
  spec = "Pod::Spec.new do |s|\n"

  %w(name version summary license authors homepage description social_media_url
     docset_url documentation_url screenshots).each do |attribute|
    value = @spec.attributes_hash[attribute]
    next if value.nil?

    value = "'#{value}'" if value.class == String
    spec += "  s.#{attribute} = #{value}\n"
  end

  spec + "  s.source = #{@source}\n\n"
end

#spec_metadataObject



19
20
21
22
23
# File 'lib/spec_builder.rb', line 19

def 
  spec = spec_header
  spec += spec_single_platform_fix
  spec
end

#spec_platform(platform) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/spec_builder.rb', line 8

def spec_platform(platform)
  fwk_base = platform.name.to_s + '/' + @spec.name + '.framework'
  <<SPEC
  s.#{platform.name}.platform             = :#{platform.symbolic_name}, '#{platform.deployment_target}'
  s.#{platform.name}.preserve_paths       = '#{fwk_base}'
  s.#{platform.name}.public_header_files  = '#{fwk_base}/Versions/A/Headers/*.h'
  s.#{platform.name}.resource             = '#{fwk_base}/Versions/A/Resources/**/*'
  s.#{platform.name}.vendored_frameworks  = '#{fwk_base}'
SPEC
end

#spec_single_platform_fixObject



46
47
48
49
50
51
52
53
54
# File 'lib/spec_builder.rb', line 46

def spec_single_platform_fix
  return '' if @spec.available_platforms.length > 1

  platform = @spec.available_platforms.first

  <<SPEC
  s.platform = :#{platform.symbolic_name}, '#{platform.deployment_target}'
SPEC
end