Sha256: bf48ca0bceb65dd257e8cd78a6680fe367a1964ec243098130ac07342baaba28

Contents?: true

Size: 1.58 KB

Versions: 2

Compression:

Stored size: 1.58 KB

Contents

module Pod
  class Command
    class RepoTal < Command
      class AddCDN < RepoTal
        self.summary = 'Add a spec repo backed by a CDN'

        self.description = <<-DESC
          Add `URL` to the local spec-repos directory at `#{Config.instance.repos_dir}`. The
          remote can later be referred to by `NAME`.
        DESC

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

        def initialize(argv)
          @name = argv.shift_argument
          @url = argv.shift_argument
          super
        end

        def validate!
          super
          unless @name && @url
            help! 'Adding a repo needs a `NAME` and a `URL`.'
          end
          if @name == 'master'
            raise Informative,
                  'To setup the master specs repo, please run `pod setup`.'
          end
        end

        def run
          section = "Adding spec repo `#{@name}` with CDN `#{@url}`"
          UI.section(section) do
            save_url
            config.sources_manager.sources([dir.basename.to_s]).each(&:verify_compatibility!)
          end
        end

        private

        # Saves the spec-repo URL to a '.url' file.
        #
        # @return [void]
        #
        def save_url
          dir.mkpath
          File.open(dir + '.url', 'w') { |file| file.write(@url) }
        rescue => e
          raise Informative, "Could not create '#{config.repos_dir}', the CocoaPods repo cache directory.\n" \
              "#{e.class.name}: #{e.message}"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cocoapods-repo-tal-0.0.2 lib/cocoapods-repo-tal/command/repo/add_cdn.rb
cocoapods-repo-tal-0.0.1 lib/cocoapods-repo-tal/command/repo/add_cdn.rb