unReST
To build very quick little API clients for legacy or tiny APIs with no existing gems.
Installation
Add this line to your application's Gemfile:
gem 'unrest'
And then execute:
$ bundle
Or install it yourself as:
$ gem install unrest
Usage
unReST works by using files of request templates, and their directory structure, to dynamically build the API client.
Setting up a project like this, for example:
.
+-- example.rb
+-- ip.html
+-- image
| +-- png.xml
| +-- svg.html
| +-- jpeg.json
| +-- webp.text
This will generate an API client with access to the follwoing endpoints/methods:
# example.rb
require('unrest')
client = Unrest.new('https://httpbin.org')
client.ip
: https://httpbin.org/ipclient.image_png
: https://httpbin.org/image/pngclient.image_svg
: https://httpbin.org/image/svgclient.image_jpeg
: https://httpbin.org/image/jpegclient.image_webp
: https://httpbin.org/image/webp
The file extentions: xml
, html
, json
and text
will be used against the API and the results formatted accordingly. Since, in the exampe, we will be sending nothing to the API- these files can be empty.
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/eksoverzero/unrest.
License
The gem is available as open source under the terms of the MIT License.