diggit 2.1.1 → 2.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60e58099916b06eceaa99f9bad1f18822ac74106
4
- data.tar.gz: 5568fc8c3a6bd36f09f25d7ceeb9233da126ffea
3
+ metadata.gz: 5cac2786446fa6926083f231b569214be1e40f0a
4
+ data.tar.gz: 29a9bd41ae8706f127b8f537e3158c8b1e5641bb
5
5
  SHA512:
6
- metadata.gz: 84dd036f313699556b0fafc8604d56b45ceb7441dc7f4530061c98816973f6bb0c71406245b3569dcfa9cf244caab20d96702ba16e9f802dafce94994f6ea2e5
7
- data.tar.gz: d82cc5a83c57e774af69f367df32dc695b72cb2807963e687502f3de309d7bf4ea784b4fa7bad6216484feab48e2c1e675f3120fefb99af444784e92c98217b3
6
+ metadata.gz: c52e0b3028901e59002dd18dec88e307fd0b9b586e1a2da2e5643ed706ff7aaa2f45f5fa2d3f7618e8ef451510bdedc6d768978ef52307ac94b87e26fd4f827a
7
+ data.tar.gz: 955253ceb5e4f142d9571b943ed852c40cf0ab476a3ae9958e80be5f22cbb0e2ccfc1bd79bb42e03eed14fa963c4be19e58580aae626d69e14ff76a77e7246fa
@@ -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 |id to enable checkout a tag, branch or commit with a specific id
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 source, with bundler
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 source, with vagrant
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
- ## Running analyses
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.'
@@ -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 +MyPlugin+ becomes +my_plugin+).
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: +:addon+, +:analysis+ or +:join+.
224
- # @param instance [Boolean] +true+ for retrieving an instance or +false+ for retrieving the class.
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 +.dgit+ folder with a proper configuration.
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 +.dgit+ folder containing a +journal+, +config+, +options+ files.
329
- # It creates a +sources+ folder.
330
- # It creates a +plugins+ folder.
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 +.dgit/journal+
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 +.dgit/journal+
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 +.dgit/options+
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 +.dgit/options+
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 +.dgit/config+
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 +.dgit/config+
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: +:run+, +:rerun+ or +:clean+.
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: +:run+, +:rerun+ or +:clean+.
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|
@@ -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: +:performed+, +:canceled+ or +:all+.
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)
@@ -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
  #
@@ -19,5 +19,5 @@
19
19
  # Copyright 2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
20
20
 
21
21
  module Diggit
22
- VERSION = '2.1.1'.freeze
22
+ VERSION = '2.1.2'.freeze
23
23
  end
@@ -20,11 +20,10 @@
20
20
 
21
21
  require 'mongo'
22
22
 
23
- # A MongoDB addon for Diggit. The name of this addon is :db.
24
- # This addon might use an :mongo hash in the global options. In this
25
- # hash, the :database key allows to configure the name of the database.
26
- # @!attribute [r] db
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
@@ -18,14 +18,13 @@
18
18
  #
19
19
  # Copyright 2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
20
20
 
21
- # An output addon for Diggit. The name of the addon is :output, and can be reached in the
22
- # addons hash. This addon might use an :output hash in the global options. In this hash, the
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 output folder.
27
+ # @return [String] the absolute path of the temporary folder.
29
28
  class Out < Diggit::Addon
30
29
  attr_reader :out, :tmp
31
30
 
@@ -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 })
@@ -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
- # Manages options that are specific to a given source
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
File without changes
@@ -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) { |a, e| a + `cat "#{e}" | wc -w`.to_i }
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
@@ -19,9 +19,7 @@
19
19
  # Copyright 2015 Matthieu Foucault <foucaultmatthieu@gmail.com>
20
20
 
21
21
  class DuplicateAnalysis < Diggit::Analysis
22
- def run
23
- end
22
+ def run; end
24
23
 
25
- def clean
26
- end
24
+ def clean; end
27
25
  end
@@ -20,10 +20,8 @@
20
20
 
21
21
  module MyModule
22
22
  class DuplicateAnalysis < Diggit::Analysis
23
- def run
24
- end
23
+ def run; end
25
24
 
26
- def clean
27
- end
25
+ def clean; end
28
26
  end
29
27
  end
@@ -20,10 +20,8 @@
20
20
 
21
21
  module MyModule
22
22
  class OtherAnalysis < Diggit::Analysis
23
- def run
24
- end
23
+ def run; end
25
24
 
26
- def clean
27
- end
25
+ def clean; end
28
26
  end
29
27
  end
@@ -18,9 +18,7 @@
18
18
  # Copyright 2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
19
19
 
20
20
  class TestAnalysis < Diggit::Analysis
21
- def run
22
- end
21
+ def run; end
23
22
 
24
- def clean
25
- end
23
+ def clean; end
26
24
  end
@@ -18,8 +18,7 @@
18
18
  # Copyright 2015 Jean-Rémy Falleri <jr.falleri@gmail.com>
19
19
 
20
20
  class TestAnalysisWithCleanError < Diggit::Analysis
21
- def run
22
- end
21
+ def run; end
23
22
 
24
23
  def clean
25
24
  raise "Error!"
@@ -22,6 +22,5 @@ class TestAnalysisWithError < Diggit::Analysis
22
22
  raise "Error!"
23
23
  end
24
24
 
25
- def clean
26
- end
25
+ def clean; end
27
26
  end
@@ -29,6 +29,5 @@ class TestAnalysisWithSourcesOptions < Diggit::Analysis
29
29
  puts src_opt[@source]["myOption"]
30
30
  end
31
31
 
32
- def clean
33
- end
32
+ def clean; end
34
33
  end
@@ -20,9 +20,7 @@
20
20
  class TestJoin < Diggit::Join
21
21
  require_analyses 'test_analysis'
22
22
 
23
- def run
24
- end
23
+ def run; end
25
24
 
26
- def clean
27
- end
25
+ def clean; end
28
26
  end
@@ -21,9 +21,7 @@ class TestJoinWithAddon < Diggit::Join
21
21
  require_addons 'test_addon'
22
22
  require_analyses 'test_analysis_with_error'
23
23
 
24
- def run
25
- end
24
+ def run; end
26
25
 
27
- def clean
28
- end
26
+ def clean; end
29
27
  end
@@ -20,8 +20,7 @@
20
20
  class TestJoinWithCleanError < Diggit::Join
21
21
  require_analyses 'test_analysis'
22
22
 
23
- def run
24
- end
23
+ def run; end
25
24
 
26
25
  def clean
27
26
  raise "Error!"
@@ -24,6 +24,5 @@ class TestJoinWithError < Diggit::Join
24
24
  raise "Error!"
25
25
  end
26
26
 
27
- def clean
28
- end
27
+ def clean; end
29
28
  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.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-10-24 00:00:00.000000000 Z
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: 'The Diggit repository analysis tool is a neat swiss knife to enable
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.6.7
231
+ rubygems_version: 2.4.5
220
232
  signing_key:
221
233
  specification_version: 4
222
234
  summary: A Git repository analysis tool.