Sha256: 2d2006af64838f3d7db913fee81e4cccb23ad59ca71f3bd4b4a2e81725857927

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 KB

Contents

require 'icuke/core_ext'
require 'icuke/waxsim'

require 'httparty'

module ICuke
  class Simulator
    include Timeout
    include HTTParty
    base_uri 'http://localhost:50000'
    
    class Error < StandardError; end
    
    def view
      get('/view')
    end
    
    def record
      get '/record'
    end
    
    def stop
      get '/stop'
    end
    
    def save(path)
      get '/save', :query => path
    end
    
    def load(path)
      get '/load', :query => path
    end
    
    def play
      get '/play'
    end
    
    def load_module(path)
      get '/module', :query => path
    end
    
    def fire_event(event)
      get '/event', :query => event.to_json
    end
    
    def set_defaults(defaults)
      get '/defaults', :query => defaults.to_json
    end
    
    def get(path, options = {})
      options[:query] = URI.escape(options[:query]) if options.has_key?(:query)
      response = self.class.get(path, options)
      if response.code != 200
        raise Simulator::Error, response.body
      end
      response.body
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
iCuke-0.7.0 lib/icuke/simulator.rb
iCuke-0.6.6 lib/icuke/simulator.rb
iCuke-0.6.5 lib/icuke/simulator.rb
iCuke-0.6.4 lib/icuke/simulator.rb
iCuke-0.6.3 lib/icuke/simulator.rb
iCuke-0.6.2 lib/icuke/simulator.rb
iCuke-0.6.1 lib/icuke/simulator.rb
iCuke-0.6.0 lib/icuke/simulator.rb