Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A fuckin' framework

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 README.textile
Octocat-spinner-32 Rakefile
README.textile

Fuck

A fuckin’ framework

Usage

Fuck is a Rack-based framework, so you can write a Rack::Builder script or
write a Rack builder configuration.

For example:


  run Fuck

Examples

Structurally, a RESTful resource could be developed in this fashion (after
modifying to actually respond and handle input).


  class Posts < Fuck::Resource
    
    # GET /posts
    def all
      respond("OK", :status => 200)
    end
    
    # POST /posts/1
    def create(id)
      respond("OK", :status => 200)
    end
    
    # GET /posts/1
    def read(id)
      respond("OK", :status => 200)
    end
    
    # PUT /posts/1
    def update(id)
      respond("OK", :status => 200)
    end
    
    # DELETE /posts/1
    def delete(id)
      respond("OK", :status => 200)
    end
    
  end

A more realistic example may be something like:


  require 'activerecord'
  # include code to establish connection et al
  
  class Post < ActiveRecord::Base; end
  
  class Posts < Fuck::Resource
    
    def all
      respond Post.find(:all).map(&:id).to_json
    end
    
    def create
      if post = Post.create(params)
        respond
      else
        respond "Unprocessable Entity: " + post.errors.full_strings.join(", "), :status => 422
      end
    end
    
    def read(id)
      respond Post.find(id).to_json
    end
    
    # etc
    
  end

Copyright & License

The MIT License
http://www.opensource.org/licenses/mit-license.php

Copyright © 2009 Matt Todd.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Something went wrong with that request. Please try again.