Module: Forrst
- Defined in:
- lib/forrst.rb,
lib/forrst/post.rb,
lib/forrst/user.rb,
lib/forrst/comment.rb,
lib/forrst/version.rb
Overview
The Forrst gem is an API library for the Forrst API that focuses on stability, ease of use and minimal dependencies.
Defined Under Namespace
Constant Summary collapse
- URL =
The URL to the API endpoint.
'http://forrst.com/api/v2/'- StatisticsURL =
URL relative to Forrst::URL that contains all the API statistics.
'/stats'- DateFormat =
A string containing the date format used for all dates returned by the API.
'%Y-%m-%d %H:%M:%S'- Version =
'0.1.1'
Class Attribute Summary collapse
-
.access_token ⇒ Object
The access token returned once a client has been authorized.
-
.id ⇒ Object
The ID of the application as provided by Forrst.
-
.oauth ⇒ Object
Instance of OAuth2::Client.
-
.secret ⇒ Object
The secret of the application as provided by Forrst.
Class Method Summary collapse
-
.configure { ... } ⇒ Object
Sets various configuration options in the module so that they can be used by other parts of this gem.
-
.statistics ⇒ Hash
Gets a set of statistics from the API server.
Class Attribute Details
.access_token ⇒ Object
The access token returned once a client has been authorized.
44 45 46 |
# File 'lib/forrst.rb', line 44 def access_token @access_token end |
.id ⇒ Object
The ID of the application as provided by Forrst.
47 48 49 |
# File 'lib/forrst.rb', line 47 def id @id end |
.oauth ⇒ Object
Instance of OAuth2::Client.
53 54 55 |
# File 'lib/forrst.rb', line 53 def oauth @oauth end |
.secret ⇒ Object
The secret of the application as provided by Forrst.
50 51 52 |
# File 'lib/forrst.rb', line 50 def secret @secret end |
Class Method Details
.configure { ... } ⇒ Object
Sets various configuration options in the module so that they can be used by other parts of this gem.
68 69 70 71 72 |
# File 'lib/forrst.rb', line 68 def configure yield self @oauth = OAuth2::Client.new(@id, @secret, :site => URL) end |
.statistics ⇒ Hash
Gets a set of statistics from the API server.
85 86 87 88 89 90 91 92 93 94 |
# File 'lib/forrst.rb', line 85 def statistics response = @oauth.request(:get, StatisticsURL) response = JSON.load(response) hash = { :limit => response['resp']['rate_limit'].to_i, :calls => response['resp']['calls_made'].to_i } return hash end |