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
0b264e6e
Commit
0b264e6e
authored
Feb 04, 2013
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Installer::FileReferencesInstaller
parent
b2fcbbb2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
170 additions
and
0 deletions
+170
-0
file_references_installer.rb
lib/cocoapods/installer/file_references_installer.rb
+113
-0
file_references_installer_spec.rb
spec/unit/installer/file_references_installer_spec.rb
+57
-0
No files found.
lib/cocoapods/installer/file_references_installer.rb
0 → 100644
View file @
0b264e6e
module
Pod
class
Installer
# Controller class responsible of installing the file references of the
# specifications in the Pods project.
#
class
FileReferencesInstaller
# @return [Sandbox] The sandbox of the installation.
#
attr_reader
:sandbox
# @return [Array<Library>] The libraries of the installation.
#
attr_reader
:libraries
# @return [Project] The Pods project.
#
attr_reader
:pods_project
# @param [Sandbox] sandbox @see sandbox
# @param [Array<Library>] libraries @see libraries
# @param [Project] libraries @see libraries
#
def
initialize
(
sandbox
,
libraries
,
pods_project
)
@sandbox
=
sandbox
@libraries
=
libraries
@pods_project
=
pods_project
end
# Installs the file references.
#
# @return [void]
#
def
install!
add_source_files_references
add_resources_references
end
#-----------------------------------------------------------------------#
private
# @!group Installation Steps
# Adds the source files of the Pods to the Pods project.
#
# @note The source files are grouped by Pod and in turn by subspec
# (recursively).
#
# @note Pods are generally added to the `Pods` group, however, if they
# have a local source they are added to the
# `Local Pods` group.
#
# @return [void]
#
def
add_source_files_references
UI
.
message
"- Adding source files to Pods project"
do
file_accessors
.
each
do
|
file_accessor
|
files
=
file_accessor
.
source_files
spec_name
=
file_accessor
.
spec
.
name
local
=
file_accessor
.
spec
.
local?
parent_group
=
local
?
pods_project
.
local_pods
:
pods_project
.
pods
parent_group
=
pods_project
.
pods
pods_project
.
add_file_references
(
files
,
spec_name
,
parent_group
)
end
end
end
# Adds the resources of the Pods to the Pods project.
#
# @note The source files are grouped by Pod and in turn by subspec
# (recursively) in the resources group.
#
# @return [void]
#
def
add_resources_references
UI
.
message
"- Adding resources to Pods project"
do
file_accessors
.
each
do
|
file_accessor
|
file_accessor
.
resources
.
each
do
|
destination
,
resources
|
next
if
resources
.
empty?
files
=
file_accessor
.
resources
.
values
.
flatten
spec_name
=
file_accessor
.
spec
.
name
parent_group
=
pods_project
.
resources
pods_project
.
add_file_references
(
files
,
spec_name
,
parent_group
)
end
end
end
end
#-----------------------------------------------------------------------#
private
# @!group Private Helpers
# @return [Array<Sandbox::FileAccessor>] The file accessors for all the
# specs platform combinations.
#
# TODO Ideally the file accessors should be created one per spec per
# platform in a single installation.
#
def
file_accessors
@file_accessors
||=
libraries
.
map
(
&
:file_accessors
).
flatten
end
#-----------------------------------------------------------------------#
end
end
end
spec/unit/installer/file_references_installer_spec.rb
0 → 100644
View file @
0b264e6e
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
module
Pod
describe
Installer
::
PodSourceInstaller
do
before
do
file_accessor
=
fixture_file_accessor
(
'banana-lib/BananaLib.podspec'
)
@library
=
Library
.
new
(
nil
)
@library
.
file_accessors
=
[
file_accessor
]
@project
=
Project
.
new
(
config
.
sandbox
.
project_path
)
@installer
=
Installer
::
FileReferencesInstaller
.
new
(
config
.
sandbox
,
[
@library
],
@project
)
end
#-------------------------------------------------------------------------#
describe
"Installation"
do
it
"adds the files references of the source files the Pods project"
do
@installer
.
install!
group_ref
=
@installer
.
pods_project
[
'Pods/BananaLib'
]
group_ref
.
should
.
be
.
not
.
nil
file_ref
=
@installer
.
pods_project
[
'Pods/BananaLib/Banana.m'
]
file_ref
.
should
.
be
.
not
.
nil
file_ref
.
path
.
should
==
"../../spec/fixtures/banana-lib/Classes/Banana.m"
end
it
"adds the files references of the resources the Pods project"
do
@installer
.
install!
group_ref
=
@installer
.
pods_project
[
'Resources/BananaLib'
]
group_ref
.
should
.
be
.
not
.
nil
file_ref
=
@installer
.
pods_project
[
'Resources/BananaLib/logo-sidebar.png'
]
file_ref
.
should
.
be
.
not
.
nil
file_ref
.
path
.
should
==
"../../spec/fixtures/banana-lib/Resources/logo-sidebar.png"
end
end
#-------------------------------------------------------------------------#
describe
"Private Helpers"
do
xit
"returns the unique file accessors"
do
library_1
=
Library
.
new
(
nil
)
library_1
.
file_accessors
=
[
fixture_file_accessor
(
'banana-lib/BananaLib.podspec'
)]
library_2
=
Library
.
new
(
nil
)
library_2
.
file_accessors
=
[
fixture_file_accessor
(
'banana-lib/BananaLib.podspec'
)]
installer
=
Installer
::
FileReferencesInstaller
.
new
(
config
.
sandbox
,
[
library_1
,
library_2
],
@project
)
installer
.
send
(
:file_accessors
).
count
.
should
==
1
end
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