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
0c2cd999
Commit
0c2cd999
authored
Nov 17, 2015
by
Samuel E. Giddins
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4531 from hemal/master
Adding pod env command to print environment
parents
0f3eb52b
b01b71dd
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
171 additions
and
36 deletions
+171
-36
CHANGELOG.md
CHANGELOG.md
+4
-0
command.rb
lib/cocoapods/command.rb
+1
-0
env.rb
lib/cocoapods/command/env.rb
+66
-0
env_spec.rb
lib/cocoapods/command/spec/env_spec.rb
+53
-0
error_report.rb
lib/cocoapods/user_interface/error_report.rb
+46
-36
command_spec.rb
spec/unit/command_spec.rb
+1
-0
No files found.
CHANGELOG.md
View file @
0c2cd999
...
...
@@ -8,6 +8,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Enhancements
*
Added support for
`pod env`
to print the pod environment without having to crash.
[
Hemal Shah
](
https://github.com/hemal
)
[
#3660
](
https://github.com/CocoaPods/CocoaPods/issues/3660
)
*
Add support for specifying :source with a pod dependency.
[
Eric Firestone
](
https://github.com/efirestone
)
[
#4486
](
https://github.com/CocoaPods/CocoaPods/pull/4486
)
...
...
lib/cocoapods/command.rb
View file @
0c2cd999
...
...
@@ -24,6 +24,7 @@ module Pod
require
'cocoapods/command/spec'
require
'cocoapods/command/init'
require
'cocoapods/command/cache'
require
'cocoapods/command/env'
self
.
abstract_command
=
true
self
.
command
=
'pod'
...
...
lib/cocoapods/command/env.rb
0 → 100644
View file @
0c2cd999
require
'cocoapods/user_interface/error_report'
module
Pod
class
Command
class
Env
<
Command
self
.
summary
=
'Display pod environment'
self
.
description
=
'Display pod environment.'
def
self
.
options
options
=
[]
options
.
concat
(
super
.
reject
{
|
option
,
_
|
option
==
'--silent'
})
end
def
initialize
(
argv
)
super
config
.
silent
=
false
end
def
run
UI
.
puts
report
end
def
report
<<-
EOS
#{
stack
}
#{
executable_path
}
### Plugins
```
#{
plugins_string
}
```
#{
markdown_podfile
}
EOS
end
def
stack
UI
::
ErrorReport
.
stack
end
def
markdown_podfile
UI
::
ErrorReport
.
markdown_podfile
end
def
plugins_string
UI
::
ErrorReport
.
plugins_string
end
private
def
executable_path
<<-
EOS
### Installation Source
```
Executable Path:
#{
actual_path
}
```
EOS
end
def
actual_path
$PROGRAM_NAME
end
end
end
end
lib/cocoapods/command/spec/env_spec.rb
0 → 100644
View file @
0c2cd999
require
File
.
expand_path
(
'../../spec_helper'
,
__FILE__
)
module
Pod
describe
Command
::
Env
do
describe
'In general'
do
before
do
@report
=
Command
::
Env
end
it
'returns a well-structured environment report'
do
expected
=
<<-
EOS
### Stack
```
CocoaPods :
#{
Pod
::
VERSION
}
Ruby :
#{
RUBY_DESCRIPTION
}
RubyGems :
#{
Gem
::
VERSION
}
Host : :host_information
Xcode : :xcode_information
Git : :git_information
Ruby lib dir :
#{
RbConfig
::
CONFIG
[
'libdir'
]
}
Repositories : repo_1
repo_2
```
### Installation Source
```
Executable Path: /usr/bin/command
```
### Plugins
```
cocoapods :
#{
Pod
::
VERSION
}
cocoapods-core :
#{
Pod
::
VERSION
}
cocoapods-plugins : 1.2.3
```
### Podfile
```ruby
```
EOS
@report
.
stubs
(
:actual_path
).
returns
(
'/usr/bin/command'
)
report
.
should
==
expected
end
end
end
end
lib/cocoapods/user_interface/error_report.rb
View file @
0c2cd999
...
...
@@ -18,28 +18,9 @@ module Pod
#{
original_command
}
```
### Report
* What did you do?
* What did you expect to happen?
* What happened instead?
### Stack
```
CocoaPods :
#{
Pod
::
VERSION
}
Ruby :
#{
RUBY_DESCRIPTION
}
RubyGems :
#{
Gem
::
VERSION
}
Host :
#{
host_information
}
Xcode :
#{
xcode_information
}
Git :
#{
git_information
}
Ruby lib dir :
#{
RbConfig
::
CONFIG
[
'libdir'
]
}
Repositories :
#{
repo_information
.
join
(
"
\n
"
)
}
```
#{
report_instructions
}
#{
stack
}
### Plugins
```
...
...
@@ -71,16 +52,41 @@ Don't forget to anonymize any private data!
EOS
end
private
def
report_instructions
<<-
EOS
### Report
def
`
(
other
)
super
rescue
Errno
::
ENOENT
=>
e
"Unable to find an executable (
#{
e
}
)"
* What did you do?
* What did you expect to happen?
* What happened instead?
EOS
end
def
pathless_exception_message
(
message
)
message
.
gsub
(
/- \(.*\):/
,
'-'
)
def
stack
<<-
EOS
### Stack
```
CocoaPods :
#{
Pod
::
VERSION
}
Ruby :
#{
RUBY_DESCRIPTION
}
RubyGems :
#{
Gem
::
VERSION
}
Host :
#{
host_information
}
Xcode :
#{
xcode_information
}
Git :
#{
git_information
}
Ruby lib dir :
#{
RbConfig
::
CONFIG
[
'libdir'
]
}
Repositories :
#{
repo_information
.
join
(
"
\n
"
)
}
```
EOS
end
def
plugins_string
plugins
=
installed_plugins
max_name_length
=
plugins
.
keys
.
map
(
&
:length
).
max
plugins
.
map
do
|
name
,
version
|
"
#{
name
.
ljust
(
max_name_length
)
}
:
#{
version
}
"
end
.
sort
.
join
(
"
\n
"
)
end
def
markdown_podfile
...
...
@@ -95,6 +101,18 @@ EOS
EOS
end
private
def
`
(
other
)
super
rescue
Errno
::
ENOENT
=>
e
"Unable to find an executable (
#{
e
}
)"
end
def
pathless_exception_message
(
message
)
message
.
gsub
(
/- \(.*\):/
,
'-'
)
end
def
error_from_podfile
(
error
)
if
error
.
message
=~
/Podfile:(\d*)/
"
\n
It appears to have originated from your Podfile at line
#{
Regexp
.
last_match
[
1
]
}
.
\n
"
...
...
@@ -130,14 +148,6 @@ EOS
reduce
({})
{
|
hash
,
s
|
hash
.
tap
{
|
h
|
h
[
s
.
name
]
=
s
.
version
.
to_s
}
}
end
def
plugins_string
plugins
=
installed_plugins
max_name_length
=
plugins
.
keys
.
map
(
&
:length
).
max
plugins
.
map
do
|
name
,
version
|
"
#{
name
.
ljust
(
max_name_length
)
}
:
#{
version
}
"
end
.
sort
.
join
(
"
\n
"
)
end
def
repo_information
SourcesManager
.
all
.
map
do
|
source
|
next
unless
source
.
type
==
'file system'
...
...
spec/unit/command_spec.rb
View file @
0c2cd999
...
...
@@ -16,6 +16,7 @@ module Pod
Command
.
parse
(
%w(spec create )
).
should
.
be
.
instance_of
Command
::
Spec
::
Create
Command
.
parse
(
%w(spec lint )
).
should
.
be
.
instance_of
Command
::
Spec
::
Lint
Command
.
parse
(
%w(init )
).
should
.
be
.
instance_of
Command
::
Init
Command
.
parse
(
%w(env )
).
should
.
be
.
instance_of
Command
::
Env
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