octospy 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.example +16 -8
- data/lib/octospy.rb +11 -0
- data/lib/octospy/configurable.rb +20 -2
- data/lib/octospy/extensions/string.rb +7 -0
- data/lib/octospy/parser.rb +3 -3
- data/lib/octospy/parser/repository.rb +2 -2
- data/lib/octospy/parser/wiki.rb +2 -2
- data/lib/octospy/version.rb +1 -1
- data/lib/octospy/worker.rb +1 -1
- data/log/.gitkeep +0 -0
- 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: 63af8f58921aa9def3c63ad00920328b2607aaa5
|
4
|
+
data.tar.gz: 9224ac7f173e40eec05358677634329f17de2165
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a0cb773971236457df2b51e3e930e5f30984228617593c16249e0904be7e1f78eea7fc391ecb7d5dc29bfde64867f56def3ddf39e3655688f43f96c875f61b7
|
7
|
+
data.tar.gz: 50269fe88cd999c5d606e7af844650eea65781ab2f27cdd3b771f45cc69d20ea755eb09c93cb46ddce55833ccc646e34366a82247958c51f8b096f738a9a86ed
|
data/.env.example
CHANGED
@@ -1,17 +1,25 @@
|
|
1
|
-
##
|
1
|
+
## IRC
|
2
2
|
SERVER=irc.yourserver.net
|
3
3
|
CHANNELS=yourchannel
|
4
|
-
# OAuth access token
|
5
|
-
GITHUB_TOKEN=e17e1c6caa3e452433ab55****************
|
6
|
-
# Basic Authentication
|
7
|
-
# GITHUB_LOGIN=yourusername
|
8
|
-
# GITHUB_PASSWORD=************
|
9
|
-
|
10
|
-
## Options
|
11
4
|
# HOST=6668
|
12
5
|
# SSL=true
|
13
6
|
# PASSWORD=*****************
|
14
7
|
|
8
|
+
## GitHub Authentication
|
9
|
+
GITHUB_TOKEN=e17e1c6caa3e452433ab55****************
|
10
|
+
# GITHUB_LOGIN=yourusername
|
11
|
+
# GITHUB_PASSWORD=************
|
12
|
+
|
15
13
|
## GitHub Enterprise
|
16
14
|
# GITHUB_API_ENDPOINT=http://your.enterprise.domain/api/v3
|
17
15
|
# GITHUB_WEB_ENDPOINT=http://your.enterprise.domain
|
16
|
+
|
17
|
+
## Intervals
|
18
|
+
# API_REQUEST_INTERVAL=0
|
19
|
+
# WORKER_INTERVAL=15
|
20
|
+
|
21
|
+
## DAEMONIZE
|
22
|
+
# DAEMONIZE=true
|
23
|
+
# PID_FILE=/tmp/octospy.pid
|
24
|
+
# LOG_FILE=/tmp/octospy.log
|
25
|
+
# SYNC_LOG=false
|
data/lib/octospy.rb
CHANGED
@@ -46,7 +46,18 @@ module Octospy
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
def daemonize
|
50
|
+
Process.daemon(nochdir: nil, noclose: true)
|
51
|
+
File.open(Octospy.pid_file, 'w') { |f| f << Process.pid }
|
52
|
+
log = File.new(Octospy.log_file, 'a')
|
53
|
+
log.sync = Octospy.sync_log
|
54
|
+
STDIN.reopen '/dev/null'
|
55
|
+
STDOUT.reopen log
|
56
|
+
STDERR.reopen STDOUT
|
57
|
+
end
|
58
|
+
|
49
59
|
def run
|
60
|
+
self.daemonize if Octospy.daemonize
|
50
61
|
self.irc_bot.start
|
51
62
|
end
|
52
63
|
end
|
data/lib/octospy/configurable.rb
CHANGED
@@ -8,6 +8,10 @@ module Octospy
|
|
8
8
|
password
|
9
9
|
nick
|
10
10
|
debug
|
11
|
+
daemonize
|
12
|
+
sync_log
|
13
|
+
pid_file
|
14
|
+
log_file
|
11
15
|
worker_interval
|
12
16
|
api_request_interval
|
13
17
|
cinch_config_block
|
@@ -47,16 +51,30 @@ module Octospy
|
|
47
51
|
@port = ENV['PORT']
|
48
52
|
@ssl = !!ENV['SSL']
|
49
53
|
@debug = !!ENV['DEBUG']
|
54
|
+
@daemonize = !!ENV['DAEMONIZE']
|
55
|
+
@sync_log = "#{ENV['SYNC_LOG'] || true}".to_boolean
|
56
|
+
@pid_file = ENV['PID_FILE'] || default_pid_file
|
57
|
+
@log_file = ENV['LOG_FILE'] || default_log_file
|
50
58
|
@password = ENV['PASSWORD']
|
51
|
-
@worker_interval = ENV['WORKER_INTERVAL'] ? ENV['WORKER_INTERVAL'].to_i : 30 #sec
|
52
59
|
# you can make up to 20 requests per minute.
|
53
60
|
# http://developer.github.com/v3/search/#rate-limit
|
54
|
-
@api_request_interval = ENV['API_REQUEST_INTERVAL']
|
61
|
+
@api_request_interval = "#{ENV['API_REQUEST_INTERVAL'] || 3}".to_i
|
62
|
+
@worker_interval = "#{ENV['WORKER_INTERVAL'] || 30}".to_i
|
55
63
|
@github_login = ENV['GITHUB_LOGIN']
|
56
64
|
@github_token = ENV['GITHUB_TOKEN']
|
57
65
|
@channels = ENV['CHANNELS'] ? ENV['CHANNELS'].gsub(/\s|#/, '').split(',').
|
58
66
|
map { |ch| "##{ch}" } : nil
|
59
67
|
@cinch_config_block = nil
|
60
68
|
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def default_pid_file
|
73
|
+
File.join(File.expand_path('../../../tmp/pids', __FILE__), "#{@nick}")
|
74
|
+
end
|
75
|
+
|
76
|
+
def default_log_file
|
77
|
+
File.join(File.expand_path('../../../log', __FILE__), "#{@nick}.log")
|
78
|
+
end
|
61
79
|
end
|
62
80
|
end
|
data/lib/octospy/parser.rb
CHANGED
@@ -47,7 +47,7 @@ module Octospy
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def build(hash)
|
50
|
-
header = "#{hash[:nick].colorize_for_irc.bold} #{colorize_to hash[:status]}"
|
50
|
+
header = "#{hash[:nick].to_s.colorize_for_irc.bold} #{colorize_to hash[:status]}"
|
51
51
|
|
52
52
|
if hash[:repository] && !hash[:repository].empty?
|
53
53
|
header = "(#{hash[:repository]}) #{header}"
|
@@ -58,7 +58,7 @@ module Octospy
|
|
58
58
|
end
|
59
59
|
|
60
60
|
if hash[:link] && !hash[:link].empty?
|
61
|
-
header = "#{header} - #{hash[:link].shorten.colorize_for_irc.blue}"
|
61
|
+
header = "#{header} - #{hash[:link].shorten.to_s.colorize_for_irc.blue}"
|
62
62
|
end
|
63
63
|
|
64
64
|
body = if hash[:body].length > 20
|
@@ -113,7 +113,7 @@ module Octospy
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def colorize_to(string)
|
116
|
-
string.colorize_for_irc.send(behavior_color string).to_s
|
116
|
+
string.to_s.colorize_for_irc.send(behavior_color string).to_s
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
@@ -20,8 +20,8 @@ module Octospy
|
|
20
20
|
verbose_commit = Octokit.commit(@event.repo.name, commit.sha)
|
21
21
|
name = "#{verbose_commit.author ? verbose_commit.author.login : commit.author.name}"
|
22
22
|
link = "#{Octokit.web_endpoint}#{@event.repo.name}/commit/#{commit.sha}"
|
23
|
-
line = "#{name.colorize_for_irc.silver}: #{commit.message}"
|
24
|
-
line << " - #{link.shorten.colorize_for_irc.blue}"
|
23
|
+
line = "#{name.to_s.colorize_for_irc.silver}: #{commit.message}"
|
24
|
+
line << " - #{link.shorten.to_s.colorize_for_irc.blue}"
|
25
25
|
body = body + "#{line}".split_lfbl
|
26
26
|
end
|
27
27
|
|
data/lib/octospy/parser/wiki.rb
CHANGED
@@ -5,8 +5,8 @@ module Octospy
|
|
5
5
|
action = @event.payload.pages[0].action
|
6
6
|
title = @event.payload.pages[0].title
|
7
7
|
sha = @event.payload.pages[0].sha[0,6]
|
8
|
-
url = @event.
|
9
|
-
url
|
8
|
+
url = "#{Octokit.web_endpoint}#{@event.repo.name}/wiki"
|
9
|
+
url += "/#{title}/_compare/#{sha}" if action == 'edited'
|
10
10
|
|
11
11
|
{
|
12
12
|
status: "#{action} the #{@event.repo.name} wiki",
|
data/lib/octospy/version.rb
CHANGED
data/lib/octospy/worker.rb
CHANGED
data/log/.gitkeep
ADDED
File without changes
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- linyows
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- lib/octospy/url.rb
|
149
149
|
- lib/octospy/version.rb
|
150
150
|
- lib/octospy/worker.rb
|
151
|
+
- log/.gitkeep
|
151
152
|
- octospy.gemspec
|
152
153
|
- spec/fixtures/commit_comment_event.json
|
153
154
|
- spec/fixtures/create_event.json
|