나는 아무것도하지했습니다^⇧H은 NoMethodError 원인
/tmp/temp_textmate.Z2P0KX:30:in `<main>': undefined method `empty?' for nil:NilClass (NoMethodError)
나는 ... 처음으로 어제 HTML 문서에 '깔끔한'를 사용하여 시도하고있어 번들의 코드 ...
#!/usr/bin/env ruby -wKU
require ENV['TM_SUPPORT_PATH'] + '/lib/ui.rb'
require ENV['TM_SUPPORT_PATH'] + '/lib/exit_codes.rb'
result = `"${TM_TIDY:-tidy}" -f /tmp/tm_tidy_errors -iq -utf8 \
-wrap 0 --tab-size $TM_TAB_SIZE --indent-spaces $TM_TAB_SIZE \
--indent yes \
${TM_XHTML:+-asxhtml --output-xhtml yes} \
${TM_SELECTED_TEXT:+--show-body-only yes} \
--enclose-text yes \
--doctype strict \
--wrap-php no \
--tidy-mark no`
status = $?.exitstatus
at_exit { File.unlink('/tmp/tm_tidy_errors') } # Clean up error log
if status == 2 # Errors
msg = "Errors: " + File.read('/tmp/tm_tidy_errors')
TextMate.exit_show_tool_tip msg
elsif status == 1 # Warnings - use output but also display notification with warnings
log = File.read('/tmp/tm_tidy_errors').to_a.select do |line|
! (ENV['TM_SELECTED_TEXT'] and (line.include?('Warning: missing <!DOCTYPE> declaration') or line.include?("Warning: inserting missing 'title' element")))
end.join rescue nil
unless log.empty?
options = {
:title => "Tidy Warnings",
:summary => "Warnings for tidying your document (press escape to close):",
:log => log
}
TextMate::UI.simple_notification(options)
end
end
if ENV['TM_SOFT_TABS'] == "YES"
print result
else
in_pre = false
result.each_line do |line|
unless in_pre
tab_size = ENV["TM_TAB_SIZE"].to_i
space, text = /(*)(.*)/m.match(line)[1..2]
line = "\t" * (space.length/tab_size).floor + " " * (space.length % tab_size) + text
end
print line
in_pre = true if line.include?("<pre>")
in_pre = false if line.include?("</pre>")
end
end
는 문제의 라인은 unless log.empty?
입니다.
OS X 10.6.6에서 TextMate 1.5.10 (1631)을 실행하고 있습니다. 최근에 rvm을 설치하고 기본 Ruby를 1.9.2로 업그레이드했습니다. 그러나 TextMate를 사용하여 1.8.7을 사용하면 문제가 해결되지 않았습니다. /tmp/tm_tidy_errors
파일이없는 경우 마지막에
log = File.read('/tmp/tm_tidy_errors').to_a.select do |line| ... end.join rescue nil
rescue nil
이 log
에 nil
를 넣어 것입니다 아니면 할 수 없습니다 : 당신이 log
에 할당 보면
제목의 위 화살표가 고의적입니까?!? – slugster
@slugster, 네, 고의적입니다. Ctrl-Shift-H는 TextMate의 Tidy에 해당하는 기본 키입니다.문제와 관련해서는 로컬에서 테스트 한 결과 아무 문제가 없었지만 명령이 Ruby로 작성되었으므로이 질문에 Ruby 태그를 추가 할 수 있습니다. Ruby에 대해 더 많은 도움을 줄 수있을만큼 잘 모르겠습니다. 내가 알 수있는 한, 명령의 나의 버전은 당신과 동일합니다. 경고를 확인하는 동안 오류가 발생하기 때문에 Tidy 설치에 문제가 있다는 것입니다. – Chuck
@Chuck - 감사합니다. 제안한대로 '루비'태그를 추가했습니다. – petedickson