github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

mtodd / fuck

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 9
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (1)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

A fuckin' framework — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Changed how some of the methods respond. 
mtodd (author)
Wed Aug 12 02:57:18 -0700 2009
commit  a3557f8973c1a39a2b22d8bc0ed169808271d55d
tree    8ea54a2a8147abd79c8102f4b650cc0243ed23f0
parent  cb6ed9dadcb266ef5bde4891fc72c03b9aff050e
fuck /
name age
history
message
file README.textile Fri Jan 09 01:45:43 -0800 2009 Fixed markup error. [mtodd]
file Rakefile Fri Jan 09 02:01:16 -0800 2009 Restructured, automated running tests. [mtodd]
directory examples/ Wed Aug 12 02:57:18 -0700 2009 Changed how some of the methods respond. [mtodd]
directory lib/ Tue Aug 11 23:59:39 -0700 2009 Implemented better error handling and reporting... [mtodd]
directory test/ Fri Jan 09 02:01:16 -0800 2009 Restructured, automated running tests. [mtodd]
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.

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server