Sha256: d788ec1979f0f306987cd27b261d5a6fe8fb18754096a8cfcc05605436bf86da

Contents?: true

Size: 919 Bytes

Versions: 41

Compression:

Stored size: 919 Bytes

Contents

require "rubygems"
require "bundler/setup"
require "./examples/config" if File.exists?('examples/config.rb')
require "api_client"
require "time"

module Github

  class Base < ApiClient::Base
    namespace false

    always do
      endpoint "https://api.github.com"
    end
  end

  class User < Base

    def self.find(name)
      fetch("/users/#{name}")
    end

    def events
      Github::Event.fetch("/users/#{login}/events")
    end

    def received_events
      Github::Event.fetch("/users/#{login}/received_events")
    end

  end

  class Event < Base

    def created_at
      Time.parse self['created_at']
    end

  end

end

user = Github::User.find("marcinbunsch")

user.events.each do |event|
  case event.type
    when "FollowEvent"
      puts "#{event.created_at} #{event.payload.target.login}: #{event.type}"
    else
      puts "#{event.created_at} #{event.repo.name} : #{event.type}"
    end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
api_client-0.5.1 examples/github.rb
api_client-0.5.0 examples/github.rb
api_client-0.4.3 examples/github.rb
api_client-0.4.2 examples/github.rb
api_client-0.4.1 examples/github.rb
api_client-0.3.3 examples/github.rb
api_client-0.4.0 examples/github.rb
api_client-0.3.2 examples/github.rb
api_client-0.3.1 examples/github.rb
api_client-0.3.0 examples/github.rb
api_client-0.2.0 examples/github.rb
api_client-0.1.9 examples/github.rb
api_client-0.1.8 examples/github.rb
api_client-0.1.7 examples/github.rb
api_client-0.1.6 examples/github.rb
api_client-0.1.5 examples/github.rb
api_client-0.1.4 examples/github.rb
api_client-0.1.3 examples/github.rb
api_client-0.1.2 examples/github.rb
api_client-0.1.1 examples/github.rb