spreadtheword 1.0.0 → 1.1.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 +4 -4
- data/lib/spreadtheword.rb +17 -3
- data/lib/spreadtheword/latex.rb +43 -17
- data/lib/spreadtheword/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c84c6682b953b9bf945cac9fb09fbf03812b01fa172d4afdbeb3de3119a8802
|
4
|
+
data.tar.gz: a15f5544db92ab6963e67c2036b4c4d3ee12a1f77e242e837bb446b195a23a92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e735dc363ec52272fc3b6268903efb6cb406b09d30f7c9eafaa8c8528828877bab2a5a592009747d273804f6a5de027c5f21ae7c206a462f357deb0d5adb5cea
|
7
|
+
data.tar.gz: 9d2f1abc60d3f7ae0feb2f08b1705f3a6acac897ad1d82d6e012b1b8fda6faaa906e8edd45d0517e5720cc826d10f8dbcf8500b219e213e7d13bf2d3ecddb1a3
|
data/lib/spreadtheword.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'cgi'
|
1
2
|
require 'uri'
|
2
3
|
require 'ostruct'
|
3
4
|
require 'active_support/all'
|
@@ -52,7 +53,7 @@ class Spreadtheword
|
|
52
53
|
@getTranslation = lambda { |sentence|
|
53
54
|
unless translateCache[sentence]
|
54
55
|
@utils.say "Translating\n-> #{sentence}\n"
|
55
|
-
translateCache[sentence] = @translate.translate(sentence, to: "en").text
|
56
|
+
translateCache[sentence] = CGI.unescapeHTML(@translate.translate(sentence, to: "en").text)
|
56
57
|
@utils.say "<- #{translateCache[sentence]}\n"
|
57
58
|
end
|
58
59
|
translateCache[sentence]
|
@@ -86,7 +87,8 @@ class Spreadtheword
|
|
86
87
|
def run!
|
87
88
|
fetchAllLogs
|
88
89
|
parseTopics
|
89
|
-
|
90
|
+
sortTopics
|
91
|
+
writer = Spreadtheword::LaTeX.new(@title, @author, @topics, @getTranslation, @gitlab)
|
90
92
|
writer.write!
|
91
93
|
end
|
92
94
|
|
@@ -116,7 +118,7 @@ class Spreadtheword
|
|
116
118
|
end
|
117
119
|
|
118
120
|
def fetchLogs
|
119
|
-
cmd = %Q{git log --pretty=format:"%
|
121
|
+
cmd = %Q{git log --pretty=format:"%an#{CONNECTOR}%s#{CONNECTOR}%H"}
|
120
122
|
if @since
|
121
123
|
cmd = %Q{#{cmd} #{@since}..master}
|
122
124
|
end
|
@@ -132,6 +134,7 @@ class Spreadtheword
|
|
132
134
|
OpenStruct.new.tap do |y|
|
133
135
|
y.author = contents[0]
|
134
136
|
y.origMsg = contents[1]
|
137
|
+
y.shaHash = contents[2]
|
135
138
|
if @translate && y.origMsg =~ NONASCII
|
136
139
|
y.msg = @getTranslation.call(contents[1])
|
137
140
|
else
|
@@ -197,6 +200,17 @@ class Spreadtheword
|
|
197
200
|
end
|
198
201
|
end
|
199
202
|
|
203
|
+
def sortTopics
|
204
|
+
topicsH = @topics
|
205
|
+
@topics = []
|
206
|
+
topicsH.each do |k,v|
|
207
|
+
@topics << [k,v]
|
208
|
+
end
|
209
|
+
@topics.sort! do |x,y|
|
210
|
+
y[1].size <=> x[1].size
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
200
214
|
def gitUserName
|
201
215
|
`git config --get user.name`.to_s.strip
|
202
216
|
end
|
data/lib/spreadtheword/latex.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'nokogiri'
|
2
2
|
|
3
3
|
class Spreadtheword::LaTeX
|
4
|
-
def initialize title, author, topics, getTranslation
|
4
|
+
def initialize title, author, topics, getTranslation, gitlab
|
5
5
|
@title = title
|
6
6
|
@author = author
|
7
7
|
@topics = topics
|
8
8
|
@getTranslation = getTranslation
|
9
|
+
@gitlab = gitlab
|
9
10
|
end
|
10
11
|
|
11
12
|
def write!
|
@@ -47,7 +48,9 @@ class Spreadtheword::LaTeX
|
|
47
48
|
|
48
49
|
def sections
|
49
50
|
ret = ''
|
50
|
-
@topics.each do |
|
51
|
+
@topics.each do |topic|
|
52
|
+
k=topic[0]
|
53
|
+
v=topic[1]
|
51
54
|
next if k.nil?
|
52
55
|
first = v[0]
|
53
56
|
title = k
|
@@ -63,7 +66,7 @@ class Spreadtheword::LaTeX
|
|
63
66
|
url = first[:payload][:spreadthewordPermalink]
|
64
67
|
end
|
65
68
|
ret += %Q_
|
66
|
-
\\section{#{escape title}}
|
69
|
+
\\section{#{escape title.titleize}}
|
67
70
|
|
68
71
|
\\subsection{Background}
|
69
72
|
|
@@ -71,6 +74,8 @@ class Spreadtheword::LaTeX
|
|
71
74
|
_
|
72
75
|
|
73
76
|
if description.present?
|
77
|
+
description.strip!
|
78
|
+
description[0] = description[0].upcase
|
74
79
|
ret += %Q_
|
75
80
|
\\subsection{Description}
|
76
81
|
|
@@ -84,11 +89,12 @@ _
|
|
84
89
|
\\newpage
|
85
90
|
_
|
86
91
|
end
|
87
|
-
|
92
|
+
topicNil = @topics.find{|x| x[0].nil?}
|
93
|
+
if topicNil
|
88
94
|
ret += %Q_
|
89
95
|
\\section{Others}
|
90
96
|
_
|
91
|
-
ret += printDevelopers(
|
97
|
+
ret += printDevelopers(topicNil[1])
|
92
98
|
end
|
93
99
|
ret
|
94
100
|
end
|
@@ -104,26 +110,46 @@ _
|
|
104
110
|
|
105
111
|
\\begin{enumerate}
|
106
112
|
_
|
107
|
-
developers.
|
108
|
-
|
109
|
-
|
110
|
-
|
113
|
+
devArr = developers.map do |k,v|
|
114
|
+
[
|
115
|
+
v.size, %Q_
|
116
|
+
\\item #{escape k.titleize} ($#{format('%.2f', v.size*100.0 / values.size)}\\%$)
|
117
|
+
_, k, v
|
118
|
+
]
|
119
|
+
end
|
120
|
+
devArr.sort! do |x,y|
|
121
|
+
y[0] <=> x[0]
|
122
|
+
end
|
123
|
+
devArr.each do |x|
|
124
|
+
ret += x[1]
|
111
125
|
end
|
112
126
|
ret += %Q_
|
113
127
|
\\end{enumerate}
|
114
128
|
_
|
115
|
-
|
129
|
+
devArr.each do |dev|
|
130
|
+
k = dev[2]
|
131
|
+
v = dev[3]
|
116
132
|
ret += %Q_
|
117
|
-
\\subsection{#{escape k}'s Commit Messages}
|
133
|
+
\\subsection{#{escape k.titleize}'s Commit Messages}
|
118
134
|
\\begin{enumerate}
|
119
135
|
_
|
136
|
+
reverseH = {}
|
120
137
|
uniqM = v.map do |x|
|
121
|
-
x[:commit].msg
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
138
|
+
msg = x[:commit].msg.to_s.strip.humanize
|
139
|
+
reverseH[msg] = x
|
140
|
+
msg
|
141
|
+
end.uniq.sort
|
142
|
+
uniqM.each do |msg|
|
143
|
+
x = reverseH[msg]
|
144
|
+
if @gitlab
|
145
|
+
ret += %Q_
|
146
|
+
\\item \\href{#{@gitlab.scheme}://#{@gitlab.host}/#{x[:commit].gitlabProject[:namespace]}/#{x[:commit].gitlabProject[:project]}/commit/#{x[:commit].shaHash}}{#{escape msg}}
|
147
|
+
_
|
148
|
+
else
|
149
|
+
ret += %Q_
|
150
|
+
\\item #{escape msg}
|
151
|
+
_
|
152
|
+
end
|
127
153
|
end
|
128
154
|
ret += %Q_
|
129
155
|
\\end{enumerate}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spreadtheword
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Minqi Pan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gitlab
|