Class: Sprout::FCSHService
- Inherits:
-
Object
- Object
- Sprout::FCSHService
- Defined in:
- lib/sprout/fcsh_service.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#execute(request) ⇒ Object
Temporarily pulled support for clear - since it’s easier to just stop and start the server.
-
#initialize(out = nil) ⇒ FCSHService
constructor
A new instance of FCSHService.
Constructor Details
#initialize(out = nil) ⇒ FCSHService
Returns a new instance of FCSHService.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/sprout/fcsh_service.rb', line 36 def initialize(out=nil) @out = out || $stdout @tasks = [] @lexer = FCSHLexer.new @out # TODO: This should use configurable SDK destinations: exe = Sprout.get_executable('sprout-flex3sdk-tool', 'bin/fcsh') @process = User.execute_silent(exe) response = '' @lexer.scan_process(@process).each do |token| response << token[:output] end out.puts response end |
Instance Method Details
#close ⇒ Object
88 89 90 |
# File 'lib/sprout/fcsh_service.rb', line 88 def close write("quit") end |
#execute(request) ⇒ Object
Temporarily pulled support for clear - since it’s easier to just stop and start the server. The clear feature continues to increment task ids and requires deeper changes for full support… def clear
@tasks.each_index do |index|
write("clear #{index+1}")
end
@tasks = []
return "[fcsh] All tasks have been cleared"
end
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/sprout/fcsh_service.rb', line 64 def execute(request) # if(request =~ /^clear/) # return clear # end hashed = Digest::MD5.hexdigest(request) # First, see if we've already received a task with this # Exact command: @tasks.each_index do |index| task = @tasks[index] if(task[:hash] == hashed) out.puts "[fcsh] #{request})" # Compile with an existing task at index+1 return write("compile #{index+1}") end end # No existing task found with this hash, create a new # task, store it for later, execute and return the result: task = {:hash => hashed, :request => request, :executed => false} @tasks << task return write(task[:request]) end |