git-game 1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/git-game +105 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 96f42dd0ad05a6a336ad92902ea9890d75a2ea58
|
4
|
+
data.tar.gz: ef730b842c7bf61d503d382fb4946b195b247b7d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8298f04c95a02487698618b9fbf6cb5b5d6b0969b30f58fe45a8f43753141e3f16c9fabedc0be5f6f27b5405ed9db0104880c9f4302a7b1185a010ab81b0dc02
|
7
|
+
data.tar.gz: 2a4b531d5cf7e99829605211d82c0256f2ee1fff47ebe65581bdb1a4e276de52a03baf4c463095a1f065e5b3cb1f8b1495e979006b9bacd306db2ff6b34368bf
|
data/bin/git-game
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# -- Exit gracefully --
|
4
|
+
Signal.trap("INT") {
|
5
|
+
print "bye "
|
6
|
+
exit 0
|
7
|
+
}
|
8
|
+
|
9
|
+
def print_header
|
10
|
+
puts "----------------------------------------------------------"
|
11
|
+
puts " THE GIT GAME "
|
12
|
+
puts "----------------------------------------------------------"
|
13
|
+
puts "Welcome! The goal of the git game is to guess committers"
|
14
|
+
puts "based on their commit messages.\n\n"
|
15
|
+
end
|
16
|
+
|
17
|
+
def print_help
|
18
|
+
puts "----------------------------------------------------------"
|
19
|
+
puts " USAGE "
|
20
|
+
puts "----------------------------------------------------------"
|
21
|
+
puts "git game [extra git log options]"
|
22
|
+
puts "EX: git game --after={2014-08-08}"
|
23
|
+
puts "(This script already uses --no-merges and --pretty."
|
24
|
+
puts "For more valid options see: http://gitref.org/inspect/)"
|
25
|
+
end
|
26
|
+
|
27
|
+
# -- Usage Text --
|
28
|
+
if ARGV.count > 0 && (input = ARGV.shift) == 'help'
|
29
|
+
print_header
|
30
|
+
print_help
|
31
|
+
exit 0
|
32
|
+
end
|
33
|
+
|
34
|
+
# -- Parse commits --
|
35
|
+
COMMIT_DELIMITER = "XXXCOMMITXXX"
|
36
|
+
FIELD_DELIMITER = "|||"
|
37
|
+
|
38
|
+
commit_format = ["%an", "%ar", "%B"].join(FIELD_DELIMITER)
|
39
|
+
|
40
|
+
raw_commits = `git log --no-merges --pretty="#{COMMIT_DELIMITER}#{commit_format}" #{input if input}`.split("#{COMMIT_DELIMITER}")
|
41
|
+
commits = []
|
42
|
+
raw_commits.each do |c|
|
43
|
+
next if c.strip.empty?
|
44
|
+
|
45
|
+
fields = c.split(FIELD_DELIMITER)
|
46
|
+
commits << {:author => fields[0], :date => fields[1], :message => fields[2]}
|
47
|
+
end
|
48
|
+
|
49
|
+
committers = commits.map { |c| c[:author] }.compact.uniq
|
50
|
+
|
51
|
+
# -- Show welcome message --
|
52
|
+
system('clear')
|
53
|
+
|
54
|
+
print_header
|
55
|
+
puts "You're playing in a repo with #{commits.size} commits and #{committers.size}"
|
56
|
+
puts "distinct committers.\n\n"
|
57
|
+
|
58
|
+
committers.each do |committer|
|
59
|
+
puts committer
|
60
|
+
end
|
61
|
+
|
62
|
+
puts "\n"
|
63
|
+
puts "When guessing, all you have to do is type part of the"
|
64
|
+
puts "committer's name. It's case-insensitive. So for instance"
|
65
|
+
puts "if the committer was James Somers, you could write 'james'"
|
66
|
+
puts "or 'jam' or even 'j' to get full credit.\n\n"
|
67
|
+
|
68
|
+
puts "Ready? PRESS ANY KEY TO START PLAYING (Ctrl-C to quit)"
|
69
|
+
|
70
|
+
gets
|
71
|
+
|
72
|
+
system('clear')
|
73
|
+
|
74
|
+
# -- Game loop --
|
75
|
+
streak = 0
|
76
|
+
|
77
|
+
loop do
|
78
|
+
commit = commits.shuffle.pop
|
79
|
+
message = commit[:message]
|
80
|
+
author = commit[:author]
|
81
|
+
|
82
|
+
next if message.nil? || message.empty? || author.nil? || author.empty?
|
83
|
+
|
84
|
+
puts "(#{commit[:date]})\n"
|
85
|
+
puts "#{message.strip}\n\n"
|
86
|
+
print "Who wrote it (current streak: #{streak})? "
|
87
|
+
|
88
|
+
guess = gets
|
89
|
+
|
90
|
+
while guess.strip.empty?
|
91
|
+
print "Who wrote it (current streak: #{streak})? "
|
92
|
+
guess = gets
|
93
|
+
end
|
94
|
+
|
95
|
+
if author.downcase.include?(guess.strip.downcase) && !guess.strip.empty?
|
96
|
+
streak += 1
|
97
|
+
puts "Got it!"
|
98
|
+
else
|
99
|
+
streak = 0
|
100
|
+
puts "Actually, it was #{author}."
|
101
|
+
end
|
102
|
+
|
103
|
+
sleep 1
|
104
|
+
system('clear')
|
105
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: git-game
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jsomers
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
executables:
|
44
|
+
- git-game
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- bin/git-game
|
49
|
+
homepage: https://github.com/jsomers/git-game
|
50
|
+
licenses:
|
51
|
+
- MIT
|
52
|
+
metadata: {}
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 2.0.0
|
70
|
+
signing_key:
|
71
|
+
specification_version: 4
|
72
|
+
summary: The git committer guessing game!
|
73
|
+
test_files: []
|
74
|
+
has_rdoc:
|