Sha256: 84500c76ca908b59e60d46a2bf2a54b9421181a647df6c42bd5fbd7a5fd8d2f5

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

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

    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

    def spec_metadata
      spec = spec_header
      spec += spec_single_platform_fix
      spec
    end

    def spec_close
      "end\n"
    end

    :private

    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

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cocoapods-packager-0.3.0 lib/spec_builder.rb