|
Revision 812, 0.8 kB
(checked in by cho45, 6 years ago)
|
|
lang/ruby/Amalgam/plugins/debug_eval.rb,
lang/ruby/Amalgam/plugins/firefox.rb,
lang/ruby/Amalgam/AppController.rb:
どうも inspect でおちていたらしい。よくわからない
|
-
Property svn:executable set to
*
|
| Line | |
|---|
| 1 | #!/usr/bin/env ruby |
|---|
| 2 | |
|---|
| 3 | class DebugEval < AmalgamPlugin |
|---|
| 4 | def candidates |
|---|
| 5 | if amalgam.sublaunchers.empty? |
|---|
| 6 | [ |
|---|
| 7 | Command.new(".d", "Debug eval", NSApp.applicationIconImage) do |
|---|
| 8 | _, code = amalgam.search_text.split(/\s+/, 2) |
|---|
| 9 | |
|---|
| 10 | if code.to_s.empty? |
|---|
| 11 | # mode change |
|---|
| 12 | amalgam.sublaunchers << self |
|---|
| 13 | amalgam.clear |
|---|
| 14 | else |
|---|
| 15 | evaluate(code) |
|---|
| 16 | end |
|---|
| 17 | end |
|---|
| 18 | ] |
|---|
| 19 | else |
|---|
| 20 | [ |
|---|
| 21 | "restart", |
|---|
| 22 | "@config.reload", |
|---|
| 23 | "build_candidates", |
|---|
| 24 | ].map do |m| |
|---|
| 25 | Candidate.new(m, m, NSApp.applicationIconImage) do |
|---|
| 26 | log "eval #{m}" |
|---|
| 27 | evaluate(m) |
|---|
| 28 | end |
|---|
| 29 | end |
|---|
| 30 | end |
|---|
| 31 | end |
|---|
| 32 | |
|---|
| 33 | def evaluate(code) |
|---|
| 34 | result = "" |
|---|
| 35 | begin |
|---|
| 36 | result = amalgam.instance_eval(code).inspect |
|---|
| 37 | rescue Exception => e |
|---|
| 38 | result = e.inspect |
|---|
| 39 | result << "\n#{e.backtrace.join("\n")}" |
|---|
| 40 | end |
|---|
| 41 | log result |
|---|
| 42 | OSX.NSRunAlertPanel("Debug", result, "OK", "", nil) |
|---|
| 43 | end |
|---|
| 44 | end |
|---|
| 45 | |
|---|