watchgod 0.0.1
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 +7 -0
- data/bin/watchgod +75 -0
- metadata +58 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c78d7ab5ebc52d34a2bbaa942fa719acc5653b03
|
4
|
+
data.tar.gz: 1168ed6b4721c06d76041526ef6ce27815cc0365
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6827ea2820ab151b61d1a002ef2fced2428c80ee48ed345a3b4b91d82b4935666159f633f0aeeea9906434122f7da4200c308cd036d188f2f66294be7a3ae50a
|
7
|
+
data.tar.gz: 2d16dce8fb6487a47d72701c3f7ed134b1437c8f327c963e188ce847ef4c651ae3dc80f4ef3b0bd5c63b4d3c56071a92729665978be601483174e1df9b47da0d
|
data/bin/watchgod
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'pushover'
|
2
|
+
require 'json'
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
# watchgod APP_TOKEN USER_TOKEN AUTH_STRING
|
6
|
+
AppToken = ARGV[0]
|
7
|
+
UserToken = ARGV[1]
|
8
|
+
AuthString = ARGV[2]
|
9
|
+
|
10
|
+
def fetch_events
|
11
|
+
uri = URI("https://api.github.com/users/jwvg0425/events/public")
|
12
|
+
req = Net::HTTP::Get.new(uri)
|
13
|
+
req['Authorization'] = "Basic #{AuthString}"
|
14
|
+
http = Net::HTTP.new(uri.hostname, uri.port)
|
15
|
+
http.use_ssl = true
|
16
|
+
http.ca_file = (__dir__ + '/cacert.pem')
|
17
|
+
res = http.request(req)
|
18
|
+
|
19
|
+
events = JSON.load(res.body)
|
20
|
+
|
21
|
+
return events
|
22
|
+
end
|
23
|
+
def send_noti title, msg, url
|
24
|
+
Pushover.notification(message: msg, title: title, url: url)
|
25
|
+
end
|
26
|
+
|
27
|
+
last_id = fetch_events.first["id"]
|
28
|
+
|
29
|
+
Pushover.configure do |config|
|
30
|
+
config.user = UserToken
|
31
|
+
config.token = AppToken
|
32
|
+
end
|
33
|
+
|
34
|
+
loop do
|
35
|
+
puts "FETCH #{last_id}"
|
36
|
+
|
37
|
+
events = fetch_events
|
38
|
+
events.each do |event|
|
39
|
+
break if event["id"] == last_id
|
40
|
+
|
41
|
+
case event["type"]
|
42
|
+
when "PushEvent"
|
43
|
+
name = event["repo"]["name"]
|
44
|
+
body = event["payload"]["commits"][0]["message"]
|
45
|
+
url = event["payload"]["commits"][0]["url"]
|
46
|
+
|
47
|
+
send_noti "God just pushed commits - #{name}", body, url
|
48
|
+
when "CommitCommentEvent"
|
49
|
+
name = event["repo"]["name"]
|
50
|
+
body = event["payload"]["comment"]["body"]
|
51
|
+
url = event["payload"]["comment"]["url"]
|
52
|
+
|
53
|
+
send_noti "God just commented on commit", body, url
|
54
|
+
when "CreateEvent"
|
55
|
+
name = event["repo"]["name"]
|
56
|
+
url = event["repo"]["url"]
|
57
|
+
|
58
|
+
send_noti "God just created repo - #{name}", name, url
|
59
|
+
when "IssuesEvent"
|
60
|
+
action = event["payload"]["action"]
|
61
|
+
body = event["payload"]["issue"]["title"]
|
62
|
+
url = event["payload"]["issue"]["url"]
|
63
|
+
|
64
|
+
send_noti "God just #{action} issue", body, url
|
65
|
+
when "IssueCommentEvent"
|
66
|
+
body = event["payload"]["comment"]["body"]
|
67
|
+
url = event["payload"]["comment"]["url"]
|
68
|
+
|
69
|
+
send_noti "God just commented on issue", body, url
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
last_id = events.first["id"]
|
74
|
+
sleep 10
|
75
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: watchgod
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- pjc0247
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pushover
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: DATADATA
|
28
|
+
email: pjc0247@naver.com
|
29
|
+
executables:
|
30
|
+
- watchgod
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- bin/watchgod
|
35
|
+
homepage:
|
36
|
+
licenses: []
|
37
|
+
metadata: {}
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 2.5.1
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: DATDATDAT
|
58
|
+
test_files: []
|