72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
# File 'lib/gorp/env.rb', line 72
def self.dump_env
extend Commands
$x.pre Time.now.httpdate, :class=>'stdout'
if $rails != 'rails'
Dir.chdir($rails) do
log :cmd, 'git log -1'
$x.pre 'git log -1', :class=>'stdin'
`git log -1`.strip.split(/\n/).each do |line|
line.sub! /commit (\w{40})/,
'commit <a href="http://github.com/rails/rails/commit/\1">\1</a>'
if $1
$x.pre(:class=>'stdout') {$x << line.chomp}
else
$x.pre line.chomp, :class=>'stdout'
end
end
end
end
if File.exist? 'Gemfile'
if File.read("#$rails/RAILS_VERSION") =~ /^[34]/
cmd = 'rake about'
else
cmd = 'rails about'
end
log :cmd, cmd
$x.pre cmd, :class=>'stdin'
about = `#{cmd}`.sub(/^(Middleware\s+)(.*)/) {
term,dfn=$1,$2
term+dfn.gsub(', ', ",\n" + ' ' * term.length)
}
about.split("\n").each {|line| $x.pre line, :class => :stdout}
elsif File.exist? 'script/rails'
cmd 'ruby script/rails application -v'
else
cmd Gorp.which_rails($rails) + ' -v'
end
Dir.chdir(File.join($WORK, $rails_app.to_s)) do
if $bundle
cmd 'bundle show'
else
cmd 'gem list'
cmd 'echo $RUBYLIB | sed "s/:/\n/g"'
end
end
cmd 'gem -v'
cmd "#{$ruby} -v"
if not `which rvm`.empty?
if ENV['rvm_version']
cmd "echo $rvm_version", :as => 'rvm -v'
else
cmd "rvm -v | grep '\\S'", :as => 'rvm -v'
end
elsif not `which rbenv`.empty?
cmd "rbenv --version"
end
if not `which nodejs`.empty?
cmd "nodejs -v"
elsif not `which node`.empty?
cmd "node -v"
end
if not `which mysql`.empty?
cmd "mysql --version"
end
log :cmd, 'echo $PATH'
$x.pre 'echo $PATH', :class=>'stdin'
ENV['PATH'].split(':').each {|path| $x.pre path, :class => :stdout}
if not `which lsb_release`.empty?
cmd "lsb_release -irc"
elsif File.exist? '/etc/debian_version'
cmd 'cat /etc/debian_version'
end
if not `which sw_vers`.empty?
cmd "sw_vers"
end
if not `which uname`.empty?
cmd "uname -srm"
end
config = Gorp::Config.get
if config and not config.empty?
$x.pre 'Gorp.config.get', :class=>'stdin'
$x.table do
config.sort.each do |name, value|
$x.tr do
$x.td name
$x.td value.inspect
end
end
end
end
rescue Exception => e
$x.pre :class => 'traceback' do
STDERR.puts e.inspect
$x.text! "#{e.inspect}\n"
e.backtrace.each {|line| $x.text! " #{line}\n"}
end
end
|