diggit 2.1.1 → 2.1.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 +5 -1
- data/README.md +16 -12
- data/bin/dgit +1 -1
- data/lib/dgit/core.rb +15 -16
- data/lib/dgit/entries.rb +1 -1
- data/lib/dgit/plugins.rb +2 -4
- data/lib/dgit/version.rb +1 -1
- data/plugins/addon/db.rb +4 -5
- data/plugins/addon/out.rb +3 -4
- data/plugins/addon/r.rb +5 -0
- data/plugins/addon/src_opt.rb +12 -1
- data/plugins/analysis/javadoc.rb +0 -0
- data/plugins/analysis/tex.rb +1 -1
- data/spec/dgit/plugins/analysis/duplicate_analysis.rb +2 -4
- data/spec/dgit/plugins/analysis/my_module/duplicate_analysis.rb +2 -4
- data/spec/dgit/plugins/analysis/my_module/other_analysis.rb +2 -4
- data/spec/dgit/plugins/analysis/test_analysis.rb +2 -4
- data/spec/dgit/plugins/analysis/test_analysis_with_clean_error.rb +1 -2
- data/spec/dgit/plugins/analysis/test_analysis_with_error.rb +1 -2
- data/spec/dgit/plugins/analysis/test_analysis_with_sources_options.rb +1 -2
- data/spec/dgit/plugins/join/test_join.rb +2 -4
- data/spec/dgit/plugins/join/test_join_with_addon.rb +2 -4
- data/spec/dgit/plugins/join/test_join_with_clean_error.rb +1 -2
- data/spec/dgit/plugins/join/test_join_with_error.rb +1 -2
- metadata +19 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cac2786446fa6926083f231b569214be1e40f0a
|
4
|
+
data.tar.gz: 29a9bd41ae8706f127b8f537e3158c8b1e5641bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c52e0b3028901e59002dd18dec88e307fd0b9b586e1a2da2e5643ed706ff7aaa2f45f5fa2d3f7618e8ef451510bdedc6d768978ef52307ac94b87e26fd4f827a
|
7
|
+
data.tar.gz: 955253ceb5e4f142d9571b943ed852c40cf0ab476a3ae9958e80be5f22cbb0e2ccfc1bd79bb42e03eed14fa963c4be19e58580aae626d69e14ff76a77e7246fa
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# Changelog of Diggit
|
2
2
|
|
3
|
+
### Version 2.1.2
|
4
|
+
* Improve documentation
|
5
|
+
* Fix bug of `sources del`
|
6
|
+
|
3
7
|
### Version 2.1.1
|
4
8
|
* Fixed small bugs in the CLI
|
5
9
|
* Fixed source error not showing up in case of clone error
|
6
|
-
* Now urls can have a trailing
|
10
|
+
* Now urls can have a trailing `|id` to enable checkout a tag, branch or commit with a specific id
|
7
11
|
* Out addon have more utility methods
|
8
12
|
|
9
13
|
### Version 2.1.0
|
data/README.md
CHANGED
@@ -4,11 +4,15 @@ A ruby tool to analyze Git repositories
|
|
4
4
|
|
5
5
|
# Installation
|
6
6
|
|
7
|
+
## Prerequisites
|
8
|
+
|
9
|
+
In order for Ruby's libgit binding, [rugged](Pre-requisites), to work, you need to install several native libraries. To build the libgit version shipped with rugged's gem, you need `pkg-config` and `cmake` installed. If you want rugged to be able to clone ssh or https repositories, you need several additional depenc as listed on [libgit website](https://github.com/libgit2/libgit2#optional-dependencies).
|
10
|
+
|
7
11
|
## From a gem
|
8
12
|
|
9
13
|
Just run `gem install diggit`.
|
10
14
|
|
11
|
-
## From the
|
15
|
+
## From the sources, with bundler
|
12
16
|
|
13
17
|
Install diggit using the following commands:
|
14
18
|
```
|
@@ -19,13 +23,13 @@ bundler install
|
|
19
23
|
```
|
20
24
|
Beware, the gem bin directory must be in your path. Also, the `dgit` command is in the `bin` folder of diggit.
|
21
25
|
|
22
|
-
## From the
|
26
|
+
## From the sources, with vagrant
|
23
27
|
|
24
|
-
You can automatically get a working VM with all required dependencies with only one command, how cool is that? For this, just install [vagrant](https://www.vagrantup.com/) and [virtualbox](https://www.virtualbox.org/), and `vagrant up` in a freshly cloned diggit folder (see previous section). Beware, this magic only works on Mac OS and Linux because it uses NFS shared folders.
|
28
|
+
You can automatically get a working VM with all required dependencies with only one command, how cool is that? For this, just install [vagrant](https://www.vagrantup.com/) and [virtualbox](https://www.virtualbox.org/), and `vagrant up` in a freshly cloned diggit folder (see previous section). Beware, this magic only works on Mac OS and Linux because it uses NFS shared folders. Note that if you use this method, you don't care about the prerequisites.
|
25
29
|
|
26
30
|
# Usage
|
27
31
|
|
28
|
-
Don't forget that dgit binary has an associated help that can be consulted using `dgit help`.
|
32
|
+
Don't forget that dgit binary has an associated help that can be consulted using `dgit help`. Additionally, if you have installed Diggit from the sources, you can generate the documentation by running `yard doc` in the cloned folder.
|
29
33
|
|
30
34
|
## Configuration
|
31
35
|
|
@@ -35,20 +39,20 @@ The diggit tool is designed to help you analyze software repositories. Firstly y
|
|
35
39
|
|
36
40
|
You can add some repositories to be analyzed with the following command: `dgit sources add https://github.com/jrfaller/diggit.git`.
|
37
41
|
|
38
|
-
### Using addons
|
39
|
-
|
40
|
-
Addons add features the the diggit tool: for instance capability of writing to a MongoDB database, etc. To enable addons for your current diggit folder you can use the following command: `dgit addons add test_addon`.
|
41
|
-
|
42
42
|
### Setting-up analyses
|
43
43
|
|
44
|
-
An analysis is applied to each repository. You can configure the analyses to be performed with the following command: `dgit analyses add test_analysis`. Analyses are performed in the order they have been added.
|
44
|
+
An analysis is applied to each repository. You can configure the analyses to be performed with the following command: `dgit analyses add test_analysis`. Analyses are performed in the order they have been added. Analyses are provided in the `plugins/analysis` folder (from the diggit installation or in any initialized diggit folder). The filename of an analysis is the underscore cased name of the class where it is defined (which is camel cased). Analyses classes must extend the `Diggit::Analysis` class.
|
45
45
|
|
46
46
|
### Setting-up joins
|
47
47
|
|
48
|
-
A join is performed after all analyses of all repositories have been performed. You can configure the joins to be performed with the following command: `dgit joins add test_join`. Joins are performed in the order they have been added.
|
48
|
+
A join is performed after all analyses of all repositories have been performed. You can configure the joins to be performed with the following command: `dgit joins add test_join`. Joins are performed in the order they have been added. Similarly to analyses, joins are provided in the `plugins/join` folder (from the diggit installation or in any initialized diggit folder). The filename of a join is the underscore cased name of the class where it is defined (which is camel cased). Joins must provide constraints on the analyses that must have been performed on the sources by using `require_analyses` in the class defining the join. For instance, to require the `test_analysis` analysisn, you need to use the statement `require_analyses test_analysis`. Joins classes must extend the `Diggit::Join` class.
|
49
|
+
|
50
|
+
### Using addons
|
51
|
+
|
52
|
+
Addons add features to analyses or joins: for instance the capability of writing to a MongoDB database, etc. To enable addons for an analysis or a join you need to use `require_addons` in an analysis or join class. For instance, to use the filesytem addon you need the following statement: `require_addons out`
|
49
53
|
|
50
|
-
##
|
54
|
+
## Cloning, analysing and joining
|
51
55
|
|
52
|
-
Once diggit is configured you can perform the analyses. First, you have to clone the repositories by using `dgit clones perform`. Then you can launch the analyses by using `dgit analyses perform`. Finally, the joins are executed via the command `dgit joins perform`. You can use the `mode` option to handle the cleaning of joins or analyses.
|
56
|
+
Once diggit is configured you can perform the analyses. First, you have to clone the repositories by using `dgit clones perform`. Then you can launch the analyses by using `dgit analyses perform`. Finally, the joins are executed via the command `dgit joins perform`. You can use the `mode` option to handle the cleaning of joins or analyses (e.g. `dgit analyses perform -m rerun`).
|
53
57
|
|
54
58
|
At all time, you can check the status of your diggit folder by using `dgit status`.
|
data/bin/dgit
CHANGED
@@ -104,7 +104,7 @@ module Diggit
|
|
104
104
|
c.arg_name 'id'
|
105
105
|
c.command :del do |del|
|
106
106
|
del.action do |_global_options, _options, args|
|
107
|
-
Diggit::Dig.it.journal.del_source args[0]
|
107
|
+
Diggit::Dig.it.journal.del_source args[0].to_i
|
108
108
|
end
|
109
109
|
end
|
110
110
|
c.desc 'Import sources from a file.'
|
data/lib/dgit/core.rb
CHANGED
@@ -208,7 +208,7 @@ module Diggit
|
|
208
208
|
|
209
209
|
# Class to handle loading of diggit plugins.
|
210
210
|
# Diggit plugins are defined in camel cased classes derived from Plugin.
|
211
|
-
# Their name is the underscore cased version of the class name (example
|
211
|
+
# Their name is the underscore cased version of the class name (example `MyPlugin` becomes `my_plugin`).
|
212
212
|
# It uses a singleton pattern, so you have to create an instance like that:
|
213
213
|
# @example
|
214
214
|
# PluginLoader.instance
|
@@ -220,8 +220,8 @@ module Diggit
|
|
220
220
|
|
221
221
|
# Load the plugin with the given name and type.
|
222
222
|
# @param name [String] the name of the plugin
|
223
|
-
# @param type [Symbol] the type of the plugin:
|
224
|
-
# @param instance [Boolean]
|
223
|
+
# @param type [Symbol] the type of the plugin: `:addon`, `:analysis` or `:join`.
|
224
|
+
# @param instance [Boolean] `true` for retrieving an instance or `false` for retrieving the class.
|
225
225
|
# @return [Plugin, Class] the instance or class of the plugin.
|
226
226
|
def load_plugin(name, type, instance = false)
|
227
227
|
plugin = search_plugin(name, type)
|
@@ -279,7 +279,7 @@ module Diggit
|
|
279
279
|
end
|
280
280
|
|
281
281
|
# Main diggit class.
|
282
|
-
# It must be runned in a folder containing a
|
282
|
+
# It must be runned in a folder containing a `.dgit folder with a proper configuration.
|
283
283
|
# Access configuration, options, sources and journal from this object.
|
284
284
|
# It implements the singleton pattern.
|
285
285
|
# You can initialize it via {.init} and retrieve the instance via {.it}.
|
@@ -325,10 +325,9 @@ module Diggit
|
|
325
325
|
end
|
326
326
|
|
327
327
|
# Initialize a folder to be a diggit folder by creating an empty configuration.
|
328
|
-
# It creates a
|
329
|
-
# It creates
|
330
|
-
#
|
331
|
-
# Directory creation is skipped if folder already exist.
|
328
|
+
# It creates a `.dgit` folder containing a `journal`, `config`, `options` files.
|
329
|
+
# It also creates an empty `sources` folder and an empty `plugins` folder.
|
330
|
+
# Directory creation is skipped if the `.dgit` folder already exists.
|
332
331
|
# @param folder [String] the path to the folder.
|
333
332
|
# @return [void]
|
334
333
|
def self.init_dir(folder = '.')
|
@@ -371,7 +370,7 @@ module Diggit
|
|
371
370
|
@folder = folder
|
372
371
|
end
|
373
372
|
|
374
|
-
# Load the journal from
|
373
|
+
# Load the journal from `.dgit/journal`
|
375
374
|
# @return [void]
|
376
375
|
def load_journal
|
377
376
|
url_array = []
|
@@ -382,32 +381,32 @@ module Diggit
|
|
382
381
|
end
|
383
382
|
end
|
384
383
|
|
385
|
-
# Save the journal to
|
384
|
+
# Save the journal to `.dgit/journal`
|
386
385
|
# @return [void]
|
387
386
|
def save_journal
|
388
387
|
File.open(config_path(DGIT_SOURCES), "w") { |f| @journal.sources.each { |source| f.puts(source.url) } }
|
389
388
|
Oj.to_file(config_path(DGIT_JOURNAL), @journal, indent: 2)
|
390
389
|
end
|
391
390
|
|
392
|
-
# Load the options from
|
391
|
+
# Load the options from `.dgit/options`
|
393
392
|
# @return [void]
|
394
393
|
def load_options
|
395
394
|
@options = Oj.load_file(config_path(DGIT_OPTIONS))
|
396
395
|
end
|
397
396
|
|
398
|
-
# Save the options to
|
397
|
+
# Save the options to `.dgit/options`
|
399
398
|
# @return [void]
|
400
399
|
def save_options
|
401
400
|
Oj.to_file(config_path(DGIT_OPTIONS), options)
|
402
401
|
end
|
403
402
|
|
404
|
-
# Load the config from
|
403
|
+
# Load the config from `.dgit/config`
|
405
404
|
# @return [void]
|
406
405
|
def load_config
|
407
406
|
@config = Config.new(Oj.load_file(config_path(DGIT_CONFIG)))
|
408
407
|
end
|
409
408
|
|
410
|
-
# Save the config to
|
409
|
+
# Save the config to `.dgit/config`
|
411
410
|
# @return [void]
|
412
411
|
def save_config
|
413
412
|
config_hash = @config.to_hash
|
@@ -426,7 +425,7 @@ module Diggit
|
|
426
425
|
# Perform the given analyses on sources with the given ids using the given mode.
|
427
426
|
# @param source_ids [Array<Integer>] the ids of the sources.
|
428
427
|
# @param analyses [Array<String>] the names of the analyses.
|
429
|
-
# @param mode [Symbol] the mode:
|
428
|
+
# @param mode [Symbol] the mode: `:run`, `:rerun` or `:clean`.
|
430
429
|
# @return [void]
|
431
430
|
def analyze(source_ids = [], analyses = [], mode = :run)
|
432
431
|
@journal.sources_by_ids(*source_ids).select { |s| s.entry.cloned? }.each do |s|
|
@@ -443,7 +442,7 @@ module Diggit
|
|
443
442
|
# Perform the given joins on sources with the given ids using the given mode.
|
444
443
|
# @param source_ids [Array<Integer>] the ids of the sources.
|
445
444
|
# @param joins [Array<String>] the names of the analyses.
|
446
|
-
# @param mode [Symbol] the mode:
|
445
|
+
# @param mode [Symbol] the mode: `:run`, `:rerun` or `:clean`.
|
447
446
|
# @return [void]
|
448
447
|
def join(source_ids = [], joins = [], mode = :run)
|
449
448
|
@config.get_joins(*joins).each do |klass|
|
data/lib/dgit/entries.rb
CHANGED
@@ -55,7 +55,7 @@ module Diggit
|
|
55
55
|
|
56
56
|
# Check if a runnable has been performed or canceled.
|
57
57
|
# @param runnable_or_string [Runnable, String] the runnable or the name of the runnable.
|
58
|
-
# @param state [Symbol] the status of the runnable:
|
58
|
+
# @param state [Symbol] the status of the runnable: `:performed`, `:canceled` or `:all`.
|
59
59
|
# @return [Boolean]
|
60
60
|
def has?(runnable_or_string, state = :all)
|
61
61
|
name = retrieve_name(runnable_or_string)
|
data/lib/dgit/plugins.rb
CHANGED
@@ -85,14 +85,12 @@ module Diggit
|
|
85
85
|
# Run the runnable.
|
86
86
|
# @abstract This method must be overrided.
|
87
87
|
# @return [void]
|
88
|
-
def run
|
89
|
-
end
|
88
|
+
def run; end
|
90
89
|
|
91
90
|
# Clean the runnable.
|
92
91
|
# @abstract This method must be overrided.
|
93
92
|
# @return [void]
|
94
|
-
def clean
|
95
|
-
end
|
93
|
+
def clean; end
|
96
94
|
|
97
95
|
# Add an addon as a required addon.
|
98
96
|
#
|
data/lib/dgit/version.rb
CHANGED
data/plugins/addon/db.rb
CHANGED
@@ -20,11 +20,10 @@
|
|
20
20
|
|
21
21
|
require 'mongo'
|
22
22
|
|
23
|
-
# A MongoDB addon for Diggit.
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
# @return [Mongo::DB] the mongo database object.
|
23
|
+
# A MongoDB addon for Diggit. This addon might use a `:mongo` hash in the global options. In this
|
24
|
+
# hash, the `:database` key allows to configure the name of the database.
|
25
|
+
# @!attribute [r] client
|
26
|
+
# @return [Mongo::Client] the mongodb client object.
|
28
27
|
class Db < Diggit::Addon
|
29
28
|
DEFAULT_SERVER = '127.0.0.1:27017'.freeze
|
30
29
|
DEFAULT_DB = 'diggit'.freeze
|
data/plugins/addon/out.rb
CHANGED
@@ -18,14 +18,13 @@
|
|
18
18
|
#
|
19
19
|
# Copyright 2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
|
20
20
|
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# :out key allows to configure the name of the output folder and :tmp the name of the temporary output
|
21
|
+
# A filesystem addon for Diggit. This addon might use an :output hash in the global options. In this hash, the
|
22
|
+
# `:out` key allows to configure the path of the output folder and ``:tmp` the path of the temporary output
|
24
23
|
# folder.
|
25
24
|
# @!attribute [r] out
|
26
25
|
# @return [String] the absolute path of the output folder.
|
27
26
|
# @!attribute [r] tmp
|
28
|
-
# @return [String] the absolute path of the temporary
|
27
|
+
# @return [String] the absolute path of the temporary folder.
|
29
28
|
class Out < Diggit::Addon
|
30
29
|
attr_reader :out, :tmp
|
31
30
|
|
data/plugins/addon/r.rb
CHANGED
@@ -22,7 +22,12 @@ R = nil # fixing SIGPIPE error in some cases. See http://hfeild-software.blogspo
|
|
22
22
|
|
23
23
|
require "rinruby"
|
24
24
|
|
25
|
+
# A R addon for Diggit implemented thanks to RinRuby.
|
26
|
+
# @!attribute [r] r
|
27
|
+
# @return [RinRuby] the RinRuby object.
|
25
28
|
class R < Diggit::Addon
|
29
|
+
attr_reader :r
|
30
|
+
|
26
31
|
def initialize(*args)
|
27
32
|
super(args)
|
28
33
|
@r = RinRuby.new({ interactive: false, echo: true })
|
data/plugins/addon/src_opt.rb
CHANGED
@@ -19,7 +19,15 @@
|
|
19
19
|
# Copyright 2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
|
20
20
|
# Copyright 2015 Matthieu Foucault <foucaultmatthieu@gmail.com>
|
21
21
|
|
22
|
-
#
|
22
|
+
# An addon to manage options specific to sources. To use it, you need to create a `.dgit/sources_options` file.
|
23
|
+
# This file must contain a Json object where the source URLs are the keys, and the values will be given to in
|
24
|
+
# return to the call of {[]} with the corresponding source. Example:
|
25
|
+
# ```
|
26
|
+
# "https://github.com/jrfaller/diggit": {
|
27
|
+
# "name": "An option object for the diggit source.",
|
28
|
+
# "useful": true
|
29
|
+
# }
|
30
|
+
# ```
|
23
31
|
class SrcOpt < Diggit::Addon
|
24
32
|
SOURCES_OPTIONS_FILE = 'sources_options'.freeze
|
25
33
|
|
@@ -30,6 +38,9 @@ class SrcOpt < Diggit::Addon
|
|
30
38
|
@sources_options = Oj.load_file(sources_options_path) if File.exist? sources_options_path
|
31
39
|
end
|
32
40
|
|
41
|
+
# Return the option object for the source.
|
42
|
+
# @param source [Source].
|
43
|
+
# @return [Hash] the option object.
|
33
44
|
def [](source)
|
34
45
|
@sources_options[source.url]
|
35
46
|
end
|
data/plugins/analysis/javadoc.rb
CHANGED
File without changes
|
data/plugins/analysis/tex.rb
CHANGED
@@ -32,7 +32,7 @@ class Tex < Diggit::Analysis
|
|
32
32
|
walker.push(repo.head.name)
|
33
33
|
walker.each do |c|
|
34
34
|
repo.checkout(c.oid, { strategy: [:force, :remove_untracked] })
|
35
|
-
words = Dir["**/*.tex"].reduce(0) { |
|
35
|
+
words = Dir["**/*.tex"].reduce(0) { |acc, elem| acc + `cat "#{elem}" | wc -w`.to_i }
|
36
36
|
File.open(file, 'a') { |f| f.puts("#{source.url};#{c.oid};#{words}\n") }
|
37
37
|
end
|
38
38
|
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: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Rémy Falleri
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-12-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rugged
|
@@ -95,6 +95,20 @@ dependencies:
|
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: redcarpet
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '3'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '3'
|
98
112
|
- !ruby/object:Gem::Dependency
|
99
113
|
name: rake
|
100
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,10 +165,8 @@ dependencies:
|
|
151
165
|
- - "~>"
|
152
166
|
- !ruby/object:Gem::Version
|
153
167
|
version: '0'
|
154
|
-
description:
|
155
|
-
the analysis of many Git repositories.
|
156
|
-
|
157
|
-
'
|
168
|
+
description: |
|
169
|
+
The Diggit repository analysis tool is a neat swiss knife to enable the analysis of many Git repositories.
|
158
170
|
email: jr.falleri@gmail.com
|
159
171
|
executables:
|
160
172
|
- dgit
|
@@ -216,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
216
228
|
version: '0'
|
217
229
|
requirements: []
|
218
230
|
rubyforge_project:
|
219
|
-
rubygems_version: 2.
|
231
|
+
rubygems_version: 2.4.5
|
220
232
|
signing_key:
|
221
233
|
specification_version: 4
|
222
234
|
summary: A Git repository analysis tool.
|