<commit_before>= Sneakers

A small library that makes building asynchronous web apps with EventMachine and Rack easy.

== Installing
  $ git clone git://github.com/bluejay/sneakers.git
  $ cd sneakers
  $ gem build sneakers.gemspec
  $ gem install sneakers-0.1.0.gem

== Your First App
Apps in Sneakers run like regular rack apps. Simple pass a block to the Sneaker method, and it returns an async rack app.
  #config.ru
  app = sneakers do
    send "Hello World"
  }
  run app
The Application is called everytime a new request is made, and then runs the code in the block.

== Note
Sneakers is very untested and was hacked together in the midst of two periods of my biochem class. It should only be used for experimentation purposes.
As of right now the only server on which I have tested it on is Thin, and it probably only works with ruby 1.9.2.

== Features

=== Fibers
Everything runs within a fiber so you can use asynchronous method calls without blocking the reactor.
  class Controller
    include Sneakers::Controller

    def call(env)
      @action = :run
      __call__(env)
    end

    def async_method
      EM::add_timer(1) do
        fiber.resume "Hello World"
      end
      return Fiber.yield
    end

    def run
      # This will write the value "Hello World" after pausing for 1 second, without blocking the reactor.
      send async_method
    end
  end
=== Controllers
Sneakers is very easy to use in an existing controller. Simply include it within the class and specify which method to call. The two ways to do this are to either: specify an @action before calling __call__(env) or to include it within the env as 'sneakers.action'. __call__(env) is aliased to call so if you specify the action in a middleware, router, etc. no changes need to be added.

  class Controller
    include Sneakers::Controller
    
    def call(env)
      @action = :myMethod # Or you could use: env['sneakers.action'] = :myMethod
      __call__(env) # This will call the method for you.
    end
  end
<commit_msg>Updated the README to reflect new changes. It still needs a lot of work though.<commit_after>= Sneakers

A small library that makes building asynchronous web apps with EventMachine and Rack easy.

== Installing
  $ git clone git://github.com/bluejay/sneakers.git
  $ cd sneakers
  $ gem build sneakers.gemspec
  $ gem install sneakers-0.1.0.gem

== Your First App
Apps in Sneakers run like regular rack apps. Simple pass a block to the Sneaker method, and it returns an async rack app.
  #config.ru
  app = sneakers do
    send "Hello World"
  }
  run app
The Application is called everytime a new request is made, and then evaluates the code in the block.

== Note
Sneakers is very untested and was hacked together in the midst of two periods of my biochem class. It should only be used for experimentation purposes.
As of right now the only server on which I have tested it on is Thin, and it probably only works with ruby 1.9.2.

== Features

=== Fibers
Everything runs within a fiber so you can use asynchronous method calls without blocking the reactor.
  class Controller
    include Sneakers::Controller

    def async_method
      EM::add_timer(1) do
        fiber.resume "Hello World"
      end
      return Fiber.yield
    end

    def run
      # This will write the value "Hello World" after pausing for 1 second, without blocking the reactor.
      send async_method
    end
  end
=== Controllers
Sneakers is very easy to use in an existing controller. Simply include it within the class and specify which method to call. The two ways to do this are to either: specify an @action before calling __call__(env) or to include it within the env as 'sneakers.action'. __call__(env) is aliased to call so if you specify the action in a middleware, router, etc. no changes need to be added. If you don't want to use 'sneakers.action' as the key where the action is located, use action_key "myKey". You can also set a default action, which is called if no action is specified by using default_to :myMethod. If not specified, the default action is #run.

  class Controller
    include Sneakers::Controller

    # default_to :run
    # action_key "random.key"

    def call(env)
      @action = :myMethod # Or you could use: env['sneakers.action'] = :myMethod
      __call__(env) # This will run the action for you.
    end
  end

{'fraction_non_alphanumeric': 0.05440771349862259, 'fraction_numerical': 0.0036730945821854912, 'mean_word_length': 3.296844181459566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2163449', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1184, 'n_words': 629}