Permalink
Browse files

[Source] Add AbstractDataProvider

  • Loading branch information...
1 parent 95a6f90 commit 95d3d8845eac481d5ac6857ff9c71a94ac7ce69f @fabiopelosin fabiopelosin committed Dec 2, 2013
@@ -1,6 +1,7 @@
require 'cocoapods-core/source/acceptor'
require 'cocoapods-core/source/aggregate'
require 'cocoapods-core/source/health_reporter'
+require 'cocoapods-core/source/abstract_data_provider'
module Pod
@@ -0,0 +1,71 @@
+module Pod
+ class Source
+
+ # Defines the required and the optional methods of a data provider.
+ #
+ class AbstractDataProvider
+
+ public
+
+ # @group Required methods
+ #-----------------------------------------------------------------------#
+
+ # @return [String] The name of the source.
+ #
+ def name
+ raise StandardError, "Abstract method."
+ end
+
+ # @return [String] The user friendly type of the source.
+ #
+ def type
+ raise StandardError, "Abstract method."
+ end
+
+ # @return [Array<String>] The list of the name of all the Pods known to
+ # the Source.
+ #
+ def pods
+ raise StandardError, "Abstract method."
+ end
+
+ # @return [Array<String>] All the available versions of a given Pod,
+ # sorted from highest to lowest.
+ #
+ # @param [String] name
+ # The name of the Pod.
+ #
+ def versions(name)
+ raise StandardError, "Abstract method."
+ end
+
+ # @return [Specification] The specification for a given version of a Pod.
+ #
+ # @param [String] name
+ # The name of the Pod.
+ #
+ # @param [String] version
+ # The version of the Pod.
+ #
+ def specification(name, version)
+ raise StandardError, "Abstract method."
+ end
+
+ # @return [Specification] The contents of the specification for a given
+ # version of a Pod.
+ #
+ # @param [String] name
+ # the name of the Pod.
+ #
+ # @param [String] version
+ # the version of the Pod.
+ #
+ def specification_contents(name, version)
+ raise StandardError, "Abstract method."
+ end
+
+ #-----------------------------------------------------------------------#
+
+ end
+ end
+end
@@ -0,0 +1,54 @@
+require File.expand_path('../../spec_helper', __FILE__)
+
+module Pod
+ describe Source::AbstractDataProvider do
+
+ before do
+ @sut = Source::AbstractDataProvider.new
+ end
+
+ #-------------------------------------------------------------------------#
+
+ describe "Optional methods" do
+ it "raises for the #name method" do
+ should.raise StandardError do
+ @sut.name
+ end.message.should.match /Abstract method/
+ end
+
+ it "raises for the #type method" do
+ should.raise StandardError do
+ @sut.type
+ end.message.should.match /Abstract method/
+ end
+
+ it "raises for the #pods method" do
+ should.raise StandardError do
+ @sut.pods
+ end.message.should.match /Abstract method/
+ end
+
+ it "raises for the #versions method" do
+ should.raise StandardError do
+ @sut.versions('Pod')
+ end.message.should.match /Abstract method/
+ end
+
+ it "raises for the #specification method" do
+ should.raise StandardError do
+ @sut.specification('Pod', '0.1.0')
+ end.message.should.match /Abstract method/
+ end
+
+ it "raises for the #specification_contents method" do
+ should.raise StandardError do
+ @sut.specification_contents('Pod', '0.1.0')
+ end.message.should.match /Abstract method/
+ end
+ end
+
+ #-------------------------------------------------------------------------#
+
+ end
+end
+

0 comments on commit 95d3d88

Please sign in to comment.