octospy 0.1.1 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 171af9f29260945a51e4857685b2a65b00db7b92
4
- data.tar.gz: d5dd7a84b89cc8c33ddfb04abe4d53961f44a803
3
+ metadata.gz: 63af8f58921aa9def3c63ad00920328b2607aaa5
4
+ data.tar.gz: 9224ac7f173e40eec05358677634329f17de2165
5
5
  SHA512:
6
- metadata.gz: e4a31851c6ad95d9a156d4f26251cd2ace5cae3b0c9802288c0ba8f61e4d5af83358aedb7365f2c027b6d55e4c4dfa89024204f7f6b4aae52ce13843a4caa246
7
- data.tar.gz: 95730ccabff662481843d9c2c5a307ae55e9a3943e4ce7032e68ec41ce9b8a5692cd8b25e10fda8cbf732e8f98aabeeaacb5bc7b8ca54cfe467444bd9c631523
6
+ metadata.gz: 6a0cb773971236457df2b51e3e930e5f30984228617593c16249e0904be7e1f78eea7fc391ecb7d5dc29bfde64867f56def3ddf39e3655688f43f96c875f61b7
7
+ data.tar.gz: 50269fe88cd999c5d606e7af844650eea65781ab2f27cdd3b771f45cc69d20ea755eb09c93cb46ddce55833ccc646e34366a82247958c51f8b096f738a9a86ed
@@ -1,17 +1,25 @@
1
- ## Required
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
@@ -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
@@ -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'] ? ENV['API_REQUEST_INTERVAL'].to_i : 3 #sec
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
@@ -25,6 +25,13 @@ module Octospy
25
25
  StringIrc.new(self)
26
26
  end
27
27
 
28
+ def to_boolean
29
+ case self
30
+ when 'true' then true
31
+ when 'false' then false
32
+ end
33
+ end
34
+
28
35
  def shorten_url
29
36
  Octospy::Url.shorten self
30
37
  end
@@ -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
 
@@ -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.payload.pages[0].html_url
9
- url = "#{url}/_compare/#{sha}%5E...#{sha}" if action == 'edited'
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",
@@ -1,3 +1,3 @@
1
1
  module Octospy
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -36,7 +36,7 @@ module Octospy
36
36
 
37
37
  def api_requestable?
38
38
  limit = Octokit.rate_limit
39
- if limit.remaining.zero?
39
+ if !limit.limit.zero? && limit.remaining.zero?
40
40
  notify "ヾ(;´Д`)ノ #{limit}"
41
41
  false
42
42
  else
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.1.1
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-06 00:00:00.000000000 Z
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