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
a66b7cb3
Commit
a66b7cb3
authored
Dec 04, 2012
by
Fabio Pelosin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #673 from rsobik/pod_spec_cat
Adds pod spec cat subcommand
parents
482c9589
b3f6eb2a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
0 deletions
+76
-0
CHANGELOG.md
CHANGELOG.md
+2
-0
spec.rb
lib/cocoapods/command/spec.rb
+50
-0
spec_spec.rb
spec/functional/command/spec_spec.rb
+24
-0
No files found.
CHANGELOG.md
View file @
a66b7cb3
...
@@ -13,6 +13,8 @@
...
@@ -13,6 +13,8 @@
-
Added Podfile to the Pods project.
-
Added Podfile to the Pods project.
[
#476
](
https://github.com/CocoaPods/CocoaPods/issues/476
)
[
#476
](
https://github.com/CocoaPods/CocoaPods/issues/476
)
-
Adds new subcommand
`pod spec cat NAME`
to print a spec file to standard output.
## Master
## Master
[
CocoaPods
](
https://github.com/CocoaPods/CocoaPods/compare/0.16.0.rc2...master
)
•
[
Xcodeproj
](
https://github.com/CocoaPods/Xcodeproj/compare/0.4.0.rc1...master
)
[
CocoaPods
](
https://github.com/CocoaPods/CocoaPods/compare/0.16.0.rc2...master
)
•
[
Xcodeproj
](
https://github.com/CocoaPods/Xcodeproj/compare/0.4.0.rc1...master
)
...
...
lib/cocoapods/command/spec.rb
View file @
a66b7cb3
...
@@ -126,6 +126,56 @@ module Pod
...
@@ -126,6 +126,56 @@ module Pod
end
end
end
end
class
Cat
<
Spec
self
.
summary
=
'Prints a spec file'
self
.
description
=
<<-
DESC
Prints `NAME.podspec` to standard output.
DESC
self
.
arguments
=
'[ NAME.podspec ]'
def
initialize
(
argv
)
@name
=
argv
.
shift_argument
super
end
def
validate!
super
help!
"A pod name is required."
unless
@name
end
def
run
found_sets
=
Source
.
search_by_name
(
@name
)
raise
Informative
,
"Unable to find a spec named `
#{
@name
}
'."
if
found_sets
.
count
==
0
unless
found_sets
.
count
==
1
names
=
found_sets
.
map
(
&
:name
)
*
', '
raise
Informative
,
"More that one fitting spec found:
\n
#{
names
}
"
end
set
=
found_sets
.
first
best_spec
=
best_spec_from_set
(
set
)
file_name
=
best_spec
.
defined_in_file
UI
.
puts
File
.
open
(
file_name
).
read
end
def
best_spec_from_set
(
set
)
sources
=
set
.
sources
best_source
=
sources
.
first
best_version
=
best_source
.
versions
(
set
.
name
).
first
sources
.
each
do
|
source
|
if
source
.
versions
(
set
.
name
).
first
>
best_version
best_source
=
source
best_version
=
version
end
end
best_spec
=
best_source
.
specification
(
set
.
name
,
best_version
)
end
end
# TODO some of the following methods can probably move to one of the subclasses.
# TODO some of the following methods can probably move to one of the subclasses.
private
private
...
...
spec/functional/command/spec_spec.rb
View file @
a66b7cb3
...
@@ -136,4 +136,28 @@ module Pod
...
@@ -136,4 +136,28 @@ module Pod
UI
.
output
.
should
.
include
"Missing license type"
UI
.
output
.
should
.
include
"Missing license type"
end
end
end
end
describe
"Command::Spec#cat"
do
extend
SpecHelper
::
TemporaryDirectory
extend
SpecHelper
::
TemporaryRepos
it
"complains it cant't find a spec to read"
do
lambda
{
command
(
'spec'
,
'cat'
,
'not-exissting-spec'
).
run
}.
should
.
raise
Informative
end
it
"complains provided spec name is ambigious"
do
e
=
lambda
{
command
(
'spec'
,
'cat'
,
'AF'
).
run
}.
should
.
raise
Informative
e
.
message
.
should
.
match
/More that one/
end
it
"prints the spec on standard output"
do
lambda
{
command
(
'spec'
,
'cat'
,
'JRSwizzle'
).
run
}.
should
.
not
.
raise
text
=
(
fixture
(
'spec-repos'
)
+
'master/JRSwizzle/1.0/JRSwizzle.podspec'
).
read
#output.gsub(/\n/,'').should.equsal text.gsub(/\n/,'')
UI
.
output
.
should
.
include
text
.
gsub
(
/\n/
,
''
)
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