sentry-github 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4b5a7e572ecff021b25646e83a7a792e6d3dfc48
4
+ data.tar.gz: 0d24a24de2d683ec985b961eeb8159a57b146cd0
5
+ SHA512:
6
+ metadata.gz: c05d318bf646bcc2438c50899e06326fe2c38af30308a5965652344f39af198aedbc983547d17c7456e537bbdedab0ed21778c05637aa2f317fabfa0aa69612f
7
+ data.tar.gz: 5fe4da47bc6ba8150f6c64fd30031e5614c640da53beb546ea2aff69d5c21dbadfce251387325514bc2f17b23dc8b3344083b405c654d00ee6c616d2f521e451
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ Gemfile.lock
2
+ pkg/
3
+ vendor/cache/*.gem
data/ChangeLog.rdoc ADDED
@@ -0,0 +1,4 @@
1
+ === 0.1.0 / 2015-01-27
2
+
3
+ * Initial release:
4
+ - Parses links and shows information for Repositories and Users
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Alexander Persson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,38 @@
1
+ = sentry-github
2
+
3
+ Parses messages for GitHub links then replies with information about it.
4
+
5
+ == Features
6
+
7
+ * Replies with information about posted repository or user
8
+
9
+ == Examples
10
+
11
+ require 'cinch'
12
+ require 'cinch/plugins/sentry/github'
13
+
14
+ bot = Cinch::Bot.new do
15
+ configure do |c|
16
+ c.nick = "Raknet"
17
+ c.server = "irc.oftc.net"
18
+ c.channels = ["#cinchdev"]
19
+ c.plugins.plugins = [Cinch::Plugins::Sentry::GitHub]
20
+ c.plugins.options = {
21
+ Cinch::Plugins::Sentry::GitHub => {
22
+ "token" => ""
23
+ }
24
+ }
25
+ end
26
+ end
27
+
28
+ bot.start
29
+
30
+ == Install
31
+
32
+ $ gem install sentry-github
33
+
34
+ == Copyright
35
+
36
+ Copyright (c) 2015 Alexander Persson
37
+
38
+ See LICENSE.txt for details.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,87 @@
1
+ require 'cinch'
2
+ require 'octokit'
3
+ require 'action_view'
4
+ require 'twitter-text'
5
+ require 'uri'
6
+ require "sentry/helper"
7
+
8
+ module Cinch
9
+ module Plugins
10
+ module Sentry
11
+ class GitHub
12
+ include Cinch::Plugin
13
+ include Twitter::Extractor
14
+ include ActionView::Helpers::DateHelper
15
+
16
+ # Fetch all github links
17
+ listen_to :channel
18
+
19
+ def initialize(*)
20
+ super
21
+ @bot = bot
22
+ end
23
+
24
+ def listen(m)
25
+ # Exctract urls
26
+ urls = extract_urls(m.message)
27
+
28
+ # Go through all links
29
+ urls.each do |url|
30
+ # Parse the url
31
+ uri = URI.parse(URI.escape(url.to_url))
32
+
33
+ # We only handle GitHub links
34
+ case uri.host
35
+ when "www.github.com", "github.com"
36
+ begin
37
+ if not uri.path.to_s.empty?
38
+ # Split the path by forward slash
39
+ split = uri.path.split "/"
40
+
41
+ # Check if we got a repository name in the link
42
+ if split[2].nil? then
43
+ # Fetch the user information
44
+ user = Ocotkit.user split[1]
45
+
46
+ # Reply with the information
47
+ m.reply("[%s] %s (repos: %s)" % [
48
+ Format(:green, "GitHub"),
49
+ Format(:bold, user.name.nil? ? user.login : user.name),
50
+ Format(:teal, user.public_repos.to_s),
51
+ ])
52
+ else
53
+ # Fetch the repository information
54
+ repo = Octokit.repo split[1] + "/" + split[2]
55
+
56
+ # Fetch the latest commit
57
+ message = repo.rels[:commits].get.data.first.commit.message
58
+
59
+ # Reply with the information
60
+ m.reply("[%s][%s] %s (commit: %s) (last update: %s) (stars: %s) (forks: %s)" % [
61
+ Format(:green, "GitHub"),
62
+ Format(:blue, repo.owner.login),
63
+ Format(:bold, repo.name),
64
+ Format(:orange, message.gsub(%r{[\n]+}," ")),
65
+ Format(:orange, time_ago_in_words(repo.pushed_at).gsub(%r{(about[\s]+)?}, "") + " ago"),
66
+ Format(:teal, repo.stargazers_count.to_s),
67
+ Format(:teal, repo.forks.to_s)
68
+ ])
69
+ end
70
+ end
71
+ rescue Exception => e
72
+ # Log the exception
73
+ puts e
74
+
75
+ # Send back error message
76
+ m.reply("[%s] %s" % [
77
+ Format(:green, "GitHub"),
78
+ Format(:bold, "Invalid GitHub link")
79
+ ])
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = "sentry-github"
5
+ gem.version = File.new("VERSION", 'r').read.chomp
6
+ gem.summary = %q{Fetches information about posted GitHub links}
7
+ gem.license = "MIT"
8
+ gem.authors = ["Alexander Persson"]
9
+ gem.email = "apersson.93@gmail.com"
10
+ gem.homepage = "https://rubygems.org/gems/sentry-github"
11
+
12
+ gem.files = `git ls-files`.split($/)
13
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
+ gem.require_paths = ['lib']
16
+
17
+ gem.add_development_dependency 'bundler', '~> 1.0'
18
+ gem.add_development_dependency 'rake', '~> 0.8'
19
+ gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
20
+
21
+ gem.add_dependency "cinch", "~> 2.0"
22
+ gem.add_dependency "octokit", "~> 4.0"
23
+ gem.add_dependency "actionpack", "~> 4.2"
24
+ gem.add_dependency "twitter-text", "~> 1.13"
25
+ gem.add_dependency "sentry-helper", "~> 0.1.0"
26
+ end
metadata ADDED
@@ -0,0 +1,163 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sentry-github
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Persson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubygems-tasks
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: cinch
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: octokit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: actionpack
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.2'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: twitter-text
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.13'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.13'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sentry-helper
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.1.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.1.0
125
+ description:
126
+ email: apersson.93@gmail.com
127
+ executables: []
128
+ extensions: []
129
+ extra_rdoc_files: []
130
+ files:
131
+ - ".gitignore"
132
+ - ChangeLog.rdoc
133
+ - Gemfile
134
+ - LICENSE.txt
135
+ - README.rdoc
136
+ - VERSION
137
+ - lib/cinch/plugins/sentry/github.rb
138
+ - sentry-github.gemspec
139
+ homepage: https://rubygems.org/gems/sentry-github
140
+ licenses:
141
+ - MIT
142
+ metadata: {}
143
+ post_install_message:
144
+ rdoc_options: []
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ requirements: []
158
+ rubyforge_project:
159
+ rubygems_version: 2.5.1
160
+ signing_key:
161
+ specification_version: 4
162
+ summary: Fetches information about posted GitHub links
163
+ test_files: []