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
8e74ed69
Commit
8e74ed69
authored
Nov 20, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ExternalSources module extracted from Dependency.
parent
5c49e612
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
176 additions
and
5 deletions
+176
-5
cocoapods.rb
lib/cocoapods.rb
+6
-5
external_sources.rb
lib/cocoapods/external_sources.rb
+130
-0
external_sources_spec.rb
spec/unit/external_sources_spec.rb
+40
-0
No files found.
lib/cocoapods.rb
View file @
8e74ed69
...
...
@@ -27,6 +27,7 @@ module Pod
autoload
:Command
,
'cocoapods/command'
autoload
:Downloader
,
'cocoapods/downloader'
autoload
:Executable
,
'cocoapods/executable'
autoload
:ExternalSources
,
'cocoapods/external_sources'
autoload
:Installer
,
'cocoapods/installer'
autoload
:LocalPod
,
'cocoapods/local_pod'
autoload
:Project
,
'cocoapods/project'
...
...
@@ -46,12 +47,12 @@ module Pod
autoload
:DummySource
,
'cocoapods/generator/dummy_source'
autoload
:PrefixHeader
,
'cocoapods/generator/prefix_header'
end
end
require
'cocoapods/file_list'
require
'cocoapods-core'
require
'cocoapods/config'
require
'cocoapods/source'
require
'cocoapods/file_list'
require
'cocoapods-core'
require
'cocoapods/config'
require
'cocoapods/source'
end
if
ENV
[
'COCOA_PODS_ENV'
]
==
'development'
require
'awesome_print'
...
...
lib/cocoapods/external_sources.rb
0 → 100644
View file @
8e74ed69
module
Pod
module
ExternalSources
def
self
.
from_dependency
(
dependency
)
name
=
dependency
.
root_name
params
=
dependency
.
external_source
if
params
.
key?
(
:git
)
GitSource
.
new
(
name
,
params
)
elsif
params
.
key?
(
:podspec
)
PodspecSource
.
new
(
name
,
params
)
elsif
params
.
key?
(
:local
)
LocalSource
.
new
(
name
,
params
)
else
raise
Informative
,
"Unknown external source parameters for
#{
name
}
:
#{
params
}
"
end
end
class
AbstractExternalSource
include
Config
::
Mixin
attr_reader
:name
,
:params
def
initialize
(
name
,
params
)
@name
,
@params
=
name
,
params
end
def
specification_from_sandbox
(
sandbox
,
platform
)
specification_from_local
(
sandbox
,
platform
)
||
specification_from_external
(
sandbox
,
platform
)
end
def
specification_from_local
(
sandbox
,
platform
)
if
local_pod
=
sandbox
.
installed_pod_named
(
name
,
platform
)
local_pod
.
top_specification
end
end
def
specification_from_external
(
sandbox
,
platform
)
podspec
=
copy_external_source_into_sandbox
(
sandbox
,
platform
)
spec
=
specification_from_local
(
sandbox
,
platform
)
raise
Informative
,
"No podspec found for `
#{
name
}
' in
#{
description
}
"
unless
spec
spec
end
# Can store from a pathname or a string
#
def
store_podspec
(
sandbox
,
podspec
)
output_path
=
sandbox
.
root
+
"Local Podspecs/
#{
name
}
.podspec"
output_path
.
dirname
.
mkpath
if
podspec
.
is_a?
(
String
)
raise
Informative
,
"No podspec found for `
#{
name
}
' in
#{
description
}
"
unless
podspec
.
include?
(
'Spec.new'
)
output_path
.
open
(
'w'
)
{
|
f
|
f
.
puts
(
podspec
)
}
else
raise
Informative
,
"No podspec found for `
#{
name
}
' in
#{
description
}
"
unless
podspec
.
exist?
FileUtils
.
copy
(
podspec
,
output_path
)
end
end
def
==
(
other
)
return
if
other
.
nil?
name
==
other
.
name
&&
params
==
other
.
params
end
end
class
GitSource
<
AbstractExternalSource
def
copy_external_source_into_sandbox
(
sandbox
,
platform
)
UI
.
info
(
"->"
.
green
+
" Pre-downloading: '
#{
name
}
'"
)
do
target
=
sandbox
.
root
+
name
target
.
rmtree
if
target
.
exist?
downloader
=
Downloader
.
for_target
(
sandbox
.
root
+
name
,
@params
)
downloader
.
download
store_podspec
(
sandbox
,
target
+
"
#{
name
}
.podspec"
)
if
local_pod
=
sandbox
.
installed_pod_named
(
name
,
platform
)
local_pod
.
downloaded
=
true
end
end
end
def
description
"from `
#{
@params
[
:git
]
}
'"
.
tap
do
|
description
|
description
<<
", commit `
#{
@params
[
:commit
]
}
'"
if
@params
[
:commit
]
description
<<
", branch `
#{
@params
[
:branch
]
}
'"
if
@params
[
:branch
]
description
<<
", tag `
#{
@params
[
:tag
]
}
'"
if
@params
[
:tag
]
end
end
end
# can be http, file, etc
class
PodspecSource
<
AbstractExternalSource
def
copy_external_source_into_sandbox
(
sandbox
,
_
)
UI
.
info
(
"->"
.
green
+
" Fetching podspec for `
#{
name
}
' from:
#{
@params
[
:podspec
]
}
"
)
do
path
=
@params
[
:podspec
]
path
=
Pathname
.
new
(
path
).
expand_path
if
path
.
start_with?
(
"~"
)
open
(
path
)
{
|
io
|
store_podspec
(
sandbox
,
io
.
read
)
}
end
end
def
description
"from `
#{
@params
[
:podspec
]
}
'"
end
end
class
LocalSource
<
AbstractExternalSource
def
pod_spec_path
path
=
Pathname
.
new
(
@params
[
:local
]).
expand_path
path
+=
"
#{
name
}
.podspec"
# unless path.to_s.include?("#{name}.podspec")
raise
Informative
,
"No podspec found for `
#{
name
}
' in `
#{
@params
[
:local
]
}
'"
unless
path
.
exist?
path
end
def
copy_external_source_into_sandbox
(
sandbox
,
_
)
store_podspec
(
sandbox
,
pod_spec_path
)
end
def
specification_from_local
(
sandbox
,
platform
)
specification_from_external
(
sandbox
,
platform
)
end
def
specification_from_external
(
sandbox
,
platform
)
copy_external_source_into_sandbox
(
sandbox
,
platform
)
spec
=
Specification
.
from_file
(
pod_spec_path
)
spec
.
source
=
@params
spec
end
def
description
"from `
#{
@params
[
:local
]
}
'"
end
end
end
end
spec/unit/external_sources_spec.rb
0 → 100644
View file @
8e74ed69
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
module
Pod
describe
ExternalSources
do
before
do
@sandbox
=
temporary_sandbox
end
it
"marks a LocalPod as downloaded if it's from GitSource"
do
dependency
=
Dependency
.
new
(
"Reachability"
,
:git
=>
fixture
(
'integration/Reachability'
))
external_source
=
ExternalSources
.
from_dependency
(
dependency
)
external_source
.
copy_external_source_into_sandbox
(
@sandbox
,
Platform
.
ios
)
@sandbox
.
installed_pod_named
(
'Reachability'
,
Platform
.
ios
).
downloaded
.
should
.
be
.
true
end
it
"creates a copy of the podspec (GitSource)"
do
dependency
=
Dependency
.
new
(
"Reachability"
,
:git
=>
fixture
(
'integration/Reachability'
))
external_source
=
ExternalSources
.
from_dependency
(
dependency
)
external_source
.
copy_external_source_into_sandbox
(
@sandbox
,
Platform
.
ios
)
path
=
@sandbox
.
root
+
'Local Podspecs/Reachability.podspec'
path
.
should
.
exist?
end
it
"creates a copy of the podspec (PodspecSource)"
do
dependency
=
Dependency
.
new
(
"Reachability"
,
:podspec
=>
fixture
(
'integration/Reachability/Reachability.podspec'
).
to_s
)
external_source
=
ExternalSources
.
from_dependency
(
dependency
)
external_source
.
copy_external_source_into_sandbox
(
@sandbox
,
Platform
.
ios
)
path
=
@sandbox
.
root
+
'Local Podspecs/Reachability.podspec'
path
.
should
.
exist?
end
it
"creates a copy of the podspec (LocalSource)"
do
dependency
=
Dependency
.
new
(
"Reachability"
,
:local
=>
fixture
(
'integration/Reachability'
))
external_source
=
ExternalSources
.
from_dependency
(
dependency
)
external_source
.
copy_external_source_into_sandbox
(
@sandbox
,
Platform
.
ios
)
path
=
@sandbox
.
root
+
'Local Podspecs/Reachability.podspec'
path
.
should
.
exist?
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