Parent

Class/Module Index [+]

Quicksearch

Github::API

Core class for api interface operations

Attributes

current_options[RW]

Public Class Methods

inherited(klass) click to toggle source

Returns all API public methods for a given class.

# File lib/github_api/api/actions.rb, line 6
def self.inherited(klass)
  klass.class_eval         def self.actions          self.new.api_methods_in(#{klass})        end        def actions          api_methods_in(#{klass})        end, __FILE__, __LINE__ + 1
  super
end
new(options={}, &block) click to toggle source

Create new API

# File lib/github_api/api.rb, line 41
def initialize(options={}, &block)
  setup(options)
  yield_or_eval(&block) if block_given?
end

Public Instance Methods

api_methods_in(klass) click to toggle source
# File lib/github_api/api/actions.rb, line 18
def api_methods_in(klass)
  puts "---"
  (klass.send(:instance_methods, false) - ['actions']).sort.each do |method|
    puts "|--> #{method}"
  end
  klass.included_modules.each do |mod|
    if mod.to_s =~ /#{klass}/
      puts "| \\ #{mod.to_s}"
      mod.instance_methods(false).each do |met|
        puts "|  |--> #{met}"
      end
      puts "| /"
    end
  end
  puts "---"
  nil
end
append_arguments(method) click to toggle source
# File lib/github_api/api/actions.rb, line 36
def append_arguments(method)
  _method = self.method(method)
  if _method.arity == 0
    args = "()"
  elsif _method.arity > 0
    args = "(few)"
  else
    args = "(else)"
  end
  args
end
arguments(args=(not_set = true), options={}, &block) click to toggle source

Acts as setter and getter for api requests arguments parsing.

Returns Arguments instance.

# File lib/github_api/api.rb, line 90
def arguments(args=(not_set = true), options={}, &block)
  if not_set
    @arguments
  else
    @arguments = Arguments.new(self, options).parse(*args, &block)
  end
end
process_basic_auth(auth) click to toggle source

Extract login and password from basic_auth parameter

# File lib/github_api/api.rb, line 64
def process_basic_auth(auth)
  case auth
  when String
    self.login, self.password = auth.split(':', 2)
  when Hash
    self.login    = auth[:login]
    self.password = auth[:password]
  end
end
set(option, value=(not_set=true), ignore_setter=false, &block) click to toggle source

Set an option to a given value

# File lib/github_api/api.rb, line 113
def set(option, value=(not_set=true), ignore_setter=false, &block)
  raise ArgumentError, 'value not set' if block and !not_set
  return self if !not_set and value.nil?

  if not_set
    set_options option
    return self
  end

  if respond_to?("#{option}=") and not ignore_setter
    return __send__("#{option}=", value)
  end

  define_accessors option, value
  self
end
setup(options={}) click to toggle source

Configure options and process basic authorization

# File lib/github_api/api.rb, line 53
def setup(options={})
  options = Github.options.merge(options)
  self.current_options = options
  Configuration.keys.each do |key|
    send("#{key}=", options[key])
  end
  process_basic_auth(options[:basic_auth])
end
with(args) click to toggle source

Scope for passing request required arguments.

# File lib/github_api/api.rb, line 100
def with(args)
  case args
  when Hash
    set args
  when /.*\/.*/
    user, repo = args.split('/')
    set :user => user, :repo => repo
  else
    ::Kernel.raise ArgumentError, 'This api does not support passed in arguments'
  end
end
yield_or_eval(&block) click to toggle source
# File lib/github_api/api.rb, line 46
def yield_or_eval(&block)
  return unless block
  block.arity > 0 ? yield(self) : self.instance_eval(&block)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.