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
2e909ac2
Commit
2e909ac2
authored
Aug 14, 2011
by
Eloy Duran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement `repo add`.
parent
7ce508b5
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
29 deletions
+66
-29
command.rb
lib/cocoa_pods/command.rb
+3
-2
repo.rb
lib/cocoa_pods/command/repo.rb
+33
-0
setup.rb
lib/cocoa_pods/command/setup.rb
+6
-15
command_spec.rb
spec/functional/command_spec.rb
+10
-5
git.rb
spec/spec_helper/git.rb
+4
-4
command_spec.rb
spec/unit/command_spec.rb
+10
-3
No files found.
lib/cocoa_pods/command.rb
View file @
2e909ac2
...
@@ -17,10 +17,11 @@ module Pod
...
@@ -17,10 +17,11 @@ module Pod
end
end
def
initialize
(
*
argv
)
def
initialize
(
*
argv
)
raise
"unknown argument(s):
#{
argv
.
join
(
', '
)
}
"
unless
argv
.
empty?
raise
ArgumentError
,
"unknown argument(s):
#{
argv
.
join
(
', '
)
}
"
unless
argv
.
empty?
end
end
def
run
def
repos_dir
File
.
expand_path
(
'~/.cocoa-pods'
)
end
end
end
end
end
end
lib/cocoa_pods/command/repo.rb
View file @
2e909ac2
require
'executioner'
require
'fileutils'
module
Pod
module
Pod
class
Command
class
Command
class
Repo
<
Command
class
Repo
<
Command
include
Executioner
executable
:git
def
initialize
(
*
argv
)
case
@action
=
argv
[
0
]
when
'add'
unless
(
@name
=
argv
[
1
])
&&
(
@url
=
argv
[
2
])
raise
ArgumentError
,
"needs a NAME and URL"
end
when
'cd'
unless
@name
=
argv
[
1
]
raise
ArgumentError
,
"needs a NAME"
end
else
super
end
end
def
dir
File
.
join
(
repos_dir
,
@name
)
end
def
run
send
@action
end
def
add
FileUtils
.
mkdir_p
(
repos_dir
)
Dir
.
chdir
(
repos_dir
)
{
git
(
"clone
#{
@url
}
#{
@name
}
"
)
}
end
end
end
end
end
end
end
...
...
lib/cocoa_pods/command/setup.rb
View file @
2e909ac2
require
'fileutils'
require
'cocoa_pods/command/repo'
require
'executioner'
module
Pod
module
Pod
class
Command
class
Command
class
Setup
<
Command
class
Setup
<
Command
include
Executioner
executable
:git
def
repos_dir
File
.
expand_path
(
'~/.cocoa-pods'
)
end
def
master_repo_dir
File
.
join
(
repos_dir
,
'master'
)
end
def
master_repo_url
def
master_repo_url
'git://github.com/alloy/cocoa-pod-specs.git'
'git://github.com/alloy/cocoa-pod-specs.git'
end
end
def
add_master_repo_command
@command
||=
Repo
.
new
(
'add'
,
'master'
,
master_repo_url
)
end
def
run
def
run
FileUtils
.
mkdir_p
(
repos_dir
)
add_master_repo_command
.
run
Dir
.
chdir
(
repos_dir
)
{
git
(
"clone
#{
master_repo_url
}
master"
)
}
end
end
end
end
end
end
...
...
spec/functional/command_spec.rb
View file @
2e909ac2
...
@@ -8,14 +8,19 @@ describe "Pod::Command" do
...
@@ -8,14 +8,19 @@ describe "Pod::Command" do
extend
SpecHelper
::
TemporaryDirectory
extend
SpecHelper
::
TemporaryDirectory
it
"creates the local spec-repos directory and creates a clone of the `master' repo"
do
it
"creates the local spec-repos directory and creates a clone of the `master' repo"
do
#log!
command
=
Pod
::
Command
.
parse
(
'setup'
)
def
command
.
master_repo_url
;
SpecHelper
.
fixture
(
'master-spec-repo.git'
);
end
def
(
command
.
add_master_repo_command
)
.
repos_dir
;
SpecHelper
.
tmp_repos_path
;
end
command
=
Pod
::
Command
.
parse
(
"setup"
)
command
.
run
git_config
(
'master'
,
'remote.origin.url'
).
should
==
fixture
(
'master-spec-repo.git'
)
end
it
"adds a spec-repo"
do
command
=
Pod
::
Command
.
parse
(
'repo'
,
'add'
,
'private'
,
fixture
(
'master-spec-repo.git'
))
def
command
.
repos_dir
;
SpecHelper
.
tmp_repos_path
;
end
def
command
.
repos_dir
;
SpecHelper
.
tmp_repos_path
;
end
def
command
.
master_repo_url
;
SpecHelper
.
fixture
(
'master-spec-repo.git'
);
end
command
.
run
command
.
run
File
.
should
.
exist
command
.
master_repo_dir
git_config
(
'private'
,
'remote.origin.url'
).
should
==
fixture
(
'master-spec-repo.git'
)
git_config
(
'remote.origin.url'
).
should
==
command
.
master_repo_url
end
end
end
end
spec/spec_helper/git.rb
View file @
2e909ac2
...
@@ -20,12 +20,12 @@ module SpecHelper
...
@@ -20,12 +20,12 @@ module SpecHelper
executable
:git
executable
:git
alias_method
:git_super
,
:git
alias_method
:git_super
,
:git
def
git
(
command
)
def
git
(
repo
,
command
)
Dir
.
chdir
(
tmp_master_repo_path
)
{
git_super
(
command
).
strip
}
Dir
.
chdir
(
File
.
join
(
tmp_repos_path
,
repo
)
)
{
git_super
(
command
).
strip
}
end
end
def
git_config
(
attr
)
def
git_config
(
repo
,
attr
)
git
"config --get
#{
attr
}
"
git
repo
,
"config --get
#{
attr
}
"
end
end
end
end
end
end
spec/unit/command_spec.rb
View file @
2e909ac2
...
@@ -11,7 +11,7 @@ end
...
@@ -11,7 +11,7 @@ end
describe
"Pod::Command::Setup"
do
describe
"Pod::Command::Setup"
do
it
"complains about unknown arguments"
do
it
"complains about unknown arguments"
do
lambda
{
Pod
::
Command
::
Setup
.
new
(
'something'
)
}.
should
.
raise
lambda
{
Pod
::
Command
::
Setup
.
new
(
'something'
)
}.
should
.
raise
ArgumentError
end
end
before
do
before
do
...
@@ -25,8 +25,15 @@ describe "Pod::Command::Setup" do
...
@@ -25,8 +25,15 @@ describe "Pod::Command::Setup" do
it
"returns the path of the directory where the local spec-repos will be stored"
do
it
"returns the path of the directory where the local spec-repos will be stored"
do
@command
.
repos_dir
.
should
==
File
.
expand_path
(
"~/.cocoa-pods"
)
@command
.
repos_dir
.
should
==
File
.
expand_path
(
"~/.cocoa-pods"
)
end
end
end
describe
"Pod::Command::Repo"
do
it
"complains about unknown arguments"
do
lambda
{
Pod
::
Command
::
Repo
.
new
(
'something'
)
}.
should
.
raise
ArgumentError
end
it
"returns the path of the directory where the `master' spec-repo will be"
do
it
"returns the path of the spec-repo directory"
do
@command
.
master_repo_dir
.
should
==
File
.
expand_path
(
"~/.cocoa-pods/master"
)
repo
=
Pod
::
Command
::
Repo
.
new
(
'cd'
,
'private'
)
repo
.
dir
.
should
==
File
.
expand_path
(
"~/.cocoa-pods/private"
)
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