Class: Cline::Collectors::Github

Inherits:
Base
  • Object
show all
Defined in:
lib/cline/collectors/github.rb

Defined Under Namespace

Classes: Activity

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

create_or_pass

Constructor Details

#initialize(name) ⇒ Github

Returns a new instance of Github.



23
24
25
26
27
28
# File 'lib/cline/collectors/github.rb', line 23

def initialize(name)
  require 'open-uri'
  require 'uri'

  @api_url = URI.parse("https://api.github.com/users/#{name}/received_events")
end

Class Method Details

.collectObject



6
7
8
9
10
# File 'lib/cline/collectors/github.rb', line 6

def collect
  new().activities.each do |message, notified_at|
    create_or_pass message, notified_at
  end
end

.login_nameObject



16
17
18
# File 'lib/cline/collectors/github.rb', line 16

def 
  @login_name
end

.login_name=(name) ⇒ Object



12
13
14
# File 'lib/cline/collectors/github.rb', line 12

def (name)
  @login_name = name
end

Instance Method Details

#activitiesObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/cline/collectors/github.rb', line 30

def activities
  events = JSON.parse(@api_url.read)

  events.map { |event|
    message = extract_message(event)
    next unless message

    [message, event['created_at']]
  }.compact
end