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
8a1a5d30
Commit
8a1a5d30
authored
May 29, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Repo] Class method to return if a repo is compatible.
parent
4ee2fc68
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
17 deletions
+111
-17
repo.rb
lib/cocoapods/command/repo.rb
+49
-14
repo_spec.rb
spec/functional/command/repo_spec.rb
+21
-3
repo_spec.rb
spec/unit/command/repo_spec.rb
+41
-0
No files found.
lib/cocoapods/command/repo.rb
View file @
8a1a5d30
...
@@ -58,24 +58,59 @@ module Pod
...
@@ -58,24 +58,59 @@ module Pod
end
end
def
check_versions
(
dir
)
def
check_versions
(
dir
)
require
'yaml'
versions
=
versions
(
dir
)
bin_version
=
Gem
::
Version
.
new
(
VERSION
)
unless
is_compatilbe
(
versions
)
yaml_file
=
dir
+
'CocoaPods-version.yml'
min
,
max
=
versions
[
'min'
],
versions
[
'max'
]
return
unless
yaml_file
.
exist?
version_msg
=
(
min
==
max
)
?
min
:
"
#{
min
}
-
#{
max
}
"
data
=
YAML
.
load_file
(
yaml_file
)
min_version
=
Gem
::
Version
.
new
(
data
[
'min'
])
if
data
[
'min'
]
max_version
=
Gem
::
Version
.
new
(
data
[
'max'
])
if
data
[
'max'
]
last_version
=
Gem
::
Version
.
new
(
data
[
'last'
])
if
data
[
'last'
]
supports_min
=
min_version
?
bin_version
>=
min_version
:
true
supports_max
=
max_version
?
bin_version
<=
max_version
:
true
unless
supports_min
&&
supports_max
version_msg
=
(
min_version
==
max_version
)
?
min_version
:
"
#{
min_version
}
-
#{
max_version
}
"
raise
Informative
,
raise
Informative
,
"
\n
[!] The `
#{
dir
.
basename
.
to_s
}
' repo requires CocoaPods
#{
min_version
}
\n
"
.
red
+
"
\n
[!] The `
#{
dir
.
basename
.
to_s
}
' repo requires CocoaPods
#{
version_msg
}
\n
"
.
red
+
"Update Cocoapods, or checkout the appropriate tag in the repo.
\n\n
"
"Update Cocoapods, or checkout the appropriate tag in the repo.
\n\n
"
end
end
puts
"
\n
Cocoapods
#{
last_version
}
is available.
\n
"
.
green
if
last_version
&&
last_version
>
bin_version
puts
"
\n
Cocoapods
#{
versions
[
'last'
]
}
is available.
\n
"
.
green
if
has_update
(
versions
)
end
def
self
.
is_compatible
(
name
)
dir
=
Config
.
instance
.
repos_dir
+
name
versions
=
versions
(
dir
)
is_compatilbe
(
versions
)
end
private
def
versions
(
dir
)
self
.
class
.
versions
(
dir
)
end
def
self
.
versions
(
dir
)
require
'yaml'
yaml_file
=
dir
+
'CocoaPods-version.yml'
yaml_file
.
exist?
?
YAML
.
load_file
(
yaml_file
)
:
{}
end
def
is_compatilbe
(
versions
)
self
.
class
.
is_compatilbe
(
versions
)
end
def
self
.
is_compatilbe
(
versions
)
min
,
max
=
versions
[
'min'
],
versions
[
'max'
]
supports_min
=
!
min
||
bin_version
>=
Gem
::
Version
.
new
(
min
)
supports_max
=
!
max
||
bin_version
<=
Gem
::
Version
.
new
(
max
)
supports_min
&&
supports_max
end
def
has_update
(
versions
)
self
.
class
.
has_update
(
versions
)
end
end
def
self
.
has_update
(
versions
)
last
=
versions
[
'last'
]
last
&&
Gem
::
Version
.
new
(
last
)
>
bin_version
end
def
self
.
bin_version
Gem
::
Version
.
new
(
VERSION
)
end
end
end
end
end
end
end
...
...
spec/functional/command/repo_spec.rb
View file @
8a1a5d30
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
describe
"Pod::Command::Repo"
do
describe
"Pod::Command::Repo"
do
describe
"In general"
do
extend
SpecHelper
::
Command
extend
SpecHelper
::
Command
extend
SpecHelper
::
TemporaryDirectory
extend
SpecHelper
::
TemporaryDirectory
extend
SpecHelper
::
TemporaryRepos
extend
SpecHelper
::
TemporaryRepos
...
@@ -39,6 +40,12 @@ describe "Pod::Command::Repo" do
...
@@ -39,6 +40,12 @@ describe "Pod::Command::Repo" do
(
repo2
.
dir
+
'README'
).
read
.
should
.
include
'Added!'
(
repo2
.
dir
+
'README'
).
read
.
should
.
include
'Added!'
(
repo3
.
dir
+
'README'
).
read
.
should
.
include
'Added!'
(
repo3
.
dir
+
'README'
).
read
.
should
.
include
'Added!'
end
end
end
describe
"Concerning a repo support"
do
extend
SpecHelper
::
Command
extend
SpecHelper
::
TemporaryDirectory
extend
SpecHelper
::
TemporaryRepos
before
do
before
do
add_repo
(
'repo1'
,
fixture
(
'spec-repos/master'
))
add_repo
(
'repo1'
,
fixture
(
'spec-repos/master'
))
...
@@ -57,20 +64,31 @@ describe "Pod::Command::Repo" do
...
@@ -57,20 +64,31 @@ describe "Pod::Command::Repo" do
end
end
it
"runs with a compatible repo"
do
it
"runs with a compatible repo"
do
yaml
=
YAML
.
dump
({
:min
=>
"0.0.1"
})
yaml
=
YAML
.
dump
({
'min'
=>
"0.0.1"
})
File
.
open
(
versions_file
,
'w'
)
{
|
f
|
f
.
write
(
yaml
)
}
File
.
open
(
versions_file
,
'w'
)
{
|
f
|
f
.
write
(
yaml
)
}
lambda
{
run_command
(
'repo'
,
'update'
)
}.
should
.
not
.
raise
lambda
{
run_command
(
'repo'
,
'update'
)
}.
should
.
not
.
raise
end
end
it
"raises if a repo is not compatible"
do
it
"raises if a repo is not compatible"
do
yaml
=
YAML
.
dump
({
:min
=>
"999.0.0"
})
yaml
=
YAML
.
dump
({
'min'
=>
"999.0.0"
})
File
.
open
(
versions_file
,
'w'
)
{
|
f
|
f
.
write
(
yaml
)
}
File
.
open
(
versions_file
,
'w'
)
{
|
f
|
f
.
write
(
yaml
)
}
lambda
{
run_command
(
'repo'
,
'update'
)
}.
should
.
raise
Pod
::
Informative
lambda
{
run_command
(
'repo'
,
'update'
)
}.
should
.
raise
Pod
::
Informative
end
end
it
"informs about a higher known CocoaPods version"
do
it
"informs about a higher known CocoaPods version"
do
yaml
=
YAML
.
dump
({
:last
=>
"999.0.0"
})
yaml
=
YAML
.
dump
({
'last'
=>
"999.0.0"
})
File
.
open
(
versions_file
,
'w'
)
{
|
f
|
f
.
write
(
yaml
)
}
File
.
open
(
versions_file
,
'w'
)
{
|
f
|
f
.
write
(
yaml
)
}
run_command
(
'repo'
,
'update'
).
should
.
include
"Cocoapods 999.0.0 is available"
run_command
(
'repo'
,
'update'
).
should
.
include
"Cocoapods 999.0.0 is available"
end
end
it
"has a class method that returns if a repo is supported"
do
yaml
=
YAML
.
dump
({
'min'
=>
"999.0.0"
})
File
.
open
(
versions_file
,
'w'
)
{
|
f
|
f
.
write
(
yaml
)
}
Pod
::
Command
::
Repo
.
is_compatible
(
'repo1'
).
should
==
false
yaml
=
YAML
.
dump
({
'min'
=>
"0.0.1"
})
File
.
open
(
versions_file
,
'w'
)
{
|
f
|
f
.
write
(
yaml
)
}
Pod
::
Command
::
Repo
.
is_compatible
(
'repo1'
).
should
==
true
end
end
end
end
spec/unit/command/repo_spec.rb
0 → 100644
View file @
8a1a5d30
require
File
.
expand_path
(
'../../../spec_helper'
,
__FILE__
)
describe
"Pod::Command::Repo"
do
extend
SpecHelper
::
Command
before
do
@command
=
command
(
'repo'
,
'update'
)
@command
.
stubs
(
:bin_version
).
returns
(
Gem
::
Version
.
new
(
'0.6.0.rc1'
))
end
it
"supports a repo with a compatible minimum version"
do
versions
=
{
'min'
=>
'0.5'
}
@command
.
class
.
send
(
:is_compatilbe
,
versions
).
should
==
true
end
it
"doesn't supports a repo with a compatible minimum version"
do
versions
=
{
'min'
=>
'0.7'
}
@command
.
class
.
send
(
:is_compatilbe
,
versions
).
should
==
false
end
it
"supports a repo with a compatible maximum version"
do
versions
=
{
'max'
=>
'0.7'
}
@command
.
class
.
send
(
:is_compatilbe
,
versions
).
should
==
true
end
it
"doesn't supports a repo with a compatible maximum version"
do
versions
=
{
'max'
=>
'0.5'
}
@command
.
class
.
send
(
:is_compatilbe
,
versions
).
should
==
false
end
it
"detects if an update is available"
do
versions
=
{
'last'
=>
'0.5'
}
@command
.
class
.
send
(
:has_update
,
versions
).
should
==
false
end
it
"detects if no update is available"
do
versions
=
{
'last'
=>
'0.7'
}
@command
.
class
.
send
(
:has_update
,
versions
).
should
==
true
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