Skip to content

Common code needed by the other Fb gems. Not intended for direct use

License

Notifications You must be signed in to change notification settings

nullscreen/fb-support

Repository files navigation

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 and the documentation on RubyDoc.

Build Status Coverage Status Dependency Status Code Climate Online docs Gem Version

Fb::Support provides:

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.

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 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 🎉

About

Common code needed by the other Fb gems. Not intended for direct use

Resources

License

Stars

Watchers

Forks

Packages

No packages published