Skip to content

Commit

Permalink
Merge pull request #57 from andrewjkerr/andrewjkerr/update-readme-wit…
Browse files Browse the repository at this point in the history
…h-syntax-highlighting

Update README.md to include syntax highlighting
  • Loading branch information
komapa authored Feb 13, 2017
2 parents d7647ba + c97ce04 commit 2cd3d9c
Showing 1 changed file with 45 additions and 45 deletions.
90 changes: 45 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,91 @@
# Tumblr Ruby Gem

[![Gem Version](https://badge.fury.io/rb/tumblr_client.png)](http://badge.fury.io/rb/tumblr_client) [![Build Status](https://secure.travis-ci.org/tumblr/tumblr_client.png)](http://travis-ci.org/tumblr/tumblr_client)
[![Gem Version](https://badge.fury.io/rb/tumblr_client.png)](https://badge.fury.io/rb/tumblr_client) [![Build Status](https://secure.travis-ci.org/tumblr/tumblr_client.png)](https://travis-ci.org/tumblr/tumblr_client)

This is the official Ruby wrapper for the Tumblr v2 API. It supports all
endpoints currently available on the
[Tumblr API](http://www.tumblr.com/docs/en/api/v2).
This is the official Ruby wrapper for the Tumblr v2 API. It supports all endpoints currently available on the [Tumblr API](https://www.tumblr.com/docs/en/api/v2).

## Installation

gem install tumblr_client
```
gem install tumblr_client
```

## Usage

First and foremost, this gem will *not* do a three legged oauth request for you. It is just a wrapper to help make
your life easier when using the v2 api. If you need to do the full oauth workflow, then please check out the
[Ruby OAuth Gem](http://oauth.rubyforge.org/).
First and foremost, this gem will *not* do a three legged oauth request for you. It is just a wrapper to help make your life easier when using the v2 api. If you need to do the full oauth workflow, then please check out the [Ruby OAuth Gem](http://oauth.rubyforge.org/).

### Configuration

Configuration for the gem is actually pretty easy:

Tumblr.configure do |config|
config.consumer_key = "consumer_key"
config.consumer_secret = "consumer_secret"
config.oauth_token = "access_token"
config.oauth_token_secret = "access_token_secret"
end
```ruby
Tumblr.configure do |config|
config.consumer_key = "consumer_key"
config.consumer_secret = "consumer_secret"
config.oauth_token = "access_token"
config.oauth_token_secret = "access_token_secret"
end
```

Once you have your configuration squared away it's time to make some requests!

>> client = Tumblr::Client.new
```ruby
>> client = Tumblr::Client.new
```

That's it! You now have a client that can make any request to the Tumblr API.

Also since the client is created with the amazing library [Faraday](https://github.com/lostisland/faraday), you can
configure it to use any HTTP Client it supports.

>> client = Tumblr::Client.new(:client => :httpclient)
Also since the client is created with the amazing library [Faraday](https://github.com/lostisland/faraday), you can configure it to use any HTTP Client it supports.

```ruby
>> client = Tumblr::Client.new(:client => :httpclient)
```

### Some quick examples

Getting user information:

>> client.info
```ruby
>> client.info
```

Getting a specific blog's posts and type:

# Grabbing a specific blogs posts
>> client.posts("codingjester.tumblr.com")

# Grabbing only the last 10 photos off the blog
>> client.posts("codingjester.tumblr.com", :type => "photo", :limit => 10)
```ruby
# Grabbing a specific blogs posts
>> client.posts("codingjester.tumblr.com")

# Grabbing only the last 10 photos off the blog
>> client.posts("codingjester.tumblr.com", :type => "photo", :limit => 10)
```

Posting some photos to Tumblr:

# Uploads a great photoset
>> client.photo("codingjester.tumblr.com", {:data => ['/path/to/pic.jpg', '/path/to/pic.jpg']})
```ruby
# Uploads a great photoset
>> client.photo("codingjester.tumblr.com", {:data => ['/path/to/pic.jpg', '/path/to/pic.jpg']})
```

### The irb Console

Finally, there is an irb console packaged with the gem that should help you test any calls you want to make.
The magic here is that you have a `.tumblr` file in your home directory. Inside this file it's just a basic
YAML layout with four lines:
Finally, there is an irb console packaged with the gem that should help you test any calls you want to make. The magic here is that you have a `.tumblr` file in your home directory. Inside this file it's just a basic YAML layout with four lines:

consumer_key: "your_consumer_key"
consumer_secret: "your_consumer_secret"
oauth_token: "your_access_token"
oauth_token_secret: "your_access_token_secret"
```yaml
consumer_key: "your_consumer_key"
consumer_secret: "your_consumer_secret"
oauth_token: "your_access_token"
oauth_token_secret: "your_access_token_secret"
```
From there, you should be able to run any of the above commands, with no problem! Just fire off the command `tumblr`
from the terminal and you should be dropped into a console.
From there, you should be able to run any of the above commands, with no problem! Just fire off the command `tumblr` from the terminal and you should be dropped into a console.

---

The first time that you go to use the irb console, if you have no `.tumblr`
file, it will walk you through the process of generating one. You will
be prompted for your consumer_key and consumer_secret (which you can get
here: http://www.tumblr.com/oauth/register) and then sent out to the site
to verify your account. Once you verify, you will be redirected to your
redirect URL (localhost by default) and copy the `oauth_verifier` back into the
console. Then you're all set!
The first time that you go to use the irb console, if you have no `.tumblr` file, it will walk you through the process of generating one. You will be prompted for your `consumer_key` and `consumer_secret` (which you can get here: https://www.tumblr.com/oauth/register) and then sent out to the site to verify your account. Once you verify, you will be redirected to your redirect URL (localhost by default) and copy the `oauth_verifier` back into the console. Then you're all set!

### Contributions and Pull Requests

No request is too small and I encourage everyone to get involved. As you can see, we're sorely lacking in tests! So
please if you would like to contribute, let me know and throw me a pull request!
No request is too small and I encourage everyone to get involved. As you can see, we're sorely lacking in tests! So please if you would like to contribute, let me know and throw me a pull request!

### Requirements

Expand Down

0 comments on commit 2cd3d9c

Please sign in to comment.