Module: Pod::Command::ErrorReport

Defined in:
lib/cocoapods/command/error_report.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) error_from_podfile(error) (private)



73
74
75
76
77
# File 'lib/cocoapods/command/error_report.rb', line 73

def error_from_podfile(error)
  if error.message =~ /Podfile:(\d*)/
    "\nIt appears to have originated from your Podfile at line #{$1}.\n"
  end
end

+ (Object) host_information (private)



79
80
81
82
# File 'lib/cocoapods/command/error_report.rb', line 79

def host_information
  product, version, build =`sw_vers`.strip.split("\n").map { |line| line.split(":").last.strip }
  "#{product} #{version} (#{build})"
end

+ (Object) markdown_podfile (private)



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/cocoapods/command/error_report.rb', line 61

def markdown_podfile
  return '' unless Config.instance.project_podfile && Config.instance.project_podfile.exist?
<<-EOS

### Podfile

```ruby
#{Config.instance.project_podfile.read.strip}
```
EOS
end

+ (Object) repo_information (private)



89
90
91
92
93
94
95
96
97
98
# File 'lib/cocoapods/command/error_report.rb', line 89

def repo_information
  Pod::Source.all.map do |source|
    repo = source.repo
    Dir.chdir(repo) do
      url = `git config --get remote.origin.url`.strip
      sha = `git rev-parse HEAD`.strip
      "#{repo.basename} - #{url} @ #{sha}"
    end
  end
end

+ (Object) report(error)



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/cocoapods/command/error_report.rb', line 11

def report(error)
  return <<-EOS

#{'――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――'.reversed}

### 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}
Ruby lib dir : #{RbConfig::CONFIG['libdir']}
Repositories : #{repo_information.join("\n               ")}
```
#{markdown_podfile}
### Error

```
#{error.message}
#{error.backtrace.join("\n")}
```

#{'――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――'.reversed}

#{'[!] Oh no, an error occurred.'.red}
#{error_from_podfile(error)}
#{'Search for existing github issues similar to yours:'.yellow}
#{"https://github.com/CocoaPods/CocoaPods/issues/search?q=#{CGI.escape(error.message)}"}

#{'If none exists, create a ticket, with the template displayed above, on:'.yellow}
https://github.com/CocoaPods/CocoaPods/issues/new

Don't forget to anonymize any private data!

EOS
end

+ (Object) xcode_information (private)



84
85
86
87
# File 'lib/cocoapods/command/error_report.rb', line 84

def xcode_information
  version, build = `xcodebuild -version`.strip.split("\n").map { |line| line.split(" ").last }
  "#{version} (#{build})"
end