0

For example, I tried to find a manual for OAuth package here but I get Ooops page missing here. I tried rim utility as instructed in Manual pages for Ruby functions from command line but version not documented

= OAuth

(from gem oauth-0.5.3)
------------------------------------------------------------------------------

------------------------------------------------------------------------------
= Constants:

OUT_OF_BAND:
  request tokens are passed between the consumer and the provider out of band
  (i.e. callbacks cannot be used), per section 6.1.1

PARAMETERS:
  required parameters, per sections 6.1.1, 6.3.1, and 7

RESERVED_CHARACTERS:
  reserved character regexp, per section 5.1

VERSION:
  [not documented]

Because of missing manuals, I have tried to find tools to list methods of packages like in IDE like Dropdown list for ruby methods of a package in RubyMine IDE? and Vim plugin to autocomplete method names of Ruby packages. I haven't yet found a solution there and, here, I want to keep the focus on the manuals and proper ways to find them in Ruby.

Is there some central place for Ruby package manuals like R's cran? And if not, how do authors of public Ruby packages usually document their plugins? Is the easiest way to see which methods each package has to read the source?

hhh
  • 50,788
  • 62
  • 179
  • 282
  • I would look at the gem source code and its README - often found in the links list on its rubygems.org page. – spickermann Aug 05 '17 at 14:27
  • _"Ooops page missing"_ – 0.5.3 seems to be missing (there is a link somewhere to build it), try http://www.rubydoc.info/gems/oauth for the latest version available. – Stefan Aug 05 '17 at 14:28

1 Answers1

0

This is not the easiest way but you can unpack any gem file corresponding to a package where you may be able to find demonstrations about the usage of each package.


Example about OAuth

You can download the gem file and unpack it to read the source in the following way

wget https://rubygems.org/downloads/oauth-0.5.3.gem

gem unpack oauth-0.5.3.gem

where you find the README with a demonstration about the usage.

README.rdoc

== Demonstration of usage

 We need to specify the oauth_callback url explicitly, otherwise it defaults to "oob" (Out of Band)

   @callback_url = "http://127.0.0.1:3000/oauth/callback"

 Create a new consumer instance by passing it a configuration hash:

   @consumer = OAuth::Consumer.new("key","secret", :site => "https://agree2")

 Start the process by requesting a token

   @request_token = @consumer.get_request_token(:oauth_callback => @callback_url)

   session[:token] = request_token.token
   session[:token_secret] = request_token.secret
   redirect_to @request_token.authorize_url(:oauth_callback => @callback_url)

 When user returns create an access_token

   hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret]}
   request_token  = OAuth::RequestToken.from_hash(@consumer, hash)
   @access_token = @request_token.get_access_token
   @photos = @access_token.get('/photos.xml')

 Now that you have an access token, you can use Typhoeus to interact with the OAuth provider if you choose.

   require 'oauth/request_proxy/typhoeus_request'
   oauth_params = {:consumer => oauth_consumer, :token => access_token}
   hydra = Typhoeus::Hydra.new
   req = Typhoeus::Request.new(uri, options) # :method needs to be specified in options
   oauth_helper = OAuth::Client::Helper.new(req, oauth_params.merge(:request_uri => uri))
   req.options[:headers].merge!({"Authorization" => oauth_helper.header}) # Signs the request
   hydra.queue(req)
   hydra.run
   @response = req.response

All functions in Ruby OAuth find . -iname "*.rb"

./lib/oauth/cli/authorize_command.rb
./lib/oauth/cli/base_command.rb
./lib/oauth/cli/help_command.rb
./lib/oauth/cli/query_command.rb
./lib/oauth/cli/sign_command.rb
./lib/oauth/cli/version_command.rb
./lib/oauth/cli.rb
./lib/oauth/client/action_controller_request.rb
./lib/oauth/client/em_http.rb
./lib/oauth/client/helper.rb
./lib/oauth/client/net_http.rb
./lib/oauth/client.rb
./lib/oauth/consumer.rb
./lib/oauth/core_ext.rb
./lib/oauth/errors/error.rb
./lib/oauth/errors/problem.rb
./lib/oauth/errors/unauthorized.rb
./lib/oauth/errors.rb
./lib/oauth/helper.rb
./lib/oauth/oauth.rb
./lib/oauth/oauth_test_helper.rb
./lib/oauth/request_proxy/action_controller_request.rb
./lib/oauth/request_proxy/base.rb
./lib/oauth/request_proxy/curb_request.rb
./lib/oauth/request_proxy/em_http_request.rb
./lib/oauth/request_proxy/jabber_request.rb
./lib/oauth/request_proxy/mock_request.rb
./lib/oauth/request_proxy/net_http.rb
./lib/oauth/request_proxy/rack_request.rb
./lib/oauth/request_proxy/rest_client_request.rb
./lib/oauth/request_proxy/typhoeus_request.rb
./lib/oauth/request_proxy.rb
./lib/oauth/server.rb
./lib/oauth/signature/base.rb
./lib/oauth/signature/hmac/sha1.rb
./lib/oauth/signature/plaintext.rb
./lib/oauth/signature/rsa/sha1.rb
./lib/oauth/signature.rb
./lib/oauth/token.rb
./lib/oauth/tokens/access_token.rb
./lib/oauth/tokens/consumer_token.rb
./lib/oauth/tokens/request_token.rb
./lib/oauth/tokens/server_token.rb
./lib/oauth/tokens/token.rb
./lib/oauth/version.rb
./lib/oauth.rb
hhh
  • 50,788
  • 62
  • 179
  • 282