octospy 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.env.example +7 -4
- data/README.md +0 -1
- data/lib/octospy/configurable.rb +2 -0
- data/lib/octospy/parser/issue.rb +2 -2
- data/lib/octospy/parser/organization.rb +1 -1
- data/lib/octospy/parser/pull_request.rb +1 -1
- data/lib/octospy/parser/release.rb +14 -0
- data/lib/octospy/parser/repository.rb +6 -6
- data/lib/octospy/parser/user.rb +2 -2
- data/lib/octospy/parser.rb +4 -1
- data/lib/octospy/version.rb +1 -1
- data/lib/octospy/worker.rb +20 -9
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66a3c3615824ecfbdef2e8a16a9f3e635176583b
|
4
|
+
data.tar.gz: 98a7bc1a73bcc382107a29d8832bf71228ec3fca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e08504e4ee353010971d1ecae483b1cccf477ce6dea702d32442d9393eafef8cbbd5b5fe240f57e0b8e85bf227b2aeda1c69a9e82fa79c1807e12c44907fca19
|
7
|
+
data.tar.gz: 3c964b19e168d43521c57778aa86708ba6a4f88f0324d8bd1bde0285ac3a9a388259a21d1ed3a834e47b28c03649ae51da9a7d132905c4b859996c44acb5971e
|
data/.env.example
CHANGED
@@ -1,14 +1,17 @@
|
|
1
|
-
|
1
|
+
## Required
|
2
2
|
SERVER=irc.yourserver.net
|
3
3
|
CHANNELS=yourchannel
|
4
|
-
|
4
|
+
# OAuth access token
|
5
5
|
GITHUB_TOKEN=e17e1c6caa3e452433ab55****************
|
6
|
+
# Basic Authentication
|
7
|
+
# GITHUB_LOGIN=yourusername
|
8
|
+
# GITHUB_PASSWORD=************
|
6
9
|
|
7
|
-
|
10
|
+
## Options
|
8
11
|
# HOST=6668
|
9
12
|
# SSL=true
|
10
13
|
# PASSWORD=*****************
|
11
14
|
|
12
|
-
|
15
|
+
## GitHub Enterprise
|
13
16
|
# GITHUB_API_ENDPOINT=http://your.enterprise.domain/api/v3
|
14
17
|
# GITHUB_WEB_ENDPOINT=http://your.enterprise.domain
|
data/README.md
CHANGED
data/lib/octospy/configurable.rb
CHANGED
@@ -7,6 +7,7 @@ module Octospy
|
|
7
7
|
ssl
|
8
8
|
password
|
9
9
|
nick
|
10
|
+
worker_interval
|
10
11
|
cinch_config_block
|
11
12
|
github_api_endpoint
|
12
13
|
github_web_endpoint
|
@@ -44,6 +45,7 @@ module Octospy
|
|
44
45
|
@port = ENV['PORT']
|
45
46
|
@ssl = !!ENV['SSL']
|
46
47
|
@password = ENV['PASSWORD']
|
48
|
+
@worker_interval = ENV['WORKER_INTERVAL'] || 30 #sec
|
47
49
|
@github_login = ENV['GITHUB_LOGIN']
|
48
50
|
@github_token = ENV['GITHUB_TOKEN']
|
49
51
|
@channels = ENV['CHANNELS'] ?
|
data/lib/octospy/parser/issue.rb
CHANGED
@@ -18,7 +18,7 @@ module Octospy
|
|
18
18
|
status: "#{@event.payload.action} issue ##{@event.payload.issue.number}",
|
19
19
|
title: @event.payload.issue.title,
|
20
20
|
body: body,
|
21
|
-
link: @event.payload.issue.
|
21
|
+
link: "#{Octokit.web_endpoint}#{@event.repo.name}/issues/#{@event.payload.issue.number}"
|
22
22
|
}
|
23
23
|
end
|
24
24
|
|
@@ -35,7 +35,7 @@ module Octospy
|
|
35
35
|
status: status,
|
36
36
|
title: title,
|
37
37
|
body: "#{@event.payload.comment.body}".split_lfbl,
|
38
|
-
link: @event.payload.comment.
|
38
|
+
link: "#{Octokit.web_endpoint}#{@event.repo.name}/issues/#{@event.payload.issue.number}#issuecomment-#{@event.payload.comment.id}"
|
39
39
|
}
|
40
40
|
end
|
41
41
|
end
|
@@ -6,7 +6,7 @@ module Octospy
|
|
6
6
|
status: "#{@event.payload.action} pull request ##{@event.payload.number}",
|
7
7
|
title: @event.payload.pull_request.title,
|
8
8
|
body: "#{@event.payload.pull_request.body}".split_lfbl,
|
9
|
-
link: @event.payload.pull_request.
|
9
|
+
link: @event.payload.pull_request._links.html.attrs[:href]
|
10
10
|
}
|
11
11
|
end
|
12
12
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Octospy
|
2
|
+
class Parser
|
3
|
+
module Release
|
4
|
+
def parse_release_event
|
5
|
+
{
|
6
|
+
status: "#{@event.payload.release.draft ? 'published' : 'saved draft'} release",
|
7
|
+
title: "#{@event.payload.release.name}",
|
8
|
+
body: "#{@event.payload.release.body}".split_lfbl,
|
9
|
+
link: "#{Octokit.web_endpoint}#{@event.repo.name}/releases/#{@event.payload.release.tag_name}"
|
10
|
+
}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -15,7 +15,7 @@ module Octospy
|
|
15
15
|
@event.payload.commits.each do |commit|
|
16
16
|
verbose_commit = Octokit.commit(@event.repo.name, commit.sha)
|
17
17
|
name = "#{verbose_commit.author ? verbose_commit.author.login : commit.author.name}"
|
18
|
-
link = "#{Octokit.web_endpoint}
|
18
|
+
link = "#{Octokit.web_endpoint}#{@event.repo.name}/commit/#{commit.sha}"
|
19
19
|
line = "#{name.colorize_for_irc.silver}: #{commit.message}"
|
20
20
|
line << " - #{link.shorten.colorize_for_irc.blue}"
|
21
21
|
body = body + "#{line}".split_lfbl
|
@@ -24,7 +24,7 @@ module Octospy
|
|
24
24
|
{
|
25
25
|
status: "pushed to #{@event.payload.ref.gsub('refs/heads/', '')}",
|
26
26
|
body: body,
|
27
|
-
link: "#{Octokit.web_endpoint}
|
27
|
+
link: "#{Octokit.web_endpoint}#{@event.repo.name}",
|
28
28
|
notice_body: true
|
29
29
|
}
|
30
30
|
end
|
@@ -36,14 +36,14 @@ module Octospy
|
|
36
36
|
{
|
37
37
|
status: "created repository",
|
38
38
|
title: title,
|
39
|
-
link: "#{Octokit.web_endpoint}
|
39
|
+
link: "#{Octokit.web_endpoint}#{@event.repo.name}",
|
40
40
|
repository: nil
|
41
41
|
}
|
42
42
|
else
|
43
43
|
{
|
44
44
|
status: "created #{@event.payload.ref_type}:#{@event.payload.ref}",
|
45
45
|
title: @event.payload.description,
|
46
|
-
link: "#{Octokit.web_endpoint}
|
46
|
+
link: "#{Octokit.web_endpoint}#{@event.repo.name}"
|
47
47
|
}
|
48
48
|
end
|
49
49
|
end
|
@@ -51,7 +51,7 @@ module Octospy
|
|
51
51
|
def parse_delete_event
|
52
52
|
{
|
53
53
|
status: "deleted #{@event.payload.ref_type}:#{@event.payload.ref}",
|
54
|
-
link: "#{Octokit.web_endpoint}
|
54
|
+
link: "#{Octokit.web_endpoint}#{@event.repo.name}"
|
55
55
|
}
|
56
56
|
end
|
57
57
|
|
@@ -68,7 +68,7 @@ module Octospy
|
|
68
68
|
def parse_public_event
|
69
69
|
{
|
70
70
|
status: "published #{@event.repo.name}",
|
71
|
-
link: "#{Octokit.web_endpoint}
|
71
|
+
link: "#{Octokit.web_endpoint}#{@event.repo.name}"
|
72
72
|
}
|
73
73
|
end
|
74
74
|
|
data/lib/octospy/parser/user.rb
CHANGED
@@ -5,7 +5,7 @@ module Octospy
|
|
5
5
|
{
|
6
6
|
status: "#{@event.payload.action} repository",
|
7
7
|
title: @event.repo.name,
|
8
|
-
link: "#{Octokit.web_endpoint}
|
8
|
+
link: "#{Octokit.web_endpoint}#{@event.repo.name}",
|
9
9
|
repository: nil
|
10
10
|
}
|
11
11
|
end
|
@@ -27,7 +27,7 @@ module Octospy
|
|
27
27
|
status: "followed",
|
28
28
|
title: title,
|
29
29
|
body: profile.join(', '),
|
30
|
-
link: "#{Octokit.web_endpoint}
|
30
|
+
link: "#{Octokit.web_endpoint}#{user.login}",
|
31
31
|
repository: nil,
|
32
32
|
notice: true
|
33
33
|
}
|
data/lib/octospy/parser.rb
CHANGED
@@ -7,6 +7,7 @@ require 'octospy/parser/pull_request'
|
|
7
7
|
require 'octospy/parser/wiki'
|
8
8
|
require 'octospy/parser/download'
|
9
9
|
require 'octospy/parser/gist'
|
10
|
+
require 'octospy/parser/release'
|
10
11
|
|
11
12
|
module Octospy
|
12
13
|
class Parser
|
@@ -18,6 +19,7 @@ module Octospy
|
|
18
19
|
include Wiki
|
19
20
|
include Download
|
20
21
|
include Gist
|
22
|
+
include Release
|
21
23
|
|
22
24
|
def initialize(event)
|
23
25
|
@event = event
|
@@ -99,7 +101,8 @@ module Octospy
|
|
99
101
|
edited: :green,
|
100
102
|
published: :blue,
|
101
103
|
started: :rainbow,
|
102
|
-
followed: :seven_eleven
|
104
|
+
followed: :seven_eleven,
|
105
|
+
saved: :cyan
|
103
106
|
}
|
104
107
|
end
|
105
108
|
|
data/lib/octospy/version.rb
CHANGED
data/lib/octospy/worker.rb
CHANGED
@@ -14,10 +14,10 @@ module Octospy
|
|
14
14
|
loop do
|
15
15
|
begin
|
16
16
|
watch_repositories
|
17
|
-
sleep
|
17
|
+
sleep Octospy.worker_interval
|
18
18
|
rescue => e
|
19
|
-
|
20
|
-
sleep
|
19
|
+
@block.call e.message
|
20
|
+
sleep Octospy.worker_interval
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -25,22 +25,33 @@ module Octospy
|
|
25
25
|
|
26
26
|
def events
|
27
27
|
@repositories.each_with_object([]) do |repo, arr|
|
28
|
+
if Octokit.rate_limit.remaining.zero?
|
29
|
+
@block.call "ヾ(;´Д`)ノ #{::Octokit.rate_limit}"
|
30
|
+
break
|
31
|
+
end
|
32
|
+
|
28
33
|
arr.concat ::Octokit.repository_events(repo)
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
37
|
+
def while_ago
|
38
|
+
Time.now.utc - (60 * 30)
|
39
|
+
end
|
40
|
+
|
32
41
|
def watch_repositories
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
next
|
42
|
+
# ascending by event.id
|
43
|
+
events.sort_by(&:id).each { |event|
|
44
|
+
case
|
45
|
+
when @last_event_id.nil? && while_ago >= event.created_at
|
46
|
+
next
|
47
|
+
when !@last_event_id.nil? && @last_event_id >= event.id.to_i
|
48
|
+
next
|
38
49
|
end
|
39
50
|
|
40
51
|
parsed_event = Octospy.parse(event)
|
41
52
|
next unless parsed_event
|
42
53
|
|
43
|
-
@last_event_id = event.id
|
54
|
+
@last_event_id = event.id.to_i
|
44
55
|
parsed_event.each { |p| @block.call p[:message] }
|
45
56
|
}
|
46
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octospy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- linyows
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -265,6 +265,7 @@ files:
|
|
265
265
|
- lib/octospy/parser/issue.rb
|
266
266
|
- lib/octospy/parser/organization.rb
|
267
267
|
- lib/octospy/parser/pull_request.rb
|
268
|
+
- lib/octospy/parser/release.rb
|
268
269
|
- lib/octospy/parser/repository.rb
|
269
270
|
- lib/octospy/parser/user.rb
|
270
271
|
- lib/octospy/parser/wiki.rb
|