tdx 0.2.1 → 0.2.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/tdx/base.rb +16 -23
- data/lib/tdx/exec.rb +47 -0
- data/lib/tdx/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60591d8400307a666c5abbbb58e96e6528e73eaa
|
4
|
+
data.tar.gz: 8c104eacfad5476280f0f226f94b5e2d103bd6af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fdfaf587263cbac81f441a558db61f92f8e5fdd37eeb6cd253c3a1a1af34b5c14794a142f7297563fafc00ba43a417b770188d011e0aa89a02bb93ec9782b61
|
7
|
+
data.tar.gz: 78a8910b954fd31905978f0b6565048a4cda084ea6bc71b891624956010db985ccfed1d6aea9b2988ffcc6c9835c42cfa2f2d11da3abb818c087a2681fc4dc29
|
data/lib/tdx/base.rb
CHANGED
@@ -25,6 +25,7 @@ require 'yaml'
|
|
25
25
|
require 'octokit'
|
26
26
|
require 'fileutils'
|
27
27
|
require 'English'
|
28
|
+
require 'tdx/exec'
|
28
29
|
|
29
30
|
# TDX main module.
|
30
31
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
@@ -40,20 +41,18 @@ module TDX
|
|
40
41
|
|
41
42
|
def svg
|
42
43
|
dat = Tempfile.new('tdx')
|
43
|
-
version =
|
44
|
+
version = Exec.new('git --version').stdout.split(/ /)[2]
|
44
45
|
raise "git version #{version} is too old, upgrade it to 2.0+" unless
|
45
46
|
Gem::Version.new(version) >= Gem::Version.new('2.0')
|
46
47
|
path = checkout
|
47
|
-
|
48
|
-
|
49
|
-
.split(/\n/)
|
50
|
-
.map { |c| c.split(' ') }
|
48
|
+
|
49
|
+
commits = Exec.new('git log "--pretty=format:%H %cI" --reverse', path)
|
50
|
+
.stdout.split(/\n/).map { |c| c.split(' ') }
|
51
51
|
issues = issues(commits)
|
52
|
-
puts "Date\t\tTest\tHoC\tFiles\tLoC\tIssues\tSHA"
|
52
|
+
puts "Date\t\t\tTest\tHoC\tFiles\tLoC\tIssues\tSHA"
|
53
53
|
commits.each do |sha, date|
|
54
|
-
|
55
|
-
|
56
|
-
line = "#{date[0, 10]}\t#{tests(path)}\t#{hoc(path)}\t#{files(path)}\t\
|
54
|
+
Exec.new("git checkout --quiet #{sha}", path).stdout
|
55
|
+
line = "#{date[0, 16]}\t#{tests(path)}\t#{hoc(path)}\t#{files(path)}\t\
|
57
56
|
#{loc(path)}\t#{issues[sha]}\t#{sha[0, 7]}"
|
58
57
|
dat << "#{line}\n"
|
59
58
|
puts line
|
@@ -81,8 +80,7 @@ module TDX
|
|
81
80
|
', "" using 1:6 with boxes title "Issues" linecolor rgb "orange"'
|
82
81
|
].join(' ')
|
83
82
|
]
|
84
|
-
|
85
|
-
raise 'Failed to run Gnuplot' unless $CHILD_STATUS.exitstatus == 0
|
83
|
+
Exec.new("gnuplot -e '#{gpi.join('; ')}'").stdout
|
86
84
|
FileUtils.rm_rf(path)
|
87
85
|
File.delete(dat)
|
88
86
|
xml = File.read(svg)
|
@@ -94,8 +92,7 @@ module TDX
|
|
94
92
|
|
95
93
|
def checkout
|
96
94
|
dir = Dir.mktmpdir
|
97
|
-
|
98
|
-
raise 'Failed to clone repository' unless $CHILD_STATUS.exitstatus == 0
|
95
|
+
Exec.new("git clone --quiet #{@uri} .", dir).stdout
|
99
96
|
size = Dir.glob(File.join(dir, '**/*'))
|
100
97
|
.map(&:size)
|
101
98
|
.inject(0) { |a, e| a + e }
|
@@ -108,9 +105,7 @@ module TDX
|
|
108
105
|
end
|
109
106
|
|
110
107
|
def loc(path)
|
111
|
-
|
112
|
-
raise 'Failed to run cloc' unless $CHILD_STATUS.exitstatus == 0
|
113
|
-
yaml = YAML.load(cloc)
|
108
|
+
yaml = YAML.load(Exec.new('cloc . --yaml --quiet', path).stdout)
|
114
109
|
if yaml
|
115
110
|
yaml['SUM']['code']
|
116
111
|
else
|
@@ -119,15 +114,11 @@ module TDX
|
|
119
114
|
end
|
120
115
|
|
121
116
|
def hoc(path)
|
122
|
-
hoc
|
123
|
-
raise 'Failed to run hoc' unless $CHILD_STATUS.exitstatus == 0
|
124
|
-
hoc.strip
|
117
|
+
Exec.new('hoc', path).stdout.strip
|
125
118
|
end
|
126
119
|
|
127
120
|
def tests(path)
|
128
|
-
hoc
|
129
|
-
raise 'Failed to run hoc' unless $CHILD_STATUS.exitstatus == 0
|
130
|
-
hoc.strip
|
121
|
+
Exec.new('hoc', path).stdout.strip
|
131
122
|
end
|
132
123
|
|
133
124
|
def issues(commits)
|
@@ -142,7 +133,9 @@ module TDX
|
|
142
133
|
else
|
143
134
|
@uri.gsub(%r{^https://github\.com/|\.git$}, '')
|
144
135
|
end
|
145
|
-
client.list_issues(repo, state: :all).map(&:created_at)
|
136
|
+
list = client.list_issues(repo, state: :all).map(&:created_at)
|
137
|
+
puts "Loaded #{list.length} issues from GitHub repo '#{repo}'"
|
138
|
+
list
|
146
139
|
else
|
147
140
|
[]
|
148
141
|
end
|
data/lib/tdx/exec.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Copyright (c) 2017 Yegor Bugayenko
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
13
|
+
# copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
# SOFTWARE.
|
22
|
+
|
23
|
+
require 'date'
|
24
|
+
require 'yaml'
|
25
|
+
require 'octokit'
|
26
|
+
require 'fileutils'
|
27
|
+
require 'English'
|
28
|
+
|
29
|
+
# TDX main module.
|
30
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
+
# Copyright:: Copyright (c) 2017 Yegor Bugayenko
|
32
|
+
# License:: MIT
|
33
|
+
module TDX
|
34
|
+
# Command line executor
|
35
|
+
class Exec
|
36
|
+
def initialize(cmd, dir = '.')
|
37
|
+
@cmd = cmd
|
38
|
+
@dir = dir
|
39
|
+
end
|
40
|
+
|
41
|
+
def stdout
|
42
|
+
out = `cd #{@dir} && #{@cmd} 2>/dev/null`
|
43
|
+
raise 'Previous command failed' unless $CHILD_STATUS.exitstatus == 0
|
44
|
+
out
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/tdx/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tdx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
@@ -179,6 +179,7 @@ files:
|
|
179
179
|
- features/support/env.rb
|
180
180
|
- lib/tdx.rb
|
181
181
|
- lib/tdx/base.rb
|
182
|
+
- lib/tdx/exec.rb
|
182
183
|
- lib/tdx/version.rb
|
183
184
|
- tdx.gemspec
|
184
185
|
- test/test__helper.rb
|