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
b7284de3
Commit
b7284de3
authored
Sep 15, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+ set spec
parent
de7fe36f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
112 additions
and
11 deletions
+112
-11
dependency.rb
lib/cocoa_pods/dependency.rb
+1
-0
specification.rb
lib/cocoa_pods/specification.rb
+10
-0
set.rb
lib/cocoa_pods/specification/set.rb
+11
-8
set_spec.rb
spec/unit/specification/set_spec.rb
+76
-0
specification_spec.rb
spec/unit/specification_spec.rb
+14
-3
No files found.
lib/cocoa_pods/dependency.rb
View file @
b7284de3
...
...
@@ -5,6 +5,7 @@ require 'rubygems/dependency'
module
Pod
class
Dependency
<
Gem
::
Dependency
attr_accessor
:only_part_of_other_pod
alias_method
:only_part_of_other_pod?
,
:only_part_of_other_pod
def
initialize
(
name
,
*
version_requirements
)
super
...
...
lib/cocoa_pods/specification.rb
View file @
b7284de3
...
...
@@ -94,6 +94,16 @@ module Pod
include
Config
::
Mixin
def
==
(
other
)
self
.
class
===
other
&&
@name
&&
@name
==
other
.
read
(
:name
)
&&
@version
&&
@version
==
other
.
read
(
:version
)
end
def
dependency_by_name
(
name
)
@dependencies
.
find
{
|
d
|
d
.
name
==
name
}
end
# Returns the specification for the pod that this pod's source is a part of.
def
part_of_specification
if
@part_of
...
...
lib/cocoa_pods/specification/set.rb
View file @
b7284de3
...
...
@@ -24,34 +24,37 @@ module Pod
@required_by
=
[]
end
def
required_by
(
specification
,
dependency
)
def
required_by
(
specification
)
dependency
=
specification
.
dependency_by_name
(
name
)
unless
@required_by
.
empty?
||
dependency
.
requirement
.
satisfied_by?
(
required_version
)
# TODO add graph that shows which dependencies led to this.
required_by
=
@required_by
.
map
(
&
:first
).
join
(
', '
)
raise
"
#{
specification
}
tries to activate `
#{
dependency
}
', "
\
"but already activated version `
#{
required_version
}
' by
#{
required_by
}
."
"but already activated version `
#{
required_version
}
' "
\
"by
#{
@required_by
.
join
(
', '
)
}
."
end
@required_by
<<
[
specification
,
dependency
]
@required_by
<<
specification
end
def
dependency
@required_by
.
inject
(
Dependency
.
new
(
name
))
{
|
previous
,
(
_
,
dep
)
|
previous
.
merge
(
dep
)
}
@required_by
.
inject
(
Dependency
.
new
(
name
))
do
|
previous
,
spec
|
previous
.
merge
(
spec
.
dependency_by_name
(
name
))
end
end
def
only_part_of_other_pod?
@required_by
.
all?
{
|
_
,
dep
|
dep
.
only_part_of_other_pod
}
@required_by
.
all?
{
|
spec
|
spec
.
dependency_by_name
(
name
).
only_part_of_other_pod?
}
end
def
name
@pod_dir
.
basename
.
to_s
end
def
spec
_pathname
def
spec
ification_path
@pod_dir
+
required_version
.
to_s
+
"
#{
name
}
.podspec"
end
def
specification
Specification
.
from_podspec
(
spec
_pathname
)
Specification
.
from_podspec
(
spec
ification_path
)
end
# Return the first version that matches the current dependency.
...
...
spec/unit/specification/set_spec.rb
0 → 100644
View file @
b7284de3
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
class
Pod
::
Spec
::
Set
def
reset!
@required_by
=
[]
end
end
describe
"Pod::Specification::Set"
do
it
"returns nil in case a set hasn't been resolved yet"
do
Pod
::
Spec
::
Set
.
by_specification_name
(
'ASIHTTPRequest'
).
should
==
nil
end
before
do
@set
=
Pod
::
Spec
::
Set
.
by_pod_dir
(
fixture
(
'spec-repos/master/ASIHTTPRequest'
))
@set
.
reset!
end
it
"returns a cached set by name once it has been resolved once"
do
Pod
::
Spec
::
Set
.
by_specification_name
(
'ASIHTTPRequest'
).
should
.
eql
@set
end
it
"always returns the same set instance for a pod dir"
do
Pod
::
Spec
::
Set
.
by_pod_dir
(
fixture
(
'spec-repos/master/ASIHTTPRequest'
)).
should
.
eql
@set
end
it
"returns the name of the pod"
do
@set
.
name
.
should
==
'ASIHTTPRequest'
end
it
"returns the versions available for this pod ordered from highest to lowest"
do
@set
.
versions
.
should
==
[
Pod
::
Version
.
new
(
'1.8.1'
),
Pod
::
Version
.
new
(
'1.8'
)]
end
it
"checks if the dependency of the specification is compatible with existing requirements"
do
@set
.
required_by
(
Pod
::
Spec
.
new
{
dependency
'ASIHTTPRequest'
,
'1.8'
})
@set
.
required_by
(
Pod
::
Spec
.
new
{
dependency
'ASIHTTPRequest'
,
'< 1.8.1'
})
@set
.
required_by
(
Pod
::
Spec
.
new
{
dependency
'ASIHTTPRequest'
,
'> 1.7.9'
})
@set
.
required_by
(
Pod
::
Spec
.
new
{
dependency
'ASIHTTPRequest'
,
'~> 1.8.0'
})
@set
.
required_by
(
Pod
::
Spec
.
new
{
dependency
'ASIHTTPRequest'
})
lambda
{
@set
.
required_by
(
Pod
::
Spec
.
new
{
dependency
'ASIHTTPRequest'
,
'< 1.8'
})
}.
should
.
raise
end
it
"raises if the required version doesn't exist"
do
@set
.
required_by
(
Pod
::
Spec
.
new
{
dependency
'ASIHTTPRequest'
,
'< 1.8'
})
lambda
{
@set
.
required_version
}.
should
.
raise
end
before
do
@set
.
required_by
(
Pod
::
Spec
.
new
{
dependency
'ASIHTTPRequest'
,
'< 1.8.1'
})
end
it
"returns the version required for the dependency"
do
@set
.
required_version
.
should
==
Pod
::
Version
.
new
(
'1.8'
)
end
it
"returns the path to the specification for the required version"
do
@set
.
specification_path
.
should
==
fixture
(
'spec-repos/master/ASIHTTPRequest/1.8/ASIHTTPRequest.podspec'
)
end
it
"returns the specification for the required version"
do
@set
.
specification
.
should
==
Pod
::
Spec
.
new
{
name
'ASIHTTPRequest'
;
version
'1.8'
}
end
it
"returns that this set is not only part for other pods"
do
@set
.
required_by
(
Pod
::
Spec
.
new
{
part_of
'ASIHTTPRequest'
})
@set
.
should
.
not
.
be
.
only_part_of_other_pod
end
it
"returns that this set is only part for other pods"
do
@set
.
reset!
@set
.
required_by
(
Pod
::
Spec
.
new
{
part_of
'ASIHTTPRequest'
})
@set
.
required_by
(
Pod
::
Spec
.
new
{
part_of
'ASIHTTPRequest'
})
@set
.
should
.
be
.
only_part_of_other_pod
end
end
spec/unit/specification_spec.rb
View file @
b7284de3
...
...
@@ -86,9 +86,9 @@ describe "A Pod::Specification loaded from a podspec" do
end
it
"returns the pod's dependencies"
do
@spec
.
read
(
:dependencies
).
should
==
[
Pod
::
Dependency
.
new
(
'monkey'
,
'~> 1.0.1'
,
'< 1.0.9'
)
]
expected
=
Pod
::
Dependency
.
new
(
'monkey'
,
'~> 1.0.1'
,
'< 1.0.9'
)
@spec
.
read
(
:dependencies
).
should
==
[
expected
]
@spec
.
dependency_by_name
(
'monkey'
).
should
==
expected
end
it
"returns the pod's xcconfig settings"
do
...
...
@@ -96,6 +96,17 @@ describe "A Pod::Specification loaded from a podspec" do
'OTHER_LDFLAGS'
=>
'-framework SystemConfiguration'
}
end
it
"returns that it's equal to another specification if the name and version are equal"
do
@spec
.
should
==
Pod
::
Spec
.
new
{
name
'BananaLib'
;
version
'1.0'
}
@spec
.
should
.
not
==
Pod
::
Spec
.
new
{
name
'OrangeLib'
;
version
'1.0'
}
@spec
.
should
.
not
==
Pod
::
Spec
.
new
{
name
'BananaLib'
;
version
'1.1'
}
@spec
.
should
.
not
==
Pod
::
Spec
.
new
end
it
"never equals when it's from a Podfile"
do
Pod
::
Spec
.
new
.
should
.
not
==
Pod
::
Spec
.
new
end
end
describe
"A Pod::Specification that's part of another pod's source"
do
...
...
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