diggit 3.0.1 → 3.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/CHANGELOG.md +6 -0
- data/bin/dgit +54 -17
- data/lib/dgit/core.rb +1 -7
- data/lib/dgit/version.rb +1 -1
- data/plugins/addon/out.rb +20 -1
- data/plugins/analysis/conflict_merge.rb +2 -2
- data/plugins/analysis/javadoc.rb +7 -2
- data/plugins/analysis/{tex.rb → words.rb} +10 -4
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e5d600c1a153b908c21f736888189e787cd37b9dfe8b825dd2b09e6d87d3504
|
4
|
+
data.tar.gz: be325f5cfb4e9145e8e6d5b527c4a518f6852687849028e7c4ce06fcbb39e0e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39fca80590e7d9c00936319c5363605fd7e8b9653d200c638b082f4da3a6efa17bfd3c11e5e211a3e8392702beb3c9e4e9f7e7414df5542afcdde4e4a042b09e
|
7
|
+
data.tar.gz: 58660bd365187ac0d816571bd5d7078202a8a0a7401f405f4afad567e82275432334202300d52509c392e8aedcbea5dd24978d328e8c49099db1e04403dddc82
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Changelog of Diggit
|
2
2
|
|
3
|
+
### Version 3.0.2
|
4
|
+
* Added version command
|
5
|
+
* `out` plugin is now able to furnish and clean folder dedicated for an analysis bound to a source
|
6
|
+
* New command to handle options
|
7
|
+
* Use ignore option of Oj to avoid weird serialization
|
8
|
+
|
3
9
|
### Version 3.0.1
|
4
10
|
* Verbose option now used
|
5
11
|
* Improved gemspec
|
data/bin/dgit
CHANGED
@@ -30,10 +30,44 @@ module Diggit
|
|
30
30
|
flag %i[f folder], default_value: ".", desc: "Path to the diggit folder. Default: current folder."
|
31
31
|
|
32
32
|
version Diggit::VERSION
|
33
|
-
|
34
33
|
subcommand_option_handling :normal
|
35
34
|
arguments :strict
|
36
35
|
|
36
|
+
accept(Hash) do |value|
|
37
|
+
result = {}
|
38
|
+
value.split(/,/).each do |pair|
|
39
|
+
k, v = pair.split(/=/)
|
40
|
+
i = v.split(/\|/)
|
41
|
+
result[k] = i
|
42
|
+
end
|
43
|
+
result
|
44
|
+
end
|
45
|
+
|
46
|
+
pre do |globals, _command, _options, _args|
|
47
|
+
Diggit::Dig.init globals[:f]
|
48
|
+
Log.level = :fine if globals[:v]
|
49
|
+
true
|
50
|
+
end
|
51
|
+
|
52
|
+
post do |_global, _command, _options, _args|
|
53
|
+
# Post logic here, skips_post to skip commands
|
54
|
+
end
|
55
|
+
|
56
|
+
on_error do |exception|
|
57
|
+
Log.error "Error running diggit."
|
58
|
+
Log.error exception.message
|
59
|
+
Log.info exception.backtrace.join("\n")
|
60
|
+
false
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "Prints diggit version"
|
64
|
+
skips_pre
|
65
|
+
command :version do |c|
|
66
|
+
c.action do |_globals, _options, _args|
|
67
|
+
Log.ok "Diggit version #{Diggit::VERSION}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
37
71
|
desc 'Init a diggit folder.'
|
38
72
|
skips_pre
|
39
73
|
command :init do |c|
|
@@ -43,6 +77,25 @@ module Diggit
|
|
43
77
|
end
|
44
78
|
end
|
45
79
|
|
80
|
+
desc 'Manage the options of the diggit folder.'
|
81
|
+
command :options do |c|
|
82
|
+
c.desc 'Set an option'
|
83
|
+
c.command :set do |set|
|
84
|
+
set.flag %i[h hash], desc: "hash to store (format: 'foo=bar,baz=val1|val2')", type: Hash, default_value: {}
|
85
|
+
set.action do |_global_options, options, _args|
|
86
|
+
Diggit::Dig.it.options.merge!(options[:h])
|
87
|
+
Diggit::Dig.it.save_options
|
88
|
+
end
|
89
|
+
end
|
90
|
+
c.desc 'Display the options'
|
91
|
+
c.command :show do |show|
|
92
|
+
show.action do |_global_options, _options, _args|
|
93
|
+
Log.info Diggit::Dig.it.options
|
94
|
+
end
|
95
|
+
end
|
96
|
+
c.default_command :show
|
97
|
+
end
|
98
|
+
|
46
99
|
desc 'Display the status of the diggit folder.'
|
47
100
|
command :status do |c|
|
48
101
|
c.action do |_global_options, _options, _args|
|
@@ -235,22 +288,6 @@ module Diggit
|
|
235
288
|
end
|
236
289
|
c.default_command :perform
|
237
290
|
end
|
238
|
-
pre do |globals, _command, _options, _args|
|
239
|
-
Diggit::Dig.init globals[:f]
|
240
|
-
Log.level = :fine if globals[:v]
|
241
|
-
true
|
242
|
-
end
|
243
|
-
|
244
|
-
post do |_global, _command, _options, _args|
|
245
|
-
# Post logic here, skips_post to skip commands
|
246
|
-
end
|
247
|
-
|
248
|
-
on_error do |exception|
|
249
|
-
Log.error "Error running diggit."
|
250
|
-
Log.error exception.message
|
251
|
-
Log.info exception.backtrace.join("\n")
|
252
|
-
false
|
253
|
-
end
|
254
291
|
|
255
292
|
exit run(ARGV)
|
256
293
|
end
|
data/lib/dgit/core.rb
CHANGED
@@ -22,19 +22,13 @@ require 'singleton'
|
|
22
22
|
require_relative 'log'
|
23
23
|
require_relative 'entries'
|
24
24
|
|
25
|
-
class Dummy
|
26
|
-
def initialize(_)
|
27
|
-
Object.new
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
25
|
Oj.default_options = Oj.default_options.merge(
|
32
26
|
mode: :object,
|
33
27
|
indent: 2,
|
34
28
|
auto_define: true,
|
29
|
+
ignore: [Rugged::Repository],
|
35
30
|
circular: true
|
36
31
|
)
|
37
|
-
Oj.register_odd(Rugged::Repository, Dummy, :new, :to_s)
|
38
32
|
|
39
33
|
class String
|
40
34
|
# Returns a underscore cased version of the string.
|
data/lib/dgit/version.rb
CHANGED
data/plugins/addon/out.rb
CHANGED
@@ -50,6 +50,13 @@ class Out < Diggit::Addon
|
|
50
50
|
File.join(@out, *paths)
|
51
51
|
end
|
52
52
|
|
53
|
+
# Get an output path for an analysis bound to a source.
|
54
|
+
# @param analysis [Analysis] an analysis object.
|
55
|
+
# @return [String] the absolute path.
|
56
|
+
def out_path_for_analysis(analysis, *paths)
|
57
|
+
out_path(analysis.name, analysis.source.id, *paths)
|
58
|
+
end
|
59
|
+
|
53
60
|
# Get a temporary path for a file/directory.
|
54
61
|
# @param paths [Array<String>] the different folders of the path.
|
55
62
|
# @return [String] the absolute path.
|
@@ -57,10 +64,22 @@ class Out < Diggit::Addon
|
|
57
64
|
File.join(@tmp, *paths)
|
58
65
|
end
|
59
66
|
|
67
|
+
# Get a temporary path for an analysis bound to a source.
|
68
|
+
# @param analysis [Analysis] an analysis object.
|
69
|
+
# @return [String] the absolute path.
|
70
|
+
def tmp_path_for_analysis(analysis, *paths)
|
71
|
+
tmp_path(analysis.name, analysis.source.id, *paths)
|
72
|
+
end
|
73
|
+
|
60
74
|
# Clean the output and temporary folders.
|
61
75
|
# @return [void]
|
62
|
-
def
|
76
|
+
def clean_all
|
63
77
|
FileUtils.rm_rf(@out)
|
64
78
|
FileUtils.rm_rf(@tmp)
|
65
79
|
end
|
80
|
+
|
81
|
+
def clean_analysis(analysis)
|
82
|
+
FileUtils.rm_rf(out_path_for_analysis(analysis))
|
83
|
+
FileUtils.rm_rf(tmp_path_for_analysis(analysis))
|
84
|
+
end
|
66
85
|
end
|
@@ -36,7 +36,7 @@ class ConflictMerge < Diggit::Analysis
|
|
36
36
|
walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE)
|
37
37
|
walker.push(repo.head.name)
|
38
38
|
walker.each do |commit|
|
39
|
-
out_dir = out.
|
39
|
+
out_dir = out.out_path_for_analysis(self, commit.oid)
|
40
40
|
parents = commit.parents
|
41
41
|
next unless parents.size > 1
|
42
42
|
left = parents[0]
|
@@ -114,6 +114,6 @@ class ConflictMerge < Diggit::Analysis
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def clean
|
117
|
-
out.
|
117
|
+
out.clean_analysis(self)
|
118
118
|
end
|
119
119
|
end
|
data/plugins/analysis/javadoc.rb
CHANGED
@@ -32,6 +32,7 @@ class Javadoc < Diggit::Analysis
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def run
|
35
|
+
FileUtils.mkdir_p(out.out_path_for_analysis(self))
|
35
36
|
files = Dir["#{@source.folder}/src/main/java/**/*.java"]
|
36
37
|
puts "#{files.length} files to process"
|
37
38
|
db = {}
|
@@ -43,7 +44,7 @@ class Javadoc < Diggit::Analysis
|
|
43
44
|
db[f] = index_methods(doc)
|
44
45
|
end
|
45
46
|
|
46
|
-
Oj.to_file(
|
47
|
+
Oj.to_file(file, db)
|
47
48
|
end
|
48
49
|
|
49
50
|
def index_methods(doc)
|
@@ -176,6 +177,10 @@ class Javadoc < Diggit::Analysis
|
|
176
177
|
end
|
177
178
|
|
178
179
|
def clean
|
179
|
-
out.
|
180
|
+
out.clean_analysis(self)
|
181
|
+
end
|
182
|
+
|
183
|
+
def file
|
184
|
+
out.out_path_for_analysis(self, "javadoc.json")
|
180
185
|
end
|
181
186
|
end
|
@@ -17,29 +17,35 @@
|
|
17
17
|
|
18
18
|
require 'fileutils'
|
19
19
|
|
20
|
-
class
|
20
|
+
class Words < Diggit::Analysis
|
21
21
|
require_addons 'out'
|
22
22
|
|
23
23
|
def initialize(options)
|
24
24
|
super(options)
|
25
|
+
@extensions = options[name]
|
25
26
|
end
|
26
27
|
|
27
28
|
def run
|
29
|
+
FileUtils.mkdir_p(out.out_path_for_analysis(self))
|
28
30
|
walker = Rugged::Walker.new(repo)
|
29
31
|
walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE)
|
30
32
|
walker.push(repo.head.name)
|
31
33
|
walker.each do |c|
|
32
34
|
repo.checkout(c.oid, { strategy: %i[force remove_untracked] })
|
33
|
-
words =
|
35
|
+
words = words_files.reduce(0) { |acc, elem| acc + `cat "#{elem}" | wc -w`.to_i }
|
34
36
|
File.open(file, 'a') { |f| f.puts("#{source.url};#{c.oid};#{words}\n") }
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
40
|
+
def words_files
|
41
|
+
@extensions.reduce([]) { |acc, elem| acc + Dir["**/*.#{elem}"] }
|
42
|
+
end
|
43
|
+
|
38
44
|
def clean
|
39
|
-
out.
|
45
|
+
out.clean_analysis(self)
|
40
46
|
end
|
41
47
|
|
42
48
|
def file
|
43
|
-
|
49
|
+
out.out_path_for_analysis(self, "words.csv")
|
44
50
|
end
|
45
51
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diggit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Rémy Falleri
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2018-01-
|
14
|
+
date: 2018-01-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: formatador
|
@@ -47,14 +47,20 @@ dependencies:
|
|
47
47
|
requirements:
|
48
48
|
- - "~>"
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version: '
|
50
|
+
version: '3'
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 3.4.0
|
51
54
|
type: :runtime
|
52
55
|
prerelease: false
|
53
56
|
version_requirements: !ruby/object:Gem::Requirement
|
54
57
|
requirements:
|
55
58
|
- - "~>"
|
56
59
|
- !ruby/object:Gem::Version
|
57
|
-
version: '
|
60
|
+
version: '3'
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 3.4.0
|
58
64
|
- !ruby/object:Gem::Dependency
|
59
65
|
name: rugged
|
60
66
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,7 +210,7 @@ files:
|
|
204
210
|
- plugins/analysis/cloc_per_file.rb
|
205
211
|
- plugins/analysis/conflict_merge.rb
|
206
212
|
- plugins/analysis/javadoc.rb
|
207
|
-
- plugins/analysis/
|
213
|
+
- plugins/analysis/words.rb
|
208
214
|
- spec/cli_spec.rb
|
209
215
|
- spec/core_spec.rb
|
210
216
|
- spec/dgit/plugins/addon/test_addon.rb
|