lib/plezi.rb in plezi-0.11.2 vs lib/plezi.rb in plezi-0.12.0

- old
+ new

@@ -9,12 +9,12 @@ require 'json' require 'yaml' require 'uri' require 'set' -# GRHttp servet -require 'grhttp' +# Iodine server +require 'iodine/http' ## erb templating begin require 'erb' @@ -65,11 +65,10 @@ # # Plezi routes accept controller classes, which makes RESTful and WebSocket applications easy to write. # For example, open your Ruby terminal (the `irb` command) and type: # # require 'plezi' -# listen # route "*", Plezi::StubRESTCtrl # exit # will start the service. # # Controller classes don't need to inherit anything :-) # @@ -79,41 +78,37 @@ # class MyController # def index # "Hello World!" # end # end -# listen # route "*", MyController # # exit # I'll stop writing this line every time. # # Amazing(!), right? - You can read more in the documentation for Plezi::StubWSCtrl and Plezi::StubRESTCtrl, which are stub classes used for testing routes. # # Plezi routes accept Regexp's (regular exceptions) for route paths. # Plezi also accepts an optional block instead of the conrtoller Class object for example: # # require 'plezi' -# listen # route(/[.]*/) {|request, response| response << "Your request, master: #{request.path}."} # # As you may have noticed before, the catch-all route (/[.]*/) has a shortcut: '*'. # # class routes that have a specific path (including root, but not a catch-all or Regexp path) # accept an implied `params[:id]` variable. the following path ('/'): # # require 'plezi' -# listen # route "/", Plezi::StubWSCtrl # # go to: http://localhost:3000/1 # # => Plezi::StubRESTCtrl.new.show() # where params[:id] == 1 # # it is possible to use "magic" routes (i.e. `/resource/:type/(:id)/(:date){/[0-9]{8}}/:foo`) and it is also possible to set the appropriate parameters within the `before` method of the Conltroller. # # Routes are handled in the order they are created. If overlapping routes exist, the first will execute first: # # require 'plezi' -# listen # route('*') do |request, response| # response << "Your request, master: #{request.path}." unless request.path.match /cats/ # end # route('*') {|request, response| response.body << "Ahhh... I love cats!"} # @@ -131,12 +126,9 @@ # PL.on_shutdown(Kernel, :my_shutdown_proc, Time.now) { puts "this will run after shutdown." } # PL.on_shutdown() { puts "this will run too." } # # # a timer # PL.run_after 2, -> {puts "this will wait 2 seconds to run... too late. for this example"} -# -# # an asynchronous method call with an optional callback block -# PL.callback(Kernel, :puts, "Plezi will start eating our code once we exit terminal.") {puts 'first output finished'} # # # remember to exit to make it all start # exit # # all the examples above shoold be good to run from irb. updated examples can be found at the Readme file in the Github project: https://github.com/boazsegev/plezi