Responsible for providing inspection of api methods
Client,Client::Activity,Client::Activity::Events,Client::Activity::Feeds,Client::Activity::Notifications,Client::Activity::Starring,Client::Activity::Watching,Client::Authorizations,Client::Emojis,Client::Gists,Client::Gists::Comments,Client::GitData,Client::GitData::Blobs,Client::GitData::Commits,Client::GitData::References,Client::GitData::Tags,Client::GitData::Trees,Client::Gitignore,Client::Issues,Client::Issues::Assignees,Client::Issues::Comments,Client::Issues::Events,Client::Issues::Labels,Client::Issues::Milestones,Client::Markdown,Client::Meta,Client::Orgs,Client::Orgs::Hooks,Client::Orgs::Members,Client::Orgs::Memberships,Client::Orgs::Projects,Client::Orgs::Teams,Client::Projects,Client::Projects::Cards,Client::Projects::Columns,Client::PullRequests,Client::PullRequests::Comments,Client::PullRequests::Reviews,Client::Repos,Client::Repos::Branches,Client::Repos::Branches::Protections,Client::Repos::Collaborators,Client::Repos::Comments,Client::Repos::Commits,Client::Repos::Contents,Client::Repos::Deployments,Client::Repos::Downloads,Client::Repos::Forks,Client::Repos::Hooks,Client::Repos::Invitations,Client::Repos::Keys,Client::Repos::Merging,Client::Repos::Pages,Client::Repos::Projects,Client::Repos::PubSubHubbub,Client::Repos::Releases,Client::Repos::Releases::Assets,Client::Repos::Releases::Tags,Client::Repos::Statistics,Client::Repos::Statuses,Client::Say,Client::Scopes,Client::Search,Client::Search::Legacy,Client::Users,Client::Users::Emails,Client::Users::Followers,Client::Users::Keys
Classes:Arguments,Config,Factory
Constants::ACCEPT,Constants::ACCEPTED_OAUTH_SCOPES,Constants::ACCEPT_CHARSET,Constants::CACHE_CONTROL,Constants::CONTENT_LENGTH,Constants::CONTENT_TYPE,Constants::DATE,Constants::ETAG,Constants::HEADER_LAST,Constants::HEADER_LINK,Constants::HEADER_NEXT,Constants::LOCATION,Constants::META_FIRST,Constants::META_LAST,Constants::META_NEXT,Constants::META_PREV,Constants::META_REL,Constants::OAUTH_SCOPES,Constants::PARAM_PAGE,Constants::PARAM_PER_PAGE,Constants::PARAM_START_PAGE,Constants::RATELIMIT_LIMIT,Constants::RATELIMIT_REMAINING,Constants::RATELIMIT_RESET,Constants::SERVER,Constants::USER_AGENT
Returns the value of attribute root.
Returns the value of attribute current_options.
List of after callbacks.
After request filter.
List of before callbacks.
Before request filter.
Returns all API public methods for a given class.
Extracts class name from options.
Defines a namespace.
Find all the api methods that should be considred by request callbacks.
Requires internal libraries.
Finds api methods in a class.
Acts as setter and getter for api requests arguments parsing.
Disable following redirects inside a block.
Execute action.
Extract login and password from basic_auth parameter.
Filter callbacks based on kind.
Create new API.
Responds to attribute query or attribute clear.
Finds methods included through class modules.
Run all callbacks associated with this action.
Set a configuration option for a given namespace.
Call block with argument.
#delete_request,#get_request,#head_request,#options_request,#patch_request,#post_request,#put_request
#ratelimit,#ratelimit_remaining,#ratelimit_reset
#auth_code,#authenticated?,#authentication,#authorize_url,#basic_authed?,#client,#get_token
Create new API
596061626364656667686970717273 | # File 'lib/github_api/api.rb', line 59definitialize(={},&block)opts=Github.configuration.fetch.merge()@current_options=optsGithub.configuration.property_names.eachdo|key|send("#{key}=",opts[key])endifopts.key?(:login)&&!opts[:login].nil?@login,@password=opts[:login],opts[:password]elsifopts.key?(:basic_auth)&&!opts[:basic_auth].nil?@login,@password=extract_basic_auth(opts[:basic_auth])endyield_or_eval(&block)ifblock_given?end |
This class handles dynamic methods through themethod_missing method
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Responds to attribute query or attribute clear
258259260261262263264265266267 | # File 'lib/github_api/api.rb', line 258defmethod_missing(method_name,*args,&block)# :nodoc:casemethod_name.to_swhen/^(.*)\?$/return!!send($1.to_s)when/^clear_(.*)$/send("#{$1.to_s}=",nil)elsesuperendend |
Returns the value of attribute root.
134135136 | # File 'lib/github_api/api.rb', line 134defroot@rootend |
Returns the value of attribute current_options.
282930 | # File 'lib/github_api/api.rb', line 28def@current_optionsend |
List of after callbacks
115116117 | # File 'lib/github_api/api.rb', line 115defself.after_callbacks@after_callbacks||=[]end |
After request filter
129130131 | # File 'lib/github_api/api.rb', line 129defself.after_request(callback,params={})after_callbacks<<params.merge(callback:callback)end |
List of before callbacks
108109110 | # File 'lib/github_api/api.rb', line 108defself.before_callbacks@before_callbacks||=[]end |
Before request filter
122123124 | # File 'lib/github_api/api.rb', line 122defself.before_request(callback,params={})before_callbacks<<params.merge(callback:callback)end |
183184185 | # File 'lib/github_api/api.rb', line 183defself.clear_request_methods!@request_methods=nilend |
Returns all API public methods for a given class.
Returns:
1112131415161718192021222324 | # File 'lib/github_api/api/actions.rb', line 11defself.extend_with_actions(child_class)returnunlesschild_class.is_a?(Class)returnifchild_class.name.nil?# Skip anonymous classeschild_class.class_eval<<-RUBY_EVAL,__FILE__,__LINE__+1 def self.actions self.new.actions end def actions api_methods_in(#{child_class}) + module_methods_in(#{child_class}) end RUBY_EVALend |
164165166 | # File 'lib/github_api/api.rb', line 164defself.extra_methods['actions']end |
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extracts class name from options
extract_class_name(:stats,class_name::statistics)Parameters:
Options Hash (options):
the full name for the class
if the class is at the root or not
Returns:
353354355356357358359 | # File 'lib/github_api/api.rb', line 353defself.extract_class_name(name,)converted=.fetch(:full_name,name).to_sconverted=converted.split('_').map(&:capitalize).joinclass_name=.fetch(:root,false)?'':"#{self.name}::"class_name+=convertedclass_nameend |
142143144145146147148149150151152153154 | # File 'lib/github_api/api.rb', line 142defself.inherited(child_class)before_callbacks.reverse_each{|callback|child_class.before_callbacks.unshift(callback)}after_callbacks.reverse_each{|callback|child_class.after_callbacks.unshift(callback)}extend_with_actions(child_class)unlesschild_class.instance_variable_defined?(:@root)child_class.instance_variable_set(:@root,false)endsuperend |
158159160161162 | # File 'lib/github_api/api.rb', line 158defself.internal_methodsapi=selfapi=api.superclassuntilapi.root?api.public_instance_methods(true)end |
187188189190191192193194195196197198199200201202203204205206207208209210211212213214 | # File 'lib/github_api/api.rb', line 187defself.method_added(method_name)method_name=method_name.to_s.gsub(/_with(out)?_callback_.*$/,'')# Only subclasses matterreturnifself.root?returnifextra_methods.include?(method_name)# Only public methods are of interestreturnunlessrequest_methods.include?(method_name)# Do not redefinereturnif(@__methods_added||=[]).include?(method_name)class_name=self.name.to_s.split('::').last.downcasewith_method="#{method_name}_with_callback_#{class_name}"without_method="#{method_name}_without_callback_#{class_name}"returnifpublic_method_defined?(with_method)[method_name,with_method,without_method].eachdo|met|@__methods_added<<metendreturnifpublic_method_defined?(with_method)define_method(with_method)do|*args,&block|send(:execute,without_method,*args,&block)endalias_methodwithout_method,method_namealias_methodmethod_name,with_methodclear_request_methods!end |
Defines a namespace
322323324325326327328329330331332333334335336337 | # File 'lib/github_api/api.rb', line 322defself.namespace(*names)=names.last.is_a?(Hash)?names.pop:{}names=names.map(&:to_sym)name=names.popifpublic_method_defined?(name)raiseArgumentError,"namespace '#{name}' is already defined"endclass_name=extract_class_name(name,)define_method(name)do|*args,&block|=args.last.is_a?(Hash)?args.pop:{}API::Factory.new(class_name,.merge(),&block)endend |
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Find all the api methods that should be considred by request callbacks.
Returns:
174175176177178179180181 | # File 'lib/github_api/api.rb', line 174defself.request_methods@request_methods||=beginmethods=(public_instance_methods(true)-internal_methods+public_instance_methods(false)).uniq.map(&:to_s)Set.new(methods-extra_methods)endend |
Requires internal libraries
Parameters:
the relative path prefix
the array of libraries to require
Returns:
5051525354 | # File 'lib/github_api/api.rb', line 50defself.require_all(prefix,*libs)libs.eachdo|lib|require"#{File.join(prefix,lib)}"endend |
138139140 | # File 'lib/github_api/api.rb', line 138defself.root!@root=trueend |
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finds api methods in a class
Parameters:
The klass to inspect for methods.
32333435363738394041 | # File 'lib/github_api/api/actions.rb', line 32defapi_methods_in(klass)methods=klass.send(:instance_methods,false)-[:actions]methods.sort.each_with_object([])do|method_name,accumulator|unlessmethod_name.to_s.include?('with')||method_name.to_s.include?('without')accumulator<<method_nameendaccumulatorendend |
Acts as setter and getter for api requests arguments parsing.
Returns Arguments instance.
277278279280281282283 | # File 'lib/github_api/api.rb', line 277defarguments(args=(not_set=true),={},&block)ifnot_set@argumentselse@arguments=Arguments.new(.merge!(api:self)).parse(*args,&block)endend |
Disable following redirects inside a block
9899100101102103 | # File 'lib/github_api/api.rb', line 98defdisable_redirectsself.follow_redirects=falseyieldensureself.follow_redirects=trueend |
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Execute action
Parameters:
246247248249250251252253 | # File 'lib/github_api/api.rb', line 246defexecute(action,*args,&block)action_name=action.to_s.gsub(/_with(out)?_callback_.*$/,'')result=nilrun_callbacks(action_name)doresult=send(action,*args,&block)endresultend |
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extract login and password from basic_auth parameter
8687888990919293 | # File 'lib/github_api/api.rb', line 86defextract_basic_auth(auth)caseauthwhenStringauth.split(':',2)whenHash[auth[:login],auth[:password]]endend |
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Filter callbacks based on kind
224225226227228 | # File 'lib/github_api/api.rb', line 224deffilter_callbacks(kind,action_name)self.class.send("#{kind}_callbacks").selectdo|callback|callback[:only].nil?||callback[:only].include?(action_name)endend |
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finds methods included through class modules
Parameters:
The klass to inspect for methods.
49505152535455565758 | # File 'lib/github_api/api/actions.rb', line 49defmodule_methods_in(klass)klass.included_modules.each_with_object([])do|mod,accumulator|ifmod.to_s=~/#{klass}/mod.instance_methods(false).eachdo|method|accumulator<<methodendendaccumulatorendend |
Returns:
269270271 | # File 'lib/github_api/api.rb', line 269defrespond_to?(method_name,include_private=false)method_name.to_s.start_with?('clear_')||superend |
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Run all callbacks associated with this action
Parameters:
235236237238239 | # File 'lib/github_api/api.rb', line 235defrun_callbacks(action_name,&block)filter_callbacks(:before,action_name).each{|hook|sendhook[:callback]}yieldifblock_given?filter_callbacks(:after,action_name).each{|hook|sendhook[:callback]}end |
Set a configuration option for a given namespace
Parameters:
Returns:
Raises:
294295296297298299300301302303304305306307308309 | # File 'lib/github_api/api.rb', line 294defset(option,value=(not_set=true),ignore_setter=false,&block)raiseArgumentError,'value not set'ifblockand!not_setreturnselfif!not_setandvalue.nil?ifnot_setoptionreturnselfendifrespond_to?("#{option}=")andnotignore_setterreturn__send__("#{option}=",value)enddefine_accessorsoption,valueselfend |
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Call block with argument
78798081 | # File 'lib/github_api/api.rb', line 78defyield_or_eval(&block)returnunlessblockblock.arity>0?yield(self):self.instance_eval(&block)end |