twigg-gerrit 0.0.1 → 0.0.2
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 +4 -4
- data/lib/twigg-gerrit/gerrit.rb +1 -0
- data/lib/twigg-gerrit/gerrit/tag.rb +38 -22
- data/lib/twigg-gerrit/gerrit/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf14f92aa02f165e411ca70ce8c8a77caa19588b
|
4
|
+
data.tar.gz: 727c1956048043d911964ecef08d480bfa905940
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 890728614db3b7c7fd8211104bd1c55c7ec1376e436e6ae677df13aab412b3a2afab4d022ab3a2e5247b885b39b062a421eefd4acdf524ab75b2c08a7d392c37
|
7
|
+
data.tar.gz: fe4215bbed06466daa0a0d6ff51df22318b6b21d5f4ae1894738c90f345a93d30403a3f1e2f9ae3202406b9e9107748510587a7f1f59264c8ee389bea7650a76
|
data/lib/twigg-gerrit/gerrit.rb
CHANGED
@@ -1,33 +1,41 @@
|
|
1
1
|
module Twigg
|
2
2
|
module Gerrit
|
3
|
-
#
|
3
|
+
# Stats for "@" tags.
|
4
4
|
class Tag
|
5
5
|
class << self
|
6
|
+
# Returns a hash of "@" tag stats for the last `days` days.
|
7
|
+
#
|
8
|
+
# Within the hash there are 3 key-value pairs:
|
9
|
+
#
|
10
|
+
# - :from: a hash of "from" authors; each author has its own hash of
|
11
|
+
# tags and counts
|
12
|
+
# - :to: a hash of "to" authors; again with a subhash for each author
|
13
|
+
# - :global: a hash of all tags and their counts
|
14
|
+
#
|
6
15
|
def stats(days: 7)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
tag: count
|
24
|
-
}
|
25
|
-
=end
|
16
|
+
{
|
17
|
+
from: Hash.new { |h, k| h[k] = Hash.new(0) },
|
18
|
+
to: Hash.new { |h, k| h[k] = Hash.new(0) },
|
19
|
+
global: Hash.new(0),
|
20
|
+
}.tap do |stats|
|
21
|
+
(change_messages(days) + comment_messages(days)).each do |result|
|
22
|
+
tags_from_result(result[:message]).each do |tag, count|
|
23
|
+
[
|
24
|
+
stats[:from][result[:from_full_name]],
|
25
|
+
stats[:to][result[:to_full_name]],
|
26
|
+
stats[:global],
|
27
|
+
].each do |hash|
|
28
|
+
hash[tag] += count
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
26
32
|
end
|
27
33
|
end
|
28
34
|
|
29
35
|
private
|
30
36
|
|
37
|
+
# Return all comment messages containing "@" tags within the last `days`
|
38
|
+
# days.
|
31
39
|
def comment_messages(days)
|
32
40
|
DB[<<-SQL, days].all
|
33
41
|
SELECT message,
|
@@ -45,6 +53,8 @@ module Twigg
|
|
45
53
|
SQL
|
46
54
|
end
|
47
55
|
|
56
|
+
# Return all change messages containing "@" tags within the last `days`
|
57
|
+
# days.
|
48
58
|
def change_messages(days)
|
49
59
|
DB[<<-SQL, days].all
|
50
60
|
SELECT message,
|
@@ -62,8 +72,14 @@ module Twigg
|
|
62
72
|
SQL
|
63
73
|
end
|
64
74
|
|
65
|
-
|
66
|
-
|
75
|
+
# Given a string, `text`, extract "@" tags.
|
76
|
+
#
|
77
|
+
# Returns a hash where the keys are tag names and the values are counts
|
78
|
+
# that indicate the number of times a tag appeared in `text`.
|
79
|
+
def tags_from_result(text)
|
80
|
+
tags = text.scan(/(?<=@)\w+/).map(&:downcase)
|
81
|
+
|
82
|
+
tags.each_with_object(Hash.new(0)) { |tag, memo| memo[tag] += 1 }
|
67
83
|
end
|
68
84
|
end
|
69
85
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twigg-gerrit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Causes Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.0.
|
61
|
+
version: 0.0.2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.0.
|
68
|
+
version: 0.0.2
|
69
69
|
description: Twigg provides stats for activity in Git repositories. This is the adapter
|
70
70
|
that enables Twigg to work with Gerrit installations.
|
71
71
|
email:
|