{"id":16948867,"url":"https://github.com/technicalpickles/ragamuffin","last_synced_at":"2025-03-21T09:47:14.477Z","repository":{"id":735742,"uuid":"385762","full_name":"technicalpickles/ragamuffin","owner":"technicalpickles","description":"I'm a bad, bad man","archived":false,"fork":false,"pushed_at":"2013-04-16T19:56:26.000Z","size":108,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-15T00:30:00.942Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"sanger-pathogens/bio_assembly_refinement","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/technicalpickles.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-11-25T21:54:50.000Z","updated_at":"2016-12-15T09:22:28.000Z","dependencies_parsed_at":"2022-07-07T14:31:28.742Z","dependency_job_id":null,"html_url":"https://github.com/technicalpickles/ragamuffin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicalpickles%2Fragamuffin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicalpickles%2Fragamuffin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicalpickles%2Fragamuffin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/technicalpickles%2Fragamuffin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/technicalpickles","download_url":"https://codeload.github.com/technicalpickles/ragamuffin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244776273,"owners_count":20508503,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T21:52:34.474Z","updated_at":"2025-03-21T09:47:14.460Z","avatar_url":"https://github.com/technicalpickles.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"Java Servlets are the JEE way of doing anything web based. They are pretty easy to write. Here's short example to read a query parameter, and display it.\n\n\n    import java.io.*;\n    import javax.servlet.*;\n    import javax.servlet.http.*;\n    \n    public class ExampleServlet extends HttpServlet {\n      public void doGet(HttpServletRequest request, \n    \t HttpServletResponse response)\n            throws ServletException, IOException\n      {\n        PrintWriter out = response.getWriter();\n        String DATA = request.getParameter(\"DATA\");\n    \n        if(DATA != null){\n          out.println(DATA);\n        } else {\n          out.println(\"No text entered.\");\n        }\n        out.close();\n      }\n    }\n\n\nAnd don't forget to set it up in web.xml:\n\n\n    \u003cweb-app xmlns=\"http://java.sun.com/xml/ns/j2ee\" version=\"2.4\"\n             xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n             xsi:schemaLocation=\"http:/java.sun.com/dtd/web-app_2_3.dtd\"\u003e\n      \u003cservlet\u003e\n        \u003cservlet-name\u003eexample\u003c/servlet-name\u003e\n        \u003cservlet-class\u003eExampleServlet\u003c/servlet-class\u003e\n      \u003c/servlet\u003e\n    \n      \u003cservlet-mapping\u003e\n        \u003cservlet-name\u003eexample\u003c/servlet-name\u003e\n        \u003curl-pattern\u003e/example\u003c/url-pattern\u003e\n      \u003c/servlet-mapping\u003e\n    \u003c/web-app\u003e\n\n\nAll pretty straight forward. What if we could harness this technique in the Ruby world? Rack is a minimal framework to make talking to a Ruby webserver nicer, and is pretty flexible and great to build frameworks on top of. Imagine if you would, an API like Java Servlets... but implemented on rack....\n\nI present to you... racklets! Let's start by making a new ruby file, and putting it in a well known load path: WEB-INF/lib. So, we'll make WEB-INF/lib/example_racklet.rb :\n\n    require 'ragamuffin'\n    class ExampleRacklet \u003c Ragamuffin::Racklet\n      def do_get(request, response)\n        data = request.params['DATA']\n        if data\n          response.write data\n        else\n          response.write 'No data'\n        end\n      end\n    end\n\nNext we need a web.xml to tell racklets what to load, and what urls to map it. This is kept in WEB-INF/web.xml:\n\n    \u003cweb-app\u003e\n      \u003cracklet\u003e\n        \u003cracklet-name\u003eexample\u003c/racklet-name\u003e\n        \u003cracklet-class\u003eParamRacklet\u003c/racklet-class\u003e\n      \u003c/racklet\u003e\n    \n      \u003cracklet-mapping\u003e\n        \u003cracklet-name\u003eexample\u003c/racklet-name\u003e\n        \u003curl-pattern\u003e/example\u003c/url-pattern\u003e\n      \u003c/racklet-mapping\u003e\n    \u003c/web-app\u003e\n\nSince we're on rack, you'll want a config.ru to run our ragamuffin web application.\n\n    require 'ragamuffin'\n    run Ragamuffin::WebApplication.new\n\n\nThis handles loading up the web.xml and updating $LOAD_PATH to include the WEB-INF/lib directory. So now we're in business to something like shotgun to run our server:\n\n    $ shotgun \n    == Shotgun starting Rack::Handler::Mongrel on localhost:9393\n\nAlternatively, you can use the included `ragamuffin` script to run it without a config.ru file.\n\n    $ bin/ragamuffin \n    == Ragamuffin starting Rack::Handler::Mongrel on localhost:9393\n    \nNow go ahead and browse to http://localhost:9393/example and you'll see:\n\n    No Data\n\nGive it the DATA parameter, and you'll see it displayed, ie http://localhost:9393/example?DATA=Hello%20World\n\n    Hello World\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnicalpickles%2Fragamuffin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechnicalpickles%2Fragamuffin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnicalpickles%2Fragamuffin/lists"}