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
e9862578
Commit
e9862578
authored
Mar 12, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ExternalSources] Support the specification of a folder for the :podspec option
parent
5c634e99
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
13 deletions
+72
-13
external_sources.rb
lib/cocoapods/external_sources.rb
+31
-5
external_sources_spec.rb
spec/unit/external_sources_spec.rb
+41
-8
No files found.
lib/cocoapods/external_sources.rb
View file @
e9862578
...
...
@@ -268,10 +268,9 @@ module Pod
#
def
fetch
(
sandbox
)
UI
.
titled_section
(
"Fetching podspec for `
#{
name
}
`
#{
description
}
"
,
{
:verbose_prefix
=>
"-> "
})
do
path
=
params
[
:podspec
]
path
=
Pathname
.
new
(
path
).
expand_path
if
path
.
to_s
.
start_with?
(
"~"
)
require
'open-uri'
open
(
p
ath
)
{
|
io
|
store_podspec
(
sandbox
,
io
.
read
)
}
open
(
p
odspec_uri
)
{
|
io
|
store_podspec
(
sandbox
,
io
.
read
)
}
end
end
...
...
@@ -280,6 +279,30 @@ module Pod
def
description
"from `
#{
params
[
:podspec
]
}
`"
end
#--------------------------------------#
private
# @!group Helpers
# @return [String] The uri of the podspec appending the name of the file
# and expanding it if necessary.
#
# @note If the declared path is expanded only if the represents a path
# relative to the file system.
#
def
podspec_uri
declared_path
=
params
[
:podspec
].
to_s
if
declared_path
.
match
(
%r{^.+://}
)
declared_path
else
path_with_ext
=
File
.
extname
(
declared_path
)
==
'.podspec'
?
declared_path
:
"
#{
declared_path
}
/
#{
name
}
.podspec"
podfile_dir
=
File
.
dirname
(
podfile_path
||
''
)
absolute_path
=
File
.
expand_path
(
path_with_ext
,
podfile_dir
)
absolute_path
end
end
end
#-------------------------------------------------------------------------#
...
...
@@ -295,7 +318,7 @@ module Pod
#
def
fetch
(
sandbox
)
UI
.
titled_section
(
"Fetching podspec for `
#{
name
}
`
#{
description
}
"
,
{
:verbose_prefix
=>
"-> "
})
do
podspec
=
pod
_
spec_path
podspec
=
podspec_path
store_podspec
(
sandbox
,
podspec
)
sandbox
.
store_local_path
(
name
,
podspec
.
dirname
)
end
...
...
@@ -315,7 +338,7 @@ module Pod
# @return [Pathname] the path of the podspec.
#
def
pod
_
spec_path
def
podspec_path
declared_path
=
params
[
:local
].
to_s
path_with_ext
=
File
.
extname
(
declared_path
)
==
'.podspec'
?
declared_path
:
"
#{
declared_path
}
/
#{
name
}
.podspec"
podfile_dir
=
File
.
dirname
(
podfile_path
||
''
)
...
...
@@ -328,5 +351,8 @@ module Pod
pathname
end
end
#-------------------------------------------------------------------------#
end
end
spec/unit/external_sources_spec.rb
View file @
e9862578
...
...
@@ -151,7 +151,8 @@ module Pod
before
do
podspec_path
=
fixture
(
'integration/Reachability/Reachability.podspec'
)
dependency
=
Dependency
.
new
(
"Reachability"
,
:podspec
=>
podspec_path
.
to_s
)
@external_source
=
ExternalSources
.
from_dependency
(
dependency
,
nil
)
podfile_path
=
fixture
(
'integration/Podfile'
)
@external_source
=
ExternalSources
.
from_dependency
(
dependency
,
podfile_path
)
end
it
"creates a copy of the podspec"
do
...
...
@@ -163,6 +164,40 @@ module Pod
it
"returns the description"
do
@external_source
.
description
.
should
.
match
%r|from `.*Reachability/Reachability.podspec`|
end
describe
"Helpers"
do
it
"handles absolute paths"
do
@external_source
.
stubs
(
:params
).
returns
(
:podspec
=>
fixture
(
'integration/Reachability'
))
path
=
@external_source
.
send
(
:podspec_uri
)
path
.
should
==
fixture
(
'integration/Reachability/Reachability.podspec'
).
to_s
end
it
"handles paths when there is no podfile path"
do
@external_source
.
stubs
(
:podfile_path
).
returns
(
nil
)
@external_source
.
stubs
(
:params
).
returns
(
:podspec
=>
fixture
(
'integration/Reachability'
))
path
=
@external_source
.
send
(
:podspec_uri
)
path
.
should
==
fixture
(
'integration/Reachability/Reachability.podspec'
).
to_s
end
it
"handles relative paths"
do
@external_source
.
stubs
(
:params
).
returns
(
:podspec
=>
'Reachability'
)
path
=
@external_source
.
send
(
:podspec_uri
)
path
.
should
==
fixture
(
'integration/Reachability/Reachability.podspec'
).
to_s
end
it
"expands the tilde"
do
@external_source
.
stubs
(
:params
).
returns
(
:podspec
=>
'~/Reachability'
)
path
=
@external_source
.
send
(
:podspec_uri
)
path
.
should
==
ENV
[
'HOME'
]
+
'/Reachability/Reachability.podspec'
end
it
"handles urls"
do
@external_source
.
stubs
(
:params
).
returns
(
:podspec
=>
"http://www.example.com/Reachability.podspec"
)
path
=
@external_source
.
send
(
:podspec_uri
)
path
.
should
==
"http://www.example.com/Reachability.podspec"
end
end
end
#---------------------------------------------------------------------------#
...
...
@@ -197,38 +232,36 @@ module Pod
it
"handles absolute paths"
do
@external_source
.
stubs
(
:params
).
returns
(
:local
=>
fixture
(
'integration/Reachability'
))
path
=
@external_source
.
send
(
:pod
_
spec_path
)
path
=
@external_source
.
send
(
:podspec_path
)
path
.
should
==
fixture
(
'integration/Reachability/Reachability.podspec'
)
end
it
"handles paths when there is no podfile path"
do
@external_source
.
stubs
(
:podfile_path
).
returns
(
nil
)
@external_source
.
stubs
(
:params
).
returns
(
:local
=>
fixture
(
'integration/Reachability'
))
path
=
@external_source
.
send
(
:pod
_
spec_path
)
path
=
@external_source
.
send
(
:podspec_path
)
path
.
should
==
fixture
(
'integration/Reachability/Reachability.podspec'
)
end
it
"handles relative paths"
do
@external_source
.
stubs
(
:params
).
returns
(
:local
=>
'Reachability'
)
path
=
@external_source
.
send
(
:pod
_
spec_path
)
path
=
@external_source
.
send
(
:podspec_path
)
path
.
should
==
fixture
(
'integration/Reachability/Reachability.podspec'
)
end
it
"expands the tilde"
do
@external_source
.
stubs
(
:params
).
returns
(
:local
=>
'~/Reachability'
)
Pathname
.
any_instance
.
stubs
(
:exist?
).
returns
(
true
)
path
=
@external_source
.
send
(
:pod
_
spec_path
)
path
=
@external_source
.
send
(
:podspec_path
)
path
.
should
==
Pathname
(
ENV
[
'HOME'
])
+
'Reachability/Reachability.podspec'
end
it
"raises if the podspec cannot be found"
do
@external_source
.
stubs
(
:params
).
returns
(
:local
=>
temporary_directory
)
e
=
lambda
{
@external_source
.
send
(
:pod
_
spec_path
)
}.
should
.
raise
Informative
e
=
lambda
{
@external_source
.
send
(
:podspec_path
)
}.
should
.
raise
Informative
e
.
message
.
should
.
match
/No podspec found/
end
end
end
#---------------------------------------------------------------------------#
...
...
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