Class: IrcMachine::Plugin::GithubNotification
- Inherits:
-
Object
- Object
- IrcMachine::Plugin::GithubNotification
- Defined in:
- lib/irc_machine/plugin/github_notifier.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #author_usernames ⇒ Object
- #authors ⇒ Object
- #branch ⇒ Object
- #commit_count ⇒ Object
- #compare_url ⇒ Object
-
#initialize(body) ⇒ GithubNotification
constructor
A new instance of GithubNotification.
- #message ⇒ Object
- #repo_name ⇒ Object
Constructor Details
#initialize(body) ⇒ GithubNotification
Returns a new instance of GithubNotification.
15 16 17 18 |
# File 'lib/irc_machine/plugin/github_notifier.rb', line 15 def initialize(body) json = CGI.parse(body)["payload"][0] @data = OpenStruct.new(JSON.parse(json)) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
13 14 15 |
# File 'lib/irc_machine/plugin/github_notifier.rb', line 13 def data @data end |
Instance Method Details
#author_usernames ⇒ Object
36 37 38 |
# File 'lib/irc_machine/plugin/github_notifier.rb', line 36 def .map{ |a| a.username }.uniq end |
#authors ⇒ Object
32 33 34 |
# File 'lib/irc_machine/plugin/github_notifier.rb', line 32 def data.commits.map{ |c| OpenStruct.new c["author"] } end |
#branch ⇒ Object
28 29 30 |
# File 'lib/irc_machine/plugin/github_notifier.rb', line 28 def branch data.ref.split("/").last end |
#commit_count ⇒ Object
24 25 26 |
# File 'lib/irc_machine/plugin/github_notifier.rb', line 24 def commit_count data.commits.size end |
#compare_url ⇒ Object
40 41 42 |
# File 'lib/irc_machine/plugin/github_notifier.rb', line 40 def compare_url data.compare end |
#message ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/irc_machine/plugin/github_notifier.rb', line 44 def "%d commit%s by %s pushed to %s/%s: %s" % [ commit_count, commit_count == 1 ? "" : "s", .join(", "), repo_name, branch, compare_url ] end |
#repo_name ⇒ Object
20 21 22 |
# File 'lib/irc_machine/plugin/github_notifier.rb', line 20 def repo_name data.repository["name"] end |