Halibut is a tiny gem that makes it easier to deal with the HAL format.
In providing tools to build, (de)serialize, and manipulate HAL resources, Halibut has the following goals:
- Provide Ruby abstractions
- Clean, small API
- Easily composable, for use in other libraries
Add this line to your application's Gemfile:
gem 'halibut'
And then execute:
$ bundle
Or install it yourself as:
$ gem install halibut
There are three ways to get a resource with halibut: manual, Builder, and JSON.
require'halibut'# manually creating a resourceorder=Halibut::Core::Resource.new"/orders/123"order.set_property"total",30.00order.set_property"currency","USD"order.set_property"status","shipped"payment=Halibut::Core::Resource.new"/orders/123/payment"payment.set_property"method","credit"payment.set_property"amount","30.00"payment.set_property"auth_code","ABZ127"resource=Halibut::Core::Resource.new"/orders"resource.add_link"find","/orders{?id}",templated: trueresource.add_link"next","/orders/1","name"=>'hotdog'resource.add_link"next","/orders/9"resource.set_property"currentlyProcessing",14resource.set_property"shippedToday",20resource.embed_resource"payment",paymentresource.add_embed_resource"orders",orderrequire'halibut/builder'builder=Halibut::Builder.new'/orders'doproperty'currentlyProcessing',14property'shippedToday',20namespace'th','http://things-db.com/{rel}'link'find','/orders{?id}',templated: truelink'next','/orders/1',name: 'hotdog'link'next','/orders/9'link'th:manufacturer','/manufacturer/1'link'th:manufacturer','/manufacturer/2'link'th:manufacturer','/manufacturer/3'end# alternativelybuilder=Halibut::Builder.new'/orders'doproperty'currentlyProcessing',14property'shippedToday',20namespace'th','http://things-db.com/{rel}'link'find','/orderes{?id}',templated: truerelation'next'dolink'/orders/1',name: 'hotdog'link'/orders/9'endrelation'th:manufacturer'dolink'/manufacturers/1'link'/manufacturers/2'link'/manufacturers/3'endendresource=builder.resourcerequire'halibut/adapter/json'# converting to JSONHalibut::Adapter::JSON.dumpresource# creating a resource from JSONresource=Halibut::Adapter::JSON.load'resource.json'- Fork it
git submodule update --initbundle install, optionally pass--without-developmentand use your own tools
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request






