Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
fb7d8537
Commit
fb7d8537
authored
Nov 07, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A Dependency can point to an external podspec or define a Specification inline.
parent
81df5fc9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
153 additions
and
6 deletions
+153
-6
dependency.rb
lib/cocoapods/dependency.rb
+31
-3
podfile.rb
lib/cocoapods/podfile.rb
+62
-2
dependency_spec.rb
spec/unit/dependency_spec.rb
+31
-1
podfile_spec.rb
spec/unit/podfile_spec.rb
+29
-0
No files found.
lib/cocoapods/dependency.rb
View file @
fb7d8537
...
@@ -7,13 +7,41 @@ module Pod
...
@@ -7,13 +7,41 @@ module Pod
attr_accessor
:only_part_of_other_pod
attr_accessor
:only_part_of_other_pod
alias_method
:only_part_of_other_pod?
,
:only_part_of_other_pod
alias_method
:only_part_of_other_pod?
,
:only_part_of_other_pod
def
initialize
(
name
,
*
version_requirements
)
attr_accessor
:external_spec_source
super
attr_accessor
:specification
def
initialize
(
*
name_and_version_requirements
,
&
block
)
if
name_and_version_requirements
.
empty?
&&
block
@specification
=
Specification
.
new
(
&
block
)
super
(
@specification
.
name
,
@specification
.
version
)
elsif
!
name_and_version_requirements
.
empty?
&&
block
.
nil?
if
name_and_version_requirements
.
last
.
is_a?
(
Hash
)
@external_spec_source
=
name_and_version_requirements
.
pop
end
super
(
name_and_version_requirements
.
first
)
else
raise
Informative
,
"A dependency needs either a name and version requirements, "
\
"a source hash, or a block which defines a podspec."
end
@only_part_of_other_pod
=
false
@only_part_of_other_pod
=
false
end
end
def
==
(
other
)
def
==
(
other
)
super
&&
@only_part_of_other_pod
==
other
.
only_part_of_other_pod
super
&&
@only_part_of_other_pod
==
other
.
only_part_of_other_pod
&&
@external_spec_source
==
other
.
external_spec_source
&&
@specification
==
other
.
specification
end
def
external_podspec?
!
@external_spec_source
.
nil?
end
def
inline_podspec?
!
@specification
.
nil?
end
end
# Taken from a newer version of RubyGems
# Taken from a newer version of RubyGems
...
...
lib/cocoapods/podfile.rb
View file @
fb7d8537
...
@@ -77,8 +77,68 @@ module Pod
...
@@ -77,8 +77,68 @@ module Pod
#
#
# * http://semver.org
# * http://semver.org
# * http://docs.rubygems.org/read/chapter/7
# * http://docs.rubygems.org/read/chapter/7
def
dependency
(
name
,
*
version_requirements
)
#
@target
.
target_dependencies
<<
Dependency
.
new
(
name
,
*
version_requirements
)
#
# ## Dependency on a library, outside those available in a spec repo.
#
# ### From a podspec in the root of a library repo.
#
# Sometimes you may want to use the bleeding edge version of a Pod. Or a
# specific revision. If this is the case, you can specify that with your
# dependency declaration.
#
#
# To use the `master` branch of the repo:
#
# dependency 'TTTFormatterKit', :git => 'https://github.com/gowalla/AFNetworking.git'
#
#
# Or specify a commit:
#
# dependency 'TTTFormatterKit', :git => 'https://github.com/gowalla/AFNetworking.git', :commit => '082f8319af'
#
#
# It is important to note, though, that this means that the version will
# have to satisfy any other dependencies on the Pod by other Pods.
#
#
# The `podspec` file is expected to be in the root of the repo, if this
# library does not have a `podspec` file in its repo yet, you will have to
# use one of the approaches outlined in the sections below.
#
#
# ### From a podspec outside a spec repo, for a library without podspec.
#
# If a podspec is available from another source outside of the library’s
# repo. Consider, for instance, a podpsec available via HTTP:
#
# dependency 'JSONKit', :podspec => 'https://raw.github.com/gist/1346394/1d26570f68ca27377a27430c65841a0880395d72/JSONKit.podspec'
#
#
# ### For a library without any available podspec
#
# Finally, if no man alive has created a podspec, for the library you want
# to use, yet, you will have to specify the library yourself.
#
#
# When you omit arguments and pass a block to `dependency`, an instance of
# Pod::Specification is yielded to the block. This is the same class which
# is normally used to specify a Pod.
#
# dependency do |spec|
# spec.name = 'JSONKit'
# spec.version = '1.4'
# spec.source = { :git => 'https://github.com/johnezang/JSONKit.git', :tag => 'v1.4' }
# spec.source_files = 'JSONKit.*'
# end
#
#
# For more info on the definition of a Pod::Specification see:
# https://github.com/alloy/cocoapods/wiki/A-pod-specification
#
#
def
dependency
(
*
name_and_version_requirements
,
&
block
)
@target
.
target_dependencies
<<
Dependency
.
new
(
*
name_and_version_requirements
,
&
block
)
end
end
def
dependencies
def
dependencies
...
...
spec/unit/dependency_spec.rb
View file @
fb7d8537
...
@@ -7,7 +7,21 @@ describe "Pod::Dependency" do
...
@@ -7,7 +7,21 @@ describe "Pod::Dependency" do
dep1
.
merge
(
dep2
).
should
==
Pod
::
Dependency
.
new
(
'bananas'
,
'>= 1.8'
,
'1.9'
)
dep1
.
merge
(
dep2
).
should
==
Pod
::
Dependency
.
new
(
'bananas'
,
'>= 1.8'
,
'1.9'
)
end
end
it
"is equal to another dependency if the `part_of_other_pod' flag is the same"
do
it
"returns wether or not the spec for this pod is in a spec repo"
do
dep
=
Pod
::
Dependency
.
new
(
'bananas'
)
dep
.
should
.
not
.
be
.
external_podspec
dep
.
external_spec_source
=
{
:git
=>
'GIT-URL'
}
dep
.
should
.
be
.
external_podspec
end
it
"returns wether or not the spec for this pod is defined inline"
do
dep
=
Pod
::
Dependency
.
new
{
|
s
|
s
.
name
=
'bananas'
}
dep
.
should
.
be
.
inline_podspec
dep
.
specification
.
should
.
be
.
instance_of
Pod
::
Specification
dep
.
specification
.
name
.
should
==
'bananas'
end
it
"is equal to another dependency if `part_of_other_pod' is the same"
do
dep1
=
Pod
::
Dependency
.
new
(
'bananas'
,
'>= 1'
)
dep1
=
Pod
::
Dependency
.
new
(
'bananas'
,
'>= 1'
)
dep1
.
only_part_of_other_pod
=
true
dep1
.
only_part_of_other_pod
=
true
dep2
=
Pod
::
Dependency
.
new
(
'bananas'
,
'>= 1'
)
dep2
=
Pod
::
Dependency
.
new
(
'bananas'
,
'>= 1'
)
...
@@ -15,4 +29,20 @@ describe "Pod::Dependency" do
...
@@ -15,4 +29,20 @@ describe "Pod::Dependency" do
dep2
.
only_part_of_other_pod
=
true
dep2
.
only_part_of_other_pod
=
true
dep1
.
should
==
dep2
dep1
.
should
==
dep2
end
end
it
"is equal to another dependency if `external_spec_source' is the same"
do
dep1
=
Pod
::
Dependency
.
new
(
'bananas'
,
:git
=>
'GIT-URL'
)
dep2
=
Pod
::
Dependency
.
new
(
'bananas'
)
dep1
.
should
.
not
==
dep2
dep2
.
external_spec_source
=
{
:git
=>
'GIT-URL'
}
dep1
.
should
==
dep2
end
it
"is equal to another dependency if `specification' is equal"
do
dep1
=
Pod
::
Dependency
.
new
{
|
s
|
s
.
name
=
'bananas'
;
s
.
version
=
'1'
}
dep2
=
Pod
::
Dependency
.
new
(
'bananas'
)
dep1
.
should
.
not
==
dep2
dep2
=
Pod
::
Dependency
.
new
{
|
s
|
s
.
name
=
'bananas'
;
s
.
version
=
'1'
}
dep1
.
should
==
dep2
end
end
end
spec/unit/podfile_spec.rb
View file @
fb7d8537
...
@@ -18,6 +18,35 @@ describe "Pod::Podfile" do
...
@@ -18,6 +18,35 @@ describe "Pod::Podfile" do
podfile
.
dependency_by_name
(
'SSZipArchive'
).
should
==
Pod
::
Dependency
.
new
(
'SSZipArchive'
,
'>= 0.1'
)
podfile
.
dependency_by_name
(
'SSZipArchive'
).
should
==
Pod
::
Dependency
.
new
(
'SSZipArchive'
,
'>= 0.1'
)
end
end
it
"adds a dependency on a Pod repo outside of a spec repo (the repo is expected to contain a podspec)"
do
podfile
=
Pod
::
Podfile
.
new
do
dependency
'SomeExternalPod'
,
:git
=>
'GIT-URL'
,
:commit
=>
'1234'
end
dep
=
podfile
.
dependency_by_name
(
'SomeExternalPod'
)
dep
.
should
.
be
.
external_podspec
dep
.
external_spec_source
.
should
==
{
:git
=>
'GIT-URL'
,
:commit
=>
'1234'
}
end
it
"adds a dependency on a library outside of a spec repo (the repo does not need to contain a podspec)"
do
podfile
=
Pod
::
Podfile
.
new
do
dependency
'SomeExternalPod'
,
:podspec
=>
'http://gist/SomeExternalPod.podspec'
end
dep
=
podfile
.
dependency_by_name
(
'SomeExternalPod'
)
dep
.
should
.
be
.
external_podspec
dep
.
external_spec_source
.
should
==
{
:podspec
=>
'http://gist/SomeExternalPod.podspec'
}
end
it
"adds a dependency on a library by specifying the podspec inline"
do
podfile
=
Pod
::
Podfile
.
new
do
dependency
do
|
s
|
s
.
name
=
'SomeExternalPod'
end
end
dep
=
podfile
.
dependency_by_name
(
'SomeExternalPod'
)
dep
.
should
.
be
.
inline_podspec
dep
.
specification
.
name
.
should
==
'SomeExternalPod'
end
it
"specifies that BridgeSupport metadata should be generated"
do
it
"specifies that BridgeSupport metadata should be generated"
do
Pod
::
Podfile
.
new
{}.
should
.
not
.
generate_bridge_support
Pod
::
Podfile
.
new
{}.
should
.
not
.
generate_bridge_support
Pod
::
Podfile
.
new
{
generate_bridge_support!
}.
should
.
generate_bridge_support
Pod
::
Podfile
.
new
{
generate_bridge_support!
}.
should
.
generate_bridge_support
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment