Skip to content

Commit

Permalink
Initial commit :)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredwu committed Jun 20, 2012
0 parents commit 6a51182
Show file tree
Hide file tree
Showing 66 changed files with 2,386 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
@@ -0,0 +1,11 @@
.DS_Store
._*
.bundle/
coverage/
log/*.log
pkg/
Gemfile.lock
spec/dummy/db/*.sqlite3
spec/dummy/log/*.log
spec/dummy/tmp/
spec/dummy/.sass-cache
1 change: 1 addition & 0 deletions .rspec
@@ -0,0 +1 @@
--colour
3 changes: 3 additions & 0 deletions .travis.yml
@@ -0,0 +1,3 @@
language: ruby
rvm:
- 1.9.3
6 changes: 6 additions & 0 deletions Gemfile
@@ -0,0 +1,6 @@
source "http://rubygems.org"

gemspec

gem "jquery-rails"
gem "bootstrap-sass"
68 changes: 68 additions & 0 deletions README.md
@@ -0,0 +1,68 @@
# ApiTaster [![Build Status](https://secure.travis-ci.org/fredwu/api_taster.png?branch=master)](http://travis-ci.org/fredwu/api_taster) [![Dependency Status](https://gemnasium.com/fredwu/api_taster.png)](https://gemnasium.com/fredwu/api_taster)

A quick and easy way to visually test out your application's API.

![](http://i.imgur.com/ZffbS.png)

## Why?

There are already many awesome API clients (such as [Postman](https://chrome.google.com/webstore/detail/fdmmgilgnpjigdojojpjoooidkmcomcm)), so why reinvent the wheel?

API Taster compared to alternatives, have the following advantages:

- API endpoints are automatically generated from your Rails routes definition
- Defining post params is as easy as defining routes
- Post params can be shared with your test factories

## Usage

Add API Taster in your gemfile:

```ruby
gem 'api_taster'
```
Mount API Taster, this will allow you to visit API Taster from within your app. For example:

```ruby
Rails.application.routes.draw do
mount ApiTaster::Engine => "/api_taster"
end
```

In `routes.rb`, define parameters for each API endpoint after the normal routes definition block. For example:

```ruby
ApiTaster.routes do
get '/users'

post '/users', {
:user => {
:name => 'Fred'
}
}

get '/users/:id', {
:id => 1
}

put '/users/:id', {
:id => 1, :user => {
:name => 'Awesome'
}
}

delete '/users/:id', {
:id => 1
}
end
```

That's it! Enjoy! :)

## License

This gem is released under the [MIT License](http://www.opensource.org/licenses/mit-license.php).

## Author

[Fred Wu](https://github.com/fredwu), originally built for [Locomote](http://locomote.com.au).
40 changes: 40 additions & 0 deletions Rakefile
@@ -0,0 +1,40 @@
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
begin
require 'rdoc/task'
rescue LoadError
require 'rdoc/rdoc'
require 'rake/rdoctask'
RDoc::Task = Rake::RDocTask
end

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'ApiTaster'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end

APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
load 'rails/tasks/engine.rake'



Bundler::GemHelper.install_tasks

require 'rake/testtask'

Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'spec'
t.pattern = 'spec/**/*_spec.rb'
t.verbose = false
end


task :default => :test
27 changes: 27 additions & 0 deletions api_taster.gemspec
@@ -0,0 +1,27 @@
$:.push File.expand_path("../lib", __FILE__)

require "api_taster/version"

Gem::Specification.new do |s|
s.name = "api_taster"
s.version = ApiTaster::VERSION
s.authors = ["Fred Wu"]
s.email = ["ifredwu@gmail.com"]
s.homepage = "https://github.com/fredwu/api_taster"
s.summary = "A quick and easy way to visually test out your application's API."
s.description = s.summary

s.files = `git ls-files`.split($\)
s.test_files = Dir["spec/**/*"]

s.add_dependency 'rails', '>= 3.1.0'
s.add_dependency 'jquery-rails'
s.add_dependency 'sass-rails'
s.add_dependency 'bootstrap-sass', '~> 2.0.3'

s.add_development_dependency 'rake'
s.add_development_dependency 'simplecov'
s.add_development_dependency 'rspec-rails'
s.add_development_dependency 'pry'
s.add_development_dependency 'thin'
end
Empty file.
28 changes: 28 additions & 0 deletions app/assets/javascripts/api_taster/01-prettify.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6a51182

Please sign in to comment.