Sha256: 10129ea37c782991ad98639f692bcc5c3ee4ac4a7e89201330172628e5b7757f

Contents?: true

Size: 1.07 KB

Versions: 50

Compression:

Stored size: 1.07 KB

Contents

# encoding: utf-8

module Github
  class API

    # 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 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)
      _method = self.method(method)
      if _method.arity == 0
        args = "()"
      elsif _method.arity > 0
        args = "(few)"
      else
        args = "(else)"
      end
      args
    end

  end # API
end # Github

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
github_api-0.11.3 lib/github_api/api/actions.rb
github_api-0.11.2 lib/github_api/api/actions.rb
github_api-0.11.1 lib/github_api/api/actions.rb
github_api-0.11.0 lib/github_api/api/actions.rb
github_api-0.10.2 lib/github_api/api/actions.rb
github_api-0.10.1 lib/github_api/api/actions.rb
github_api-0.10.0 lib/github_api/api/actions.rb
github_api-0.9.7 lib/github_api/api/actions.rb
github_api-0.9.6 lib/github_api/api/actions.rb
github_api-0.9.5 lib/github_api/api/actions.rb
github_api-0.9.4 lib/github_api/api/actions.rb
github_api-0.9.3 lib/github_api/api/actions.rb
github_api-0.9.2 lib/github_api/api/actions.rb
github_api-0.9.1 lib/github_api/api/actions.rb
github_api-0.9.0 lib/github_api/api/actions.rb
github_api-0.8.11 lib/github_api/api/actions.rb
github_api-0.8.10 lib/github_api/api/actions.rb
github_api-0.8.9 lib/github_api/api/actions.rb
github_api-0.8.8 lib/github_api/api/actions.rb
github_api-0.8.7 lib/github_api/api/actions.rb