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
2b4e6250
Commit
2b4e6250
authored
Nov 05, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use ActiveSupport to clean a bit up and remove some dead code.
parent
ec3d6542
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
19 deletions
+13
-19
project.rb
lib/cocoapods/xcode/project.rb
+12
-19
spec_helper.rb
spec/spec_helper.rb
+1
-0
No files found.
lib/cocoapods/xcode/project.rb
View file @
2b4e6250
framework
'Foundation'
require
'fileutils'
require
'active_support/inflector'
require
'active_support/core_ext/string/inflections'
module
Pod
module
Xcode
class
Project
...
...
@@ -17,8 +20,7 @@ module Pod
end
def
self
.
has_many
(
plural_attr_name
,
options
=
{},
&
block
)
klass
=
options
[
:class
]
||
PBXFileReference
singular_attr_name
=
options
[
:singular
]
||
plural_attr_name
.
to_s
[
0
..-
2
]
# strip off 's'
klass
=
options
[
:class
]
||
Project
.
const_get
(
"PBX
#{
plural_attr_name
.
to_s
.
classify
}
"
)
if
options
[
:fkey_on_target
]
define_method
(
plural_attr_name
)
do
scoped
=
@project
.
objects
.
select_by_class
(
klass
).
select
do
|
object
|
...
...
@@ -29,7 +31,8 @@ module Pod
end
end
else
uuid_list_name
=
options
[
:uuid
]
||
"
#{
singular_attr_name
}
References"
singular_attr_name
=
plural_attr_name
.
to_s
.
singularize
uuid_list_name
=
"
#{
singular_attr_name
}
References"
attribute
(
plural_attr_name
,
uuid_list_name
)
define_method
(
plural_attr_name
)
do
uuids
=
send
(
uuid_list_name
)
...
...
@@ -50,7 +53,7 @@ module Pod
def
self
.
belongs_to
(
singular_attr_name
,
options
=
{})
if
uuid_name
=
options
[
:uuids
]
# part of another objects uuid list
klass
=
options
[
:class
]
klass
=
options
[
:class
]
||
Project
.
const_get
(
"PBX
#{
singular_attr_name
.
to_s
.
classify
}
"
)
define_method
(
singular_attr_name
)
do
# Loop over all objects of the class and find the one that includes
# this object in the specified uuid list.
...
...
@@ -80,16 +83,6 @@ module Pod
end
end
def
self
.
has_one
(
singular_attr_name
,
options
=
{})
klass
=
options
[
:class
]
uuid_name
=
options
[
:uuid
]
||
"
#{
singular_attr_name
}
Reference"
define_method
(
singular_attr_name
)
do
@project
.
objects
.
select_by_class
(
klass
).
find
do
|
object
|
object
.
respond_to?
(
uuid_name
)
&&
object
.
send
(
uuid_name
)
==
self
.
uuid
end
end
end
def
self
.
isa
@isa
||=
name
.
split
(
'::'
).
last
end
...
...
@@ -157,8 +150,8 @@ module Pod
class
PBXFileReference
<
PBXObject
attributes
:path
,
:sourceTree
,
:explicitFileType
,
:includeInIndex
has_many
:buildFiles
,
:uuid
=>
:fileRef
,
:fkey_on_target
=>
true
,
:class
=>
Project
::
PBXBuildFile
belongs_to
:group
,
:
class
=>
Project
::
PBXGroup
,
:
uuids
=>
:childReferences
has_many
:buildFiles
,
:uuid
=>
:fileRef
,
:fkey_on_target
=>
true
belongs_to
:group
,
:uuids
=>
:childReferences
def
initialize
(
project
,
uuid
,
attributes
)
is_new
=
uuid
.
nil?
...
...
@@ -185,7 +178,7 @@ module Pod
class
PBXGroup
<
PBXObject
attributes
:sourceTree
has_many
:children
,
:
singular
=>
:child
do
|
object
|
has_many
:children
,
:
class
=>
PBXFileReference
do
|
object
|
if
object
.
is_a?
(
Pod
::
Xcode
::
Project
::
PBXFileReference
)
# Associating the file to this group through the inverse
# association will also remove it from the group it was in.
...
...
@@ -272,8 +265,8 @@ module Pod
attributes
:productName
,
:productType
has_many
:buildPhases
,
:class
=>
PBXBuildPhase
has_many
:dependencies
,
:singular
=>
:dependency
# TODO :class => ?
has_many
:buildPhases
has_many
:dependencies
# TODO :class => ?
has_many
:buildRules
# TODO :class => ?
belongs_to
:buildConfigurationList
belongs_to
:product
,
:uuid
=>
:productReference
...
...
spec/spec_helper.rb
View file @
2b4e6250
...
...
@@ -4,6 +4,7 @@ require 'mac_bacon'
require
'pathname'
ROOT
=
Pathname
.
new
(
File
.
expand_path
(
'../../'
,
__FILE__
))
gem
'activesupport'
,
'~> 3.1.1'
$:
.
unshift
((
ROOT
+
'lib'
).
to_s
)
require
'cocoapods'
...
...
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