Class: Rack::Xapper

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/xapper.rb

Constant Summary collapse

APP_MANIFEST_TEMPLATE =
"\n<Deployment xmlns=\"http://schemas.microsoft.com/client/2007/deployment\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" RuntimeVersion=\"2.0.31005.0\" EntryPointAssembly=\"Microsoft.Scripting.Silverlight\" EntryPointType=\"Microsoft.Scripting.Silverlight.DynamicApplication\" ExternalCallersFromCrossDomain=\"ScriptableOnly\">\n  <!-- Add assembly references here -->\n  <Deployment.Parts>\n<!-- In the XAP -->\n<!-- <AssemblyPart Source=\"Foo.dll\" /> -->\n<!-- Outside the XAP, same domain -->\n<!-- <AssemblyPart Source=\"/Foo.dll\" /> -->\n<!-- Outside the XAP, different domain -->\n<!-- <AssemblyPart Source=\"http://bar.com/Foo.dll\" /> -->\n\n  </Deployment.Parts>\n  <!-- Add transparent platform extensions (.slvx) references here -->\n  <Deployment.ExternalParts>\n<!-- Example -->\n<!-- <ExtensionPart Source=\"http://bar.com/v1/Foo.slvx\" /> -->\n  </Deployment.ExternalParts>\n</Deployment>\n \n"
LANGUAGES =
{
  :names => %w(IronPython Python py),
  :extensions => %w(.py),
  :context => "IronPython.Runtime.PythonContext",
  :assemblies => %w(IronPython.dll IronPython.Modules.dll),
  :external => "IronPython.slvx"
},
{
  :names => %w(IronRuby Ruby rb),
  :extensions => %w(.rb),
  :context => "IronRuby.Runtime.RubyContext",
  :assemblies => %w(IronRuby.dll IronRuby.Libraries.dll),
  :external => "IronRuby.slvx"
}
DEFAULT_OPTIONS =
{
  :assembly_path => ::File.dirname(__FILE__) + '/../assemblies',
  :xap_path => "sl",
  :source_path => 'app/silverlight',
  :extra_app_files => [],
  :xap_name => 'app',
  :external_url_prefix => "/dlr-slvx",
  :root => 'public',
  :sl_version => :clr2,
  :languages => LANGUAGES,
  :app_manifest => APP_MANIFEST_TEMPLATE
}

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Xapper



211
212
213
214
# File 'lib/rack/xapper.rb', line 211

def initialize(app, options={})
  @xap_options = DEFAULT_OPTIONS.merge(options)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



216
217
218
219
220
221
222
223
224
225
226
# File 'lib/rack/xapper.rb', line 216

def call(env)
  path = env['PATH_INFO']
  can_serve = /#{@xap_options[:xap_name]}\.xap/ =~ path
  
  if can_serve
    file_server = XapFile.new(@xap_options)
    file_server.call(env)
  else
    @app.call(env)
  end
end