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.24 examples/github.rb
api_client-0.5.22 examples/github.rb
api_client-0.5.21 examples/github.rb
api_client-0.5.20 examples/github.rb
api_client-0.5.19 examples/github.rb
api_client-0.5.18 examples/github.rb
api_client-0.5.17 examples/github.rb
api_client-0.5.16 examples/github.rb
api_client-0.5.15 examples/github.rb
api_client-0.5.14 examples/github.rb
api_client-0.5.13 examples/github.rb
api_client-0.5.12 examples/github.rb
api_client-0.5.11 examples/github.rb
api_client-0.5.9 examples/github.rb
api_client-0.5.7 examples/github.rb
api_client-0.5.6 examples/github.rb
api_client-0.5.5 examples/github.rb
api_client-0.5.4 examples/github.rb
api_client-0.5.3 examples/github.rb
api_client-0.5.2 examples/github.rb