Class: Stratify::GitHub::Event::CreateEvent

Inherits:
Stratify::GitHub::Event show all
Defined in:
lib/stratify-github/events.rb

Class Method Summary collapse

Methods inherited from Stratify::GitHub::Event

repo_url, trunc

Class Method Details

.make(activity, api_hash) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/stratify-github/events.rb', line 26

def self.make(activity, api_hash)
  activity.ref      = api_hash['payload']['ref']
  activity.ref_type = api_hash['payload']['ref_type']
  # This is a bummer. There's no omni-present repo element.
  if activity.ref_type == 'repository'
    activity.repository = api_hash['url']
  else
    activity.repository = repo_url(api_hash['url'])
  end
  activity
end

.text(activity) ⇒ Object



37
38
39
40
41
# File 'lib/stratify-github/events.rb', line 37

def self.text(activity)
  # ref is populated if ref_type is not 'repository'.
  ref = activity.ref ? "#{activity.ref} on" : ''
  "#{activity.actor} created #{activity.ref_type} #{ref} #{activity.repository}"
end