0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
An attempt to implement Ext.Direct from Sencha
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

This is an attempt to implement Ext.Direct (see http://www.sencha.com/products/extjs/extdirect for more info)

I wanted to have a library that did not have to many dependencies.

The idea is very simple:

  1. add an 'api' and 'router' endpoint to your backend.
  2. expose your classes.

and you are set

#INSTALL# gem install ruby_ext_direct

#Example:# (For more examples ) ##A RACK based example##

###Gemfile

gem 'ruby_ext_direct', :require => 'ext_direct'

###web_service.rb

require 'rubygems'
require 'bundler/setup'
require 'rack'
require 'json'

require 'ext_direct'

#Expose all classes in a directory
ExtDirect::Api.expose_all("./exposed_classes")

#Generate a client-side descriptor
map '/api' do
  run Proc.new { |env|
    [200, {'Content-Type' => 'text/json'}, [ExtDirect::Api.to_json]]
  }
end

#Route request to methods
map '/router' do
  run Proc.new { |env|
    result = ''

    req = Rack::Request.new(env)
    if req.post?
      data = env["rack.input"].gets
      result = ExtDirect::Router.route(data)
    end

    [200, {'Content-Type' => 'text/html'}, [result.to_json]]
  }
end

TODO: add documentation
TODO: add rails engine