Sha256: bd2a7f7a69ebfbefa8976fb96454fb2d521a8f5534e326f5f1264146a8f41f48

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'cocoapods-schoutedenapus/converter'

module Pod
  class Command
    class Lib
      class Schoutedenapus < Lib
        self.summary = 'Generate Swift packages from podspecs.'

        self.arguments = [ CLAide::Argument.new('PODSPEC', true) ]

        def initialize(argv)
          @spec = spec_with_path(argv.shift_argument)
          super
        end

        def validate!
          super
          help! 'A podspec is required.' unless @spec
        end

        def run
          File.write('Package.swift', ::Schoutedenapus::Converter.new(@spec).to_s)
        end

        private

        def spec_with_path(path)
          return if path.nil? || !Pathname.new(path).exist?

          if Pathname.new(path).directory?
            help! path + ': is a directory.'
            return
          end

          unless ['.podspec', '.json'].include? Pathname.new(path).extname
            help! path + ': is not a podspec.'
            return
          end

          Specification.from_file(path)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cocoapods-schoutedenapus-0.0.2 lib/cocoapods-schoutedenapus/command/schoutedenapus.rb
cocoapods-schoutedenapus-0.0.1 lib/cocoapods-schoutedenapus/command/schoutedenapus.rb