class Github::API

Core class for api interface operations

def self.inherited(klass)

Returns all API public methods for a given class.
def self.inherited(klass)
  klass.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
    def self.actions
      self.new.api_methods_in(#{klass})
    end
    def actions
      api_methods_in(#{klass})
    end
  RUBY_EVAL
  super
end

def _merge_mime_type(resource, params) # :nodoc:

:nodoc:
def _merge_mime_type(resource, params) # :nodoc:
    params['resource'] = resource
    params['mime_type'] = params['mime_type'] || :raw
end

def api_methods_in(klass)

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

def append_arguments(method)

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

def initialize(options={}, &block)

Creates new API
def initialize(options={}, &block)
  super()
  setup options
  set_api_client
  client if client_id? && client_secret?
  self.instance_eval(&block) if block_given?
end

def method_missing(method, *args, &block) # :nodoc:

:nodoc:
Responds to attribute query or attribute clear
def method_missing(method, *args, &block) # :nodoc:
  case method.to_s
  when /^(.*)\?$/
    return !self.send($1.to_s).nil?
  when /^clear_(.*)$/
    self.send("#{$1.to_s}=", nil)
  else
    super
  end
end

def process_basic_auth(auth)

Extract login and password from basic_auth parameter
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

def set(option, value=(not_set = true), &block)

Set an option to a given value
def set(option, value=(not_set = true), &block)
  raise ArgumentError, 'value not set' if block and !not_set
  if not_set
    set_options option
    return self
  end
  if respond_to?("#{option}=")
    return __send__("#{option}=", value)
  end
  self
end

def set_api_client

Assigns current api class
def set_api_client
  Github.api_client = self
end

def set_options(options)

Set multiple options
def set_options(options)
  unless options.respond_to?(:each)
    raise ArgumentError, 'cannot iterate over value'
  end
  options.each { |key, value| set(key, value) }
end

def setup(options={})

def setup(options={})
  options = Github.options.merge(options)
  Configuration::VALID_OPTIONS_KEYS.each do |key|
    send("#{key}=", options[key])
  end
  process_basic_auth(options[:basic_auth])
end