https://github.com/nullscreen/fb-support
Common code needed by the other Fb gems. Not intended for direct use
https://github.com/nullscreen/fb-support
Last synced: 2 months ago
JSON representation
Common code needed by the other Fb gems. Not intended for direct use
- Host: GitHub
- URL: https://github.com/nullscreen/fb-support
- Owner: nullscreen
- License: mit
- Created: 2017-07-24T22:34:28.000Z (almost 8 years ago)
- Default Branch: main
- Last Pushed: 2022-10-30T20:49:01.000Z (over 2 years ago)
- Last Synced: 2025-03-30T12:34:42.309Z (3 months ago)
- Language: Ruby
- Size: 22.5 KB
- Stars: 0
- Watchers: 8
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
Common code needed by the other Fb gems
=======================================Fb::Support provides common functionality to all Fb gems.
It is considered suitable for internal use only at this time.The **source code** is available on [GitHub](https://github.com/fullscreen/fb-support) and the **documentation** on [RubyDoc](http://www.rubydoc.info/gems/fb-support/frames).
[](https://travis-ci.org/Fullscreen/fb-support)
[](https://coveralls.io/r/Fullscreen/fb-support)
[](https://gemnasium.com/Fullscreen/fb-support)
[](https://codeclimate.com/github/Fullscreen/fb-support)
[](http://www.rubydoc.info/gems/fb-support/frames)
[](http://rubygems.org/gems/fb-support)Fb::Support provides:
* [Fb.configure](http://www.rubydoc.info/gems/fb-support/Fb/Config#configure-instance_method)
* [Fb::Configuration](http://www.rubydoc.info/gems/fb-support/Fb/Configuration)
* [Fb::HTTPRequest](http://www.rubydoc.info/gems/fb-support/Fb/HTTPRequest)
* [Fb::HTTPError](http://www.rubydoc.info/gems/fb-support/Fb/HTTPError)## Response callback
`Fb::HTTPRequest` has an `on_response` callback which is invoked with
the request object and the HTTP response object on a successful
response. This can be used for introspecting responses, performing some
action when rate limit is near, etc.```rb
Fb::HTTPRequest.on_response = lambda do |request, response|
usage = request.rate_limiting_header
Librato.measure 'fb.call_count', usage['call_count']
Librato.measure 'fb.total_cputime', usage['total_cputime']
Librato.measure 'fb.total_time', usage['total_time']
if usage.values.any? {|value| value > 85 }
sleep 180
end
end
```How to test
===========In order to run the tests you need to have one Facebook access token and set
it as an environment variable:export FB_TEST_ACCESS_TOKEN="5040|67b895"
There are many [documented ways](https://developers.facebook.com/docs/facebook-login/access-tokens#apptokens) to generate a test access token.
The easiest way is probably to:- create a Facebook app
- copy its app Id and app Secret
- join them as "app-id|app-secret"… that is a valid access token!How to contribute
=================Contribute to the code by forking the project, adding the missing code,
writing the appropriate tests and submitting a pull request.In order for a PR to be approved, all the tests need to pass and all the public
methods need to be documented and listed in the guides. Remember:- to run all tests locally: `bundle exec rspec`
- to generate the docs locally: `bundle exec yard`
- to list undocumented methods: `bundle exec yard stats --list-undoc`Thanks :tada: