Sha256: e20346263804b81e7649f1db2acddd0d8edd2dd991d042b02a25ea8054de0f2a

Contents?: true

Size: 922 Bytes

Versions: 1

Compression:

Stored size: 922 Bytes

Contents

module Schoutedenapus
  class Converter
    def initialize(spec)
      @spec = spec
    end

    def to_s
      return <<-EOF
import PackageDescription

let package = Package(
\tname: "#{@spec.name}"#{dependencies}
)
EOF
    end

    private

    def dependency_to_package(dep)
      set = Pod::SourcesManager.search(dep)
      Pod::Command::help! "Could not find pod '#{dep.name}'" if set.nil?
      url = set.specification.source[:git]
      # FIXME: Should use the lowest matching version
      major = set.versions.first.major
      minor = set.versions.first.minor
      "\t\t.Package(url: \"#{url}\", majorVersion: #{major}, minor: #{minor}),"
    end

    def dependencies
      return '' if @spec.dependencies.count == 0

      deps = @spec.dependencies.map { |dep| dependency_to_package(dep) }.join("\n")
      dependencies = <<-EOF
,
\tdependencies: [
#{deps}
\t]
EOF
      dependencies.rstrip!
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cocoapods-schoutedenapus-0.0.1 lib/cocoapods-schoutedenapus/converter.rb