{"id":20058629,"url":"https://github.com/tlewin/fortune-api","last_synced_at":"2026-05-11T08:05:38.659Z","repository":{"id":14520362,"uuid":"17234375","full_name":"tlewin/fortune-api","owner":"tlewin","description":"Simple web wrapper for fortune BSD program.","archived":false,"fork":false,"pushed_at":"2014-02-28T20:30:12.000Z","size":132,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-12T22:08:00.309Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"oortcloud/heroku-buildpack-meteorite","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tlewin.png","metadata":{"files":{"readme":"README.md","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":"2014-02-27T02:58:32.000Z","updated_at":"2014-02-28T20:30:12.000Z","dependencies_parsed_at":"2022-08-27T10:02:06.898Z","dependency_job_id":null,"html_url":"https://github.com/tlewin/fortune-api","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/tlewin%2Ffortune-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tlewin%2Ffortune-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tlewin%2Ffortune-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tlewin%2Ffortune-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tlewin","download_url":"https://codeload.github.com/tlewin/fortune-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241488154,"owners_count":19970826,"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-11-13T13:02:29.744Z","updated_at":"2026-05-11T08:05:33.614Z","avatar_url":"https://github.com/tlewin.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Fortune API\n\nSimple web wrapper for fortune BSD program.\n\n## Helmet\n\nFor this application, it was used the [Helmet Framework](https://github.com/tlewin/helmet). A small web framework, developed by myself, that runs on top of Goliath web server and provide a Sinatra like API.\n\nThe async approach for this kind of application has the benefit of still serving other requests, while the fortune process is running in background. In other words, the application can handle more than one request at time.\n\nUsing the `ab -c 10 -n 1000 http://localhost:9000/fortune` command to compare the async vs sync approach, we have the following numbers:\n\n    async: 359.33 requests/sec (mean)\n     sync: 257.78 requests/sec (mean)\n\n_* iMac 2.9GHz Intel Core i5/ Ruby 2.0.0_\n\nAlmost 40% of performance gain!\n\n## API documentation\n\nThe API returns the fortune text in three different formats:\n\n1. `text/plain`: http://hostname:port/fortune\n2. `application/json`: http://hostname:port/fortune.json\n3. `text/html`: http://hostname:port/fortune.html (Simple web interface)\n\nThe application also recognizes the HTTP `Accept` header in order to determine the proper format.\n\nIt is possible to filter content by passing the following URL variables:\n\n* `long`: 0 = disallow long, 1 = force long, null value indicates allow but do not force (Optional)\n* `dirty`: 0 = only clean ones, 1 = only dirty ones, null value defaults to only clean ones (Optional)\n\n## Usage\n\nTo start the application, just type the following command:\n\n    ruby app.rb -s\n\nThe application should start at localhost:9000\n\nFor more options:\n\n    ruby app.rb --help\n\n## Tests\n\nFor tests:\n\n    rake test\n\n## Requirements\n\nThis code was tested using Ruby 2.0 and Ruby 2.1\n\n## External dependencies\n\nBSD fortune program\n\nTo install it on Mac OS X you can visit the link: http://download.cnet.com/fortune/3000-20416_4-8558.html\n\nOr, if you are a brew user:\n\n    brew install fortune\n\n## Dependencies\n\nAll ruby dependencies are available in rubygems.org repository\n\n* helmet [https://github.com/tlewin/helmet]\n* multi_json [https://github.com/intridea/multi_json]\n\nTests\n\n* shoulda [https://github.com/thoughtbot/shoulda]\n* mocha [https://github.com/freerange/mocha]\n* em-http-request [https://github.com/igrigorik/em-http-request]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftlewin%2Ffortune-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftlewin%2Ffortune-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftlewin%2Ffortune-api/lists"}