githabit 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/githabit/app.rb +30 -1
- data/lib/githabit/setup.rb +56 -0
- data/lib/githabit/version.rb +1 -1
- 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: ec5025355e2a00a0c2c75168902f0de0f8580173
|
4
|
+
data.tar.gz: 5641e3f3c640981c05e96bda1e76715be3a9dc17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 915ca23e75b8716bd90afc1f60a7094d4256a33c16acc3fa2da6520122b3c3d901297232e360536703f7f8cff3118cc37bf9f5936c016be679762b135c8aa3a3
|
7
|
+
data.tar.gz: e92864d017fcf2f21ccf8eff7e34a2e3b09907e1f3de585c87fd2957f4980691ae86b38bf9d8ba097a913d20bfc35c919926b85de2ee97c9ddc806af79cd400f
|
data/lib/githabit/app.rb
CHANGED
@@ -25,15 +25,44 @@ module Githabit
|
|
25
25
|
def setup()
|
26
26
|
@log.info("Running setup - Caching all current events, no rewards will be generated for them")
|
27
27
|
|
28
|
+
# Create tasks
|
29
|
+
print "Do you want to attempt to create the Githabit tasks automatically? [Y/n] "
|
30
|
+
response = $stdin.gets.chomp!
|
31
|
+
|
32
|
+
if (response != "n")
|
33
|
+
task = {
|
34
|
+
"up" => true,
|
35
|
+
"down" => false,
|
36
|
+
"type" => "habit",
|
37
|
+
"priority" => 1
|
38
|
+
}
|
39
|
+
|
40
|
+
task['text'] = "Make a Github commit"
|
41
|
+
|
42
|
+
@habit_api.create_task(task)
|
43
|
+
|
44
|
+
task['text'] = "Close Github issue"
|
45
|
+
|
46
|
+
@habit_api.create_task(task)
|
47
|
+
|
48
|
+
@log.info("Tasks created");
|
49
|
+
end
|
50
|
+
|
28
51
|
# Initialize cache
|
29
52
|
@log.info("Checking github for new events")
|
30
53
|
events = @github_api.get_user_events(@settings['github']['monitor_user'])
|
31
54
|
|
32
55
|
events.select { |e| e['type'] == 'PushEvent'}.each do |event|
|
33
|
-
@log.debug("Caching event - #{event['id']}")
|
56
|
+
@log.debug("Caching push event - #{event['id']}")
|
34
57
|
@cache.cache(event)
|
35
58
|
end
|
36
59
|
|
60
|
+
events.select { |e| e['type'] == 'IssuesEvent'}.each do |event|
|
61
|
+
next if event['payload']['action'] != 'closed'
|
62
|
+
@log.debug("Caching issue close event - #{event['id']}")
|
63
|
+
@cache.cache(event)
|
64
|
+
end
|
65
|
+
|
37
66
|
@log.info("Setup completed, starting main loop")
|
38
67
|
end
|
39
68
|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'pp'
|
2
|
+
|
3
|
+
class Setup
|
4
|
+
|
5
|
+
def initialize()
|
6
|
+
end
|
7
|
+
|
8
|
+
def run()
|
9
|
+
config = {}
|
10
|
+
# Initialize cache
|
11
|
+
|
12
|
+
|
13
|
+
print "Setup config file? [Y/n] "
|
14
|
+
exit if gets.strip == "n"
|
15
|
+
|
16
|
+
# Config setup
|
17
|
+
config['github'] = {}
|
18
|
+
config['habitrpg'] = {}
|
19
|
+
|
20
|
+
print "Github Username: "
|
21
|
+
config['github']['user'] = gets.strip
|
22
|
+
|
23
|
+
print "Github password: "
|
24
|
+
config['github']['password'] = gets.strip
|
25
|
+
|
26
|
+
print "Users history to monitor: "
|
27
|
+
config['github']['monitor_user'] = gets.strip
|
28
|
+
|
29
|
+
puts "Auto watch causes the application to stay running indefinately constantly polling the github stream of the user for changes. This is good if you want to run this kind of as a standalone application instead of manually or scheduled through cron."
|
30
|
+
|
31
|
+
print "Enable autowatch? [y/N]: "
|
32
|
+
if (gets.strip == "y")
|
33
|
+
config['github']['autowatch'] = true
|
34
|
+
|
35
|
+
print "How often in minutes to check for changes? "
|
36
|
+
config['github']['frequency'] = gets.strip
|
37
|
+
else
|
38
|
+
config['github']['autowatch'] = false
|
39
|
+
config['github']['frequency'] = 5
|
40
|
+
end
|
41
|
+
|
42
|
+
print "HabitRPG API User: "
|
43
|
+
config['habitrpg']['user'] = gets.strip
|
44
|
+
|
45
|
+
print "HabitRPG API Token: "
|
46
|
+
config['habitrpg']['token'] = gets.strip
|
47
|
+
|
48
|
+
pp config
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
x = Setup.new
|
56
|
+
x.run
|
data/lib/githabit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: githabit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Morgan Kesler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/githabit/app.rb
|
108
108
|
- lib/githabit/cache.rb
|
109
109
|
- lib/githabit/github_api.rb
|
110
|
+
- lib/githabit/setup.rb
|
110
111
|
- lib/githabit/version.rb
|
111
112
|
homepage: https://github.com/keslerm/githabit
|
112
113
|
licenses:
|