Project

bocu

0.0
No commit activity in last 3 years
No release in over 3 years
Ruby wrapper for coub.com API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.14
~> 5.10
~> 0.10
~> 12
~> 0.10
~> 3

Runtime

~> 0.9
 Project Readme

Bocu

Build Status

API wrapper for Coub

Powered by Her — ORM for REST API.

Currently under development, so it supports only several public API methods.

Installation

Add this line to your application's Gemfile:

gem 'bocu'

Usage

You can check official Coub API docs here.

Search by query:
require 'bocu'

coubs = Bocu::Coub.search('optimism')
coubs = coubs.order_by(:likes_count).page(5).per(25).fetch
# returns array of coubs, wrapped with Her::Model

coubs.first.attributes
# => returns Big Coub JSON, most part is omitted
# => {"flag"=>nil, "abuses"=>nil, "recoubs_by_users_channels"=>nil,
# "recoub"=>nil, "like"=>nil, "in_my_best2015"=>false,
# "type"=>"Coub::Simple", "permalink"=>"5kirj"...
Search by id:
require 'bocu'

coub = Bocu::Coub.find('70x8c')
# => returns Big Coub JSON, most part is omitted
# => #<Bocu::Coub(coubs/12553778) flag=nil abuses=nil recoubs_by_users_channels=nil recoub=nil like=nil
# in_my_best2015=false type="Coub::Simple" permalink="70x8c" title="House Every Weekend"
# visibility_type="public" original_visibility_type="public" channel_id=1162114
# created_at="2015-06-26T04:24:28Z" updated_at="2017-07-10T03:56:43Z" ...
Timeline:

Related docs

require 'bocu'

Bocu::Coub.by_tag('games').fetch # coubs by tag
Bocu::Coub.hot.fetch # timeline of the Hot section

# timeline of the Explore section categories
Bocu::Coub.random.fetch
Bocu::Coub.newest.fetch
Bocu::Coub.coub_of_the_day.fetch
Using chainable scopes for pagination and ordering:
require 'bocu'

coubs = Bocu::Coub.search('drive')
coubs = coubs.order_by(:views_count).per_page(5).page(2)

result = coubs.fetch # Returns array of 5 hot coubs starting from page 2
result.metadata # {:page=>"2", :total_pages=>504, :per_page=>"5"}
result.count # 5

TODO

  • Improve documentaion
  • More tests
  • More supported methods
  • Authentication(?)

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test 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/vaihtovirta/bocu.

License

The gem is available as open source under the terms of the MIT License.