Class: Diggit::Dig

Inherits:
Object
  • Object
show all
Defined in:
lib/dgit/core.rb

Overview

Main diggit class. It must be runned in a folder containing a ‘.dgit folder with a proper configuration. Access configuration, options, sources and journal from this object. It implements the singleton pattern. You can initialize it via Dig.init and retrieve the instance via Dig.it.

Constant Summary collapse

DGIT_FOLDER =
".dgit".freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(folder) ⇒ Dig

Constructor. Should not be called directly. Use init and it instead.



373
374
375
376
377
# File 'lib/dgit/core.rb', line 373

def initialize(folder)
	raise "Folder #{folder} is not a diggit folder." unless File.exist?(File.expand_path(DGIT_FOLDER, folder))
	@plugin_loader = PluginLoader.instance
	@folder = folder
end

Instance Attribute Details

#configConfig (readonly)

Returns the config.

Returns:



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
# File 'lib/dgit/core.rb', line 302

class Dig
	DGIT_FOLDER = ".dgit".freeze
	DGIT_SOURCES = "sources".freeze
	DGIT_CONFIG = "config".freeze
	DGIT_OPTIONS = "options".freeze
	DGIT_JOURNAL = "journal".freeze

	private_constant :DGIT_SOURCES, :DGIT_CONFIG, :DGIT_OPTIONS, :DGIT_JOURNAL

	attr_reader :config, :options, :journal, :plugin_loader, :folder

	@diggit = nil

	# Returns the diggit instance.
	# @return [Dig] the instance.
	def self.it
		raise "Diggit has not been initialized." if @diggit.nil?
		@diggit
	end

	# Initialize and return the diggit instance into the given folder.
	# @param folder [String] the path to the folder.
	# @return [Dig] the instance.
	def self.init(folder = '.')
		@diggit = Dig.new(folder)
		@diggit.load_options
		@diggit.load_config
		@diggit.load_journal
		@diggit
	end

	# Initialize a folder to be a diggit folder by creating an empty configuration.
	# It creates a `.dgit` folder containing a `journal`, `config`, `options` files.
	# It also creates an empty `sources` folder and an empty `plugins` folder.
	# Directory creation is skipped if the `.dgit` folder already exists.
	# @param folder [String] the path to the folder.
	# @return [void]
	def self.init_dir(folder = '.')
		dgit_folder = File.expand_path(DGIT_FOLDER, folder)
		unless File.exist?(dgit_folder)
			FileUtils.mkdir(dgit_folder)
			Oj.to_file(File.expand_path(DGIT_CONFIG, dgit_folder), Config.empty_config)
			Oj.to_file(File.expand_path(DGIT_OPTIONS, dgit_folder), {})
			FileUtils.touch(File.expand_path(DGIT_SOURCES, dgit_folder))
			Oj.to_file(File.expand_path(DGIT_JOURNAL, dgit_folder), Journal.new)
		end
		FileUtils.mkdir(File.expand_path('sources', folder)) unless File.exist?(File.expand_path('sources', folder))
		return if File.exist?(File.expand_path("plugins", folder))
		FileUtils.mkdir_p(File.expand_path("plugins", folder))
		FileUtils.mkdir_p(File.expand_path("plugins/analysis", folder))
		FileUtils.mkdir_p(File.expand_path("plugins/addon", folder))
		FileUtils.mkdir_p(File.expand_path("plugins/join", folder))
	end

	# Return the path of the given config file
	# @param name [String] name of the file
	# @return [String] the path to the file.
	def config_path(name)
		File.expand_path(name, File.expand_path(DGIT_FOLDER, @folder))
	end

	# Return the path of the given file in the diggit folder
	# @param name [String] name of the file
	# @return [String] the path to the file.
	def file_path(name)
		File.expand_path(name, @folder)
	end

	# Constructor. Should not be called directly.
	# Use {.init} and {.it} instead.
	# @return [Dig] a diggit object.
	def initialize(folder)
		raise "Folder #{folder} is not a diggit folder." unless File.exist?(File.expand_path(DGIT_FOLDER, folder))
		@plugin_loader = PluginLoader.instance
		@folder = folder
	end

	# Load the journal from `.dgit/journal`
	# @return [void]
	def load_journal
		url_array = []
		IO.readlines(config_path(DGIT_SOURCES)).each { |l| url_array << l.strip }
		@journal = Oj.load_file(config_path(DGIT_JOURNAL))
		url_array.each do |url|
			@journal.add_source(url)
		end
	end

	# Save the journal to `.dgit/journal`
	# @return [void]
	def save_journal
		File.open(config_path(DGIT_SOURCES), "w") { |f| @journal.sources.each { |source| f.puts(source.url) } }
		Oj.to_file(config_path(DGIT_JOURNAL), @journal, indent: 2)
	end

	# Load the options from `.dgit/options`
	# @return [void]
	def load_options
		@options = Oj.load_file(config_path(DGIT_OPTIONS))
	end

	# Save the options to `.dgit/options`
	# @return [void]
	def save_options
		Oj.to_file(config_path(DGIT_OPTIONS), options)
	end

	# Load the config from `.dgit/config`
	# @return [void]
	def load_config
		@config = Config.new(Oj.load_file(config_path(DGIT_CONFIG)))
	end

	# Save the config to `.dgit/config`
	# @return [void]
	def save_config
		config_hash = @config.to_hash
		Oj.to_file(config_path(DGIT_CONFIG), config_hash)
	end

	# Clone the repository of all sources with the given source ids.
	# @param source_ids [Array<Integer>] the ids of the sources.
	# @return [void]
	def clone(*source_ids)
		@journal.sources_by_ids(*source_ids).select { |s| s.entry.new? }.each(&:clone)
	ensure
		save_journal
	end

	# Perform the given analyses on sources with the given ids using the given mode.
	# @param source_ids [Array<Integer>] the ids of the sources.
	# @param analyses [Array<String>] the names of the analyses.
	# @param mode [Symbol] the mode: `:run`, `:rerun` or `:clean`.
	# @return [void]
	def analyze(source_ids = [], analyses = [], mode = :run)
		@journal.sources_by_ids(*source_ids).select { |s| s.entry.cloned? }.each do |s|
			@config.get_analyses(*analyses).each do |klass|
				a = klass.new(@options)
				s.load_repository
				a.source = s
				clean(a, s.entry) if clean_mode?(mode) && s.entry.has?(a)
				run(a, s.entry) if run_mode?(mode) && !s.entry.has?(a)
			end
		end
	end

	# Perform the given joins on sources with the given ids using the given mode.
	# @param source_ids [Array<Integer>] the ids of the sources.
	# @param joins [Array<String>] the names of the analyses.
	# @param mode [Symbol] the mode: `:run`, `:rerun` or `:clean`.
	# @return [void]
	def join(source_ids = [], joins = [], mode = :run)
		@config.get_joins(*joins).each do |klass|
			j = klass.new(@options)
			clean(j, @journal.workspace) if clean_mode?(mode) && @journal.workspace.has?(j)
			source_array = @journal.sources_by_ids(*source_ids).select do |s|
				s.entry.cloned? && (klass.required_analyses - s.entry.performed.map(&:name)).empty?
			end
			j.sources = source_array
			run(j, @journal.workspace) if run_mode?(mode) && !source_array.empty? && !@journal.workspace.has?(j)
		end
	end

		private

	def clean_mode?(mode)
		mode == :rerun || mode == :clean
	end

	def run_mode?(mode)
		mode == :rerun || mode == :run
	end

	def clean(runnable, placeholder)
		placeholder.clean(runnable)
		entry = RunnableEntry.new(runnable)
		begin
			runnable.clean
		rescue StandardError => e
			entry.toc
			entry.error = e
			placeholder.canceled << entry
			Log.error "Error cleaning #{runnable.name}: #{e}"
			e.backtrace.each { |l| Log.debug(l) }
		ensure
			save_journal
		end
	end

	def run(runnable, placeholder)
		entry = RunnableEntry.new(runnable)
		begin
			runnable.run
		rescue StandardError => e
			entry.toc
			entry.error = e
			placeholder.canceled << entry
			Log.error "Error running #{runnable.name}: #{e}"
			e.backtrace.each { |l| Log.debug(l) }
		else
			entry.toc
			placeholder.performed << entry
		ensure
			save_journal
		end
	end
end

#folderString (readonly)

Returns the folder in which diggit is running.

Returns:

  • (String)

    the folder in which diggit is running.



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
# File 'lib/dgit/core.rb', line 302

class Dig
	DGIT_FOLDER = ".dgit".freeze
	DGIT_SOURCES = "sources".freeze
	DGIT_CONFIG = "config".freeze
	DGIT_OPTIONS = "options".freeze
	DGIT_JOURNAL = "journal".freeze

	private_constant :DGIT_SOURCES, :DGIT_CONFIG, :DGIT_OPTIONS, :DGIT_JOURNAL

	attr_reader :config, :options, :journal, :plugin_loader, :folder

	@diggit = nil

	# Returns the diggit instance.
	# @return [Dig] the instance.
	def self.it
		raise "Diggit has not been initialized." if @diggit.nil?
		@diggit
	end

	# Initialize and return the diggit instance into the given folder.
	# @param folder [String] the path to the folder.
	# @return [Dig] the instance.
	def self.init(folder = '.')
		@diggit = Dig.new(folder)
		@diggit.load_options
		@diggit.load_config
		@diggit.load_journal
		@diggit
	end

	# Initialize a folder to be a diggit folder by creating an empty configuration.
	# It creates a `.dgit` folder containing a `journal`, `config`, `options` files.
	# It also creates an empty `sources` folder and an empty `plugins` folder.
	# Directory creation is skipped if the `.dgit` folder already exists.
	# @param folder [String] the path to the folder.
	# @return [void]
	def self.init_dir(folder = '.')
		dgit_folder = File.expand_path(DGIT_FOLDER, folder)
		unless File.exist?(dgit_folder)
			FileUtils.mkdir(dgit_folder)
			Oj.to_file(File.expand_path(DGIT_CONFIG, dgit_folder), Config.empty_config)
			Oj.to_file(File.expand_path(DGIT_OPTIONS, dgit_folder), {})
			FileUtils.touch(File.expand_path(DGIT_SOURCES, dgit_folder))
			Oj.to_file(File.expand_path(DGIT_JOURNAL, dgit_folder), Journal.new)
		end
		FileUtils.mkdir(File.expand_path('sources', folder)) unless File.exist?(File.expand_path('sources', folder))
		return if File.exist?(File.expand_path("plugins", folder))
		FileUtils.mkdir_p(File.expand_path("plugins", folder))
		FileUtils.mkdir_p(File.expand_path("plugins/analysis", folder))
		FileUtils.mkdir_p(File.expand_path("plugins/addon", folder))
		FileUtils.mkdir_p(File.expand_path("plugins/join", folder))
	end

	# Return the path of the given config file
	# @param name [String] name of the file
	# @return [String] the path to the file.
	def config_path(name)
		File.expand_path(name, File.expand_path(DGIT_FOLDER, @folder))
	end

	# Return the path of the given file in the diggit folder
	# @param name [String] name of the file
	# @return [String] the path to the file.
	def file_path(name)
		File.expand_path(name, @folder)
	end

	# Constructor. Should not be called directly.
	# Use {.init} and {.it} instead.
	# @return [Dig] a diggit object.
	def initialize(folder)
		raise "Folder #{folder} is not a diggit folder." unless File.exist?(File.expand_path(DGIT_FOLDER, folder))
		@plugin_loader = PluginLoader.instance
		@folder = folder
	end

	# Load the journal from `.dgit/journal`
	# @return [void]
	def load_journal
		url_array = []
		IO.readlines(config_path(DGIT_SOURCES)).each { |l| url_array << l.strip }
		@journal = Oj.load_file(config_path(DGIT_JOURNAL))
		url_array.each do |url|
			@journal.add_source(url)
		end
	end

	# Save the journal to `.dgit/journal`
	# @return [void]
	def save_journal
		File.open(config_path(DGIT_SOURCES), "w") { |f| @journal.sources.each { |source| f.puts(source.url) } }
		Oj.to_file(config_path(DGIT_JOURNAL), @journal, indent: 2)
	end

	# Load the options from `.dgit/options`
	# @return [void]
	def load_options
		@options = Oj.load_file(config_path(DGIT_OPTIONS))
	end

	# Save the options to `.dgit/options`
	# @return [void]
	def save_options
		Oj.to_file(config_path(DGIT_OPTIONS), options)
	end

	# Load the config from `.dgit/config`
	# @return [void]
	def load_config
		@config = Config.new(Oj.load_file(config_path(DGIT_CONFIG)))
	end

	# Save the config to `.dgit/config`
	# @return [void]
	def save_config
		config_hash = @config.to_hash
		Oj.to_file(config_path(DGIT_CONFIG), config_hash)
	end

	# Clone the repository of all sources with the given source ids.
	# @param source_ids [Array<Integer>] the ids of the sources.
	# @return [void]
	def clone(*source_ids)
		@journal.sources_by_ids(*source_ids).select { |s| s.entry.new? }.each(&:clone)
	ensure
		save_journal
	end

	# Perform the given analyses on sources with the given ids using the given mode.
	# @param source_ids [Array<Integer>] the ids of the sources.
	# @param analyses [Array<String>] the names of the analyses.
	# @param mode [Symbol] the mode: `:run`, `:rerun` or `:clean`.
	# @return [void]
	def analyze(source_ids = [], analyses = [], mode = :run)
		@journal.sources_by_ids(*source_ids).select { |s| s.entry.cloned? }.each do |s|
			@config.get_analyses(*analyses).each do |klass|
				a = klass.new(@options)
				s.load_repository
				a.source = s
				clean(a, s.entry) if clean_mode?(mode) && s.entry.has?(a)
				run(a, s.entry) if run_mode?(mode) && !s.entry.has?(a)
			end
		end
	end

	# Perform the given joins on sources with the given ids using the given mode.
	# @param source_ids [Array<Integer>] the ids of the sources.
	# @param joins [Array<String>] the names of the analyses.
	# @param mode [Symbol] the mode: `:run`, `:rerun` or `:clean`.
	# @return [void]
	def join(source_ids = [], joins = [], mode = :run)
		@config.get_joins(*joins).each do |klass|
			j = klass.new(@options)
			clean(j, @journal.workspace) if clean_mode?(mode) && @journal.workspace.has?(j)
			source_array = @journal.sources_by_ids(*source_ids).select do |s|
				s.entry.cloned? && (klass.required_analyses - s.entry.performed.map(&:name)).empty?
			end
			j.sources = source_array
			run(j, @journal.workspace) if run_mode?(mode) && !source_array.empty? && !@journal.workspace.has?(j)
		end
	end

		private

	def clean_mode?(mode)
		mode == :rerun || mode == :clean
	end

	def run_mode?(mode)
		mode == :rerun || mode == :run
	end

	def clean(runnable, placeholder)
		placeholder.clean(runnable)
		entry = RunnableEntry.new(runnable)
		begin
			runnable.clean
		rescue StandardError => e
			entry.toc
			entry.error = e
			placeholder.canceled << entry
			Log.error "Error cleaning #{runnable.name}: #{e}"
			e.backtrace.each { |l| Log.debug(l) }
		ensure
			save_journal
		end
	end

	def run(runnable, placeholder)
		entry = RunnableEntry.new(runnable)
		begin
			runnable.run
		rescue StandardError => e
			entry.toc
			entry.error = e
			placeholder.canceled << entry
			Log.error "Error running #{runnable.name}: #{e}"
			e.backtrace.each { |l| Log.debug(l) }
		else
			entry.toc
			placeholder.performed << entry
		ensure
			save_journal
		end
	end
end

#journalJournal (readonly)

Returns the journal.

Returns:



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
# File 'lib/dgit/core.rb', line 302

class Dig
	DGIT_FOLDER = ".dgit".freeze
	DGIT_SOURCES = "sources".freeze
	DGIT_CONFIG = "config".freeze
	DGIT_OPTIONS = "options".freeze
	DGIT_JOURNAL = "journal".freeze

	private_constant :DGIT_SOURCES, :DGIT_CONFIG, :DGIT_OPTIONS, :DGIT_JOURNAL

	attr_reader :config, :options, :journal, :plugin_loader, :folder

	@diggit = nil

	# Returns the diggit instance.
	# @return [Dig] the instance.
	def self.it
		raise "Diggit has not been initialized." if @diggit.nil?
		@diggit
	end

	# Initialize and return the diggit instance into the given folder.
	# @param folder [String] the path to the folder.
	# @return [Dig] the instance.
	def self.init(folder = '.')
		@diggit = Dig.new(folder)
		@diggit.load_options
		@diggit.load_config
		@diggit.load_journal
		@diggit
	end

	# Initialize a folder to be a diggit folder by creating an empty configuration.
	# It creates a `.dgit` folder containing a `journal`, `config`, `options` files.
	# It also creates an empty `sources` folder and an empty `plugins` folder.
	# Directory creation is skipped if the `.dgit` folder already exists.
	# @param folder [String] the path to the folder.
	# @return [void]
	def self.init_dir(folder = '.')
		dgit_folder = File.expand_path(DGIT_FOLDER, folder)
		unless File.exist?(dgit_folder)
			FileUtils.mkdir(dgit_folder)
			Oj.to_file(File.expand_path(DGIT_CONFIG, dgit_folder), Config.empty_config)
			Oj.to_file(File.expand_path(DGIT_OPTIONS, dgit_folder), {})
			FileUtils.touch(File.expand_path(DGIT_SOURCES, dgit_folder))
			Oj.to_file(File.expand_path(DGIT_JOURNAL, dgit_folder), Journal.new)
		end
		FileUtils.mkdir(File.expand_path('sources', folder)) unless File.exist?(File.expand_path('sources', folder))
		return if File.exist?(File.expand_path("plugins", folder))
		FileUtils.mkdir_p(File.expand_path("plugins", folder))
		FileUtils.mkdir_p(File.expand_path("plugins/analysis", folder))
		FileUtils.mkdir_p(File.expand_path("plugins/addon", folder))
		FileUtils.mkdir_p(File.expand_path("plugins/join", folder))
	end

	# Return the path of the given config file
	# @param name [String] name of the file
	# @return [String] the path to the file.
	def config_path(name)
		File.expand_path(name, File.expand_path(DGIT_FOLDER, @folder))
	end

	# Return the path of the given file in the diggit folder
	# @param name [String] name of the file
	# @return [String] the path to the file.
	def file_path(name)
		File.expand_path(name, @folder)
	end

	# Constructor. Should not be called directly.
	# Use {.init} and {.it} instead.
	# @return [Dig] a diggit object.
	def initialize(folder)
		raise "Folder #{folder} is not a diggit folder." unless File.exist?(File.expand_path(DGIT_FOLDER, folder))
		@plugin_loader = PluginLoader.instance
		@folder = folder
	end

	# Load the journal from `.dgit/journal`
	# @return [void]
	def load_journal
		url_array = []
		IO.readlines(config_path(DGIT_SOURCES)).each { |l| url_array << l.strip }
		@journal = Oj.load_file(config_path(DGIT_JOURNAL))
		url_array.each do |url|
			@journal.add_source(url)
		end
	end

	# Save the journal to `.dgit/journal`
	# @return [void]
	def save_journal
		File.open(config_path(DGIT_SOURCES), "w") { |f| @journal.sources.each { |source| f.puts(source.url) } }
		Oj.to_file(config_path(DGIT_JOURNAL), @journal, indent: 2)
	end

	# Load the options from `.dgit/options`
	# @return [void]
	def load_options
		@options = Oj.load_file(config_path(DGIT_OPTIONS))
	end

	# Save the options to `.dgit/options`
	# @return [void]
	def save_options
		Oj.to_file(config_path(DGIT_OPTIONS), options)
	end

	# Load the config from `.dgit/config`
	# @return [void]
	def load_config
		@config = Config.new(Oj.load_file(config_path(DGIT_CONFIG)))
	end

	# Save the config to `.dgit/config`
	# @return [void]
	def save_config
		config_hash = @config.to_hash
		Oj.to_file(config_path(DGIT_CONFIG), config_hash)
	end

	# Clone the repository of all sources with the given source ids.
	# @param source_ids [Array<Integer>] the ids of the sources.
	# @return [void]
	def clone(*source_ids)
		@journal.sources_by_ids(*source_ids).select { |s| s.entry.new? }.each(&:clone)
	ensure
		save_journal
	end

	# Perform the given analyses on sources with the given ids using the given mode.
	# @param source_ids [Array<Integer>] the ids of the sources.
	# @param analyses [Array<String>] the names of the analyses.
	# @param mode [Symbol] the mode: `:run`, `:rerun` or `:clean`.
	# @return [void]
	def analyze(source_ids = [], analyses = [], mode = :run)
		@journal.sources_by_ids(*source_ids).select { |s| s.entry.cloned? }.each do |s|
			@config.get_analyses(*analyses).each do |klass|
				a = klass.new(@options)
				s.load_repository
				a.source = s
				clean(a, s.entry) if clean_mode?(mode) && s.entry.has?(a)
				run(a, s.entry) if run_mode?(mode) && !s.entry.has?(a)
			end
		end
	end

	# Perform the given joins on sources with the given ids using the given mode.
	# @param source_ids [Array<Integer>] the ids of the sources.
	# @param joins [Array<String>] the names of the analyses.
	# @param mode [Symbol] the mode: `:run`, `:rerun` or `:clean`.
	# @return [void]
	def join(source_ids = [], joins = [], mode = :run)
		@config.get_joins(*joins).each do |klass|
			j = klass.new(@options)
			clean(j, @journal.workspace) if clean_mode?(mode) && @journal.workspace.has?(j)
			source_array = @journal.sources_by_ids(*source_ids).select do |s|
				s.entry.cloned? && (klass.required_analyses - s.entry.performed.map(&:name)).empty?
			end
			j.sources = source_array
			run(j, @journal.workspace) if run_mode?(mode) && !source_array.empty? && !@journal.workspace.has?(j)
		end
	end

		private

	def clean_mode?(mode)
		mode == :rerun || mode == :clean
	end

	def run_mode?(mode)
		mode == :rerun || mode == :run
	end

	def clean(runnable, placeholder)
		placeholder.clean(runnable)
		entry = RunnableEntry.new(runnable)
		begin
			runnable.clean
		rescue StandardError => e
			entry.toc
			entry.error = e
			placeholder.canceled << entry
			Log.error "Error cleaning #{runnable.name}: #{e}"
			e.backtrace.each { |l| Log.debug(l) }
		ensure
			save_journal
		end
	end

	def run(runnable, placeholder)
		entry = RunnableEntry.new(runnable)
		begin
			runnable.run
		rescue StandardError => e
			entry.toc
			entry.error = e
			placeholder.canceled << entry
			Log.error "Error running #{runnable.name}: #{e}"
			e.backtrace.each { |l| Log.debug(l) }
		else
			entry.toc
			placeholder.performed << entry
		ensure
			save_journal
		end
	end
end

#optionsHash<String,Object> (readonly)

Returns the options.

Returns:

  • (Hash<String,Object>)

    the options.



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
# File 'lib/dgit/core.rb', line 302

class Dig
	DGIT_FOLDER = ".dgit".freeze
	DGIT_SOURCES = "sources".freeze
	DGIT_CONFIG = "config".freeze
	DGIT_OPTIONS = "options".freeze
	DGIT_JOURNAL = "journal".freeze

	private_constant :DGIT_SOURCES, :DGIT_CONFIG, :DGIT_OPTIONS, :DGIT_JOURNAL

	attr_reader :config, :options, :journal, :plugin_loader, :folder

	@diggit = nil

	# Returns the diggit instance.
	# @return [Dig] the instance.
	def self.it
		raise "Diggit has not been initialized." if @diggit.nil?
		@diggit
	end

	# Initialize and return the diggit instance into the given folder.
	# @param folder [String] the path to the folder.
	# @return [Dig] the instance.
	def self.init(folder = '.')
		@diggit = Dig.new(folder)
		@diggit.load_options
		@diggit.load_config
		@diggit.load_journal
		@diggit
	end

	# Initialize a folder to be a diggit folder by creating an empty configuration.
	# It creates a `.dgit` folder containing a `journal`, `config`, `options` files.
	# It also creates an empty `sources` folder and an empty `plugins` folder.
	# Directory creation is skipped if the `.dgit` folder already exists.
	# @param folder [String] the path to the folder.
	# @return [void]
	def self.init_dir(folder = '.')
		dgit_folder = File.expand_path(DGIT_FOLDER, folder)
		unless File.exist?(dgit_folder)
			FileUtils.mkdir(dgit_folder)
			Oj.to_file(File.expand_path(DGIT_CONFIG, dgit_folder), Config.empty_config)
			Oj.to_file(File.expand_path(DGIT_OPTIONS, dgit_folder), {})
			FileUtils.touch(File.expand_path(DGIT_SOURCES, dgit_folder))
			Oj.to_file(File.expand_path(DGIT_JOURNAL, dgit_folder), Journal.new)
		end
		FileUtils.mkdir(File.expand_path('sources', folder)) unless File.exist?(File.expand_path('sources', folder))
		return if File.exist?(File.expand_path("plugins", folder))
		FileUtils.mkdir_p(File.expand_path("plugins", folder))
		FileUtils.mkdir_p(File.expand_path("plugins/analysis", folder))
		FileUtils.mkdir_p(File.expand_path("plugins/addon", folder))
		FileUtils.mkdir_p(File.expand_path("plugins/join", folder))
	end

	# Return the path of the given config file
	# @param name [String] name of the file
	# @return [String] the path to the file.
	def config_path(name)
		File.expand_path(name, File.expand_path(DGIT_FOLDER, @folder))
	end

	# Return the path of the given file in the diggit folder
	# @param name [String] name of the file
	# @return [String] the path to the file.
	def file_path(name)
		File.expand_path(name, @folder)
	end

	# Constructor. Should not be called directly.
	# Use {.init} and {.it} instead.
	# @return [Dig] a diggit object.
	def initialize(folder)
		raise "Folder #{folder} is not a diggit folder." unless File.exist?(File.expand_path(DGIT_FOLDER, folder))
		@plugin_loader = PluginLoader.instance
		@folder = folder
	end

	# Load the journal from `.dgit/journal`
	# @return [void]
	def load_journal
		url_array = []
		IO.readlines(config_path(DGIT_SOURCES)).each { |l| url_array << l.strip }
		@journal = Oj.load_file(config_path(DGIT_JOURNAL))
		url_array.each do |url|
			@journal.add_source(url)
		end
	end

	# Save the journal to `.dgit/journal`
	# @return [void]
	def save_journal
		File.open(config_path(DGIT_SOURCES), "w") { |f| @journal.sources.each { |source| f.puts(source.url) } }
		Oj.to_file(config_path(DGIT_JOURNAL), @journal, indent: 2)
	end

	# Load the options from `.dgit/options`
	# @return [void]
	def load_options
		@options = Oj.load_file(config_path(DGIT_OPTIONS))
	end

	# Save the options to `.dgit/options`
	# @return [void]
	def save_options
		Oj.to_file(config_path(DGIT_OPTIONS), options)
	end

	# Load the config from `.dgit/config`
	# @return [void]
	def load_config
		@config = Config.new(Oj.load_file(config_path(DGIT_CONFIG)))
	end

	# Save the config to `.dgit/config`
	# @return [void]
	def save_config
		config_hash = @config.to_hash
		Oj.to_file(config_path(DGIT_CONFIG), config_hash)
	end

	# Clone the repository of all sources with the given source ids.
	# @param source_ids [Array<Integer>] the ids of the sources.
	# @return [void]
	def clone(*source_ids)
		@journal.sources_by_ids(*source_ids).select { |s| s.entry.new? }.each(&:clone)
	ensure
		save_journal
	end

	# Perform the given analyses on sources with the given ids using the given mode.
	# @param source_ids [Array<Integer>] the ids of the sources.
	# @param analyses [Array<String>] the names of the analyses.
	# @param mode [Symbol] the mode: `:run`, `:rerun` or `:clean`.
	# @return [void]
	def analyze(source_ids = [], analyses = [], mode = :run)
		@journal.sources_by_ids(*source_ids).select { |s| s.entry.cloned? }.each do |s|
			@config.get_analyses(*analyses).each do |klass|
				a = klass.new(@options)
				s.load_repository
				a.source = s
				clean(a, s.entry) if clean_mode?(mode) && s.entry.has?(a)
				run(a, s.entry) if run_mode?(mode) && !s.entry.has?(a)
			end
		end
	end

	# Perform the given joins on sources with the given ids using the given mode.
	# @param source_ids [Array<Integer>] the ids of the sources.
	# @param joins [Array<String>] the names of the analyses.
	# @param mode [Symbol] the mode: `:run`, `:rerun` or `:clean`.
	# @return [void]
	def join(source_ids = [], joins = [], mode = :run)
		@config.get_joins(*joins).each do |klass|
			j = klass.new(@options)
			clean(j, @journal.workspace) if clean_mode?(mode) && @journal.workspace.has?(j)
			source_array = @journal.sources_by_ids(*source_ids).select do |s|
				s.entry.cloned? && (klass.required_analyses - s.entry.performed.map(&:name)).empty?
			end
			j.sources = source_array
			run(j, @journal.workspace) if run_mode?(mode) && !source_array.empty? && !@journal.workspace.has?(j)
		end
	end

		private

	def clean_mode?(mode)
		mode == :rerun || mode == :clean
	end

	def run_mode?(mode)
		mode == :rerun || mode == :run
	end

	def clean(runnable, placeholder)
		placeholder.clean(runnable)
		entry = RunnableEntry.new(runnable)
		begin
			runnable.clean
		rescue StandardError => e
			entry.toc
			entry.error = e
			placeholder.canceled << entry
			Log.error "Error cleaning #{runnable.name}: #{e}"
			e.backtrace.each { |l| Log.debug(l) }
		ensure
			save_journal
		end
	end

	def run(runnable, placeholder)
		entry = RunnableEntry.new(runnable)
		begin
			runnable.run
		rescue StandardError => e
			entry.toc
			entry.error = e
			placeholder.canceled << entry
			Log.error "Error running #{runnable.name}: #{e}"
			e.backtrace.each { |l| Log.debug(l) }
		else
			entry.toc
			placeholder.performed << entry
		ensure
			save_journal
		end
	end
end

#plugin_loaderPluginLoader (readonly)

Returns utility classes to load plugins.

Returns:



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
# File 'lib/dgit/core.rb', line 302

class Dig
	DGIT_FOLDER = ".dgit".freeze
	DGIT_SOURCES = "sources".freeze
	DGIT_CONFIG = "config".freeze
	DGIT_OPTIONS = "options".freeze
	DGIT_JOURNAL = "journal".freeze

	private_constant :DGIT_SOURCES, :DGIT_CONFIG, :DGIT_OPTIONS, :DGIT_JOURNAL

	attr_reader :config, :options, :journal, :plugin_loader, :folder

	@diggit = nil

	# Returns the diggit instance.
	# @return [Dig] the instance.
	def self.it
		raise "Diggit has not been initialized." if @diggit.nil?
		@diggit
	end

	# Initialize and return the diggit instance into the given folder.
	# @param folder [String] the path to the folder.
	# @return [Dig] the instance.
	def self.init(folder = '.')
		@diggit = Dig.new(folder)
		@diggit.load_options
		@diggit.load_config
		@diggit.load_journal
		@diggit
	end

	# Initialize a folder to be a diggit folder by creating an empty configuration.
	# It creates a `.dgit` folder containing a `journal`, `config`, `options` files.
	# It also creates an empty `sources` folder and an empty `plugins` folder.
	# Directory creation is skipped if the `.dgit` folder already exists.
	# @param folder [String] the path to the folder.
	# @return [void]
	def self.init_dir(folder = '.')
		dgit_folder = File.expand_path(DGIT_FOLDER, folder)
		unless File.exist?(dgit_folder)
			FileUtils.mkdir(dgit_folder)
			Oj.to_file(File.expand_path(DGIT_CONFIG, dgit_folder), Config.empty_config)
			Oj.to_file(File.expand_path(DGIT_OPTIONS, dgit_folder), {})
			FileUtils.touch(File.expand_path(DGIT_SOURCES, dgit_folder))
			Oj.to_file(File.expand_path(DGIT_JOURNAL, dgit_folder), Journal.new)
		end
		FileUtils.mkdir(File.expand_path('sources', folder)) unless File.exist?(File.expand_path('sources', folder))
		return if File.exist?(File.expand_path("plugins", folder))
		FileUtils.mkdir_p(File.expand_path("plugins", folder))
		FileUtils.mkdir_p(File.expand_path("plugins/analysis", folder))
		FileUtils.mkdir_p(File.expand_path("plugins/addon", folder))
		FileUtils.mkdir_p(File.expand_path("plugins/join", folder))
	end

	# Return the path of the given config file
	# @param name [String] name of the file
	# @return [String] the path to the file.
	def config_path(name)
		File.expand_path(name, File.expand_path(DGIT_FOLDER, @folder))
	end

	# Return the path of the given file in the diggit folder
	# @param name [String] name of the file
	# @return [String] the path to the file.
	def file_path(name)
		File.expand_path(name, @folder)
	end

	# Constructor. Should not be called directly.
	# Use {.init} and {.it} instead.
	# @return [Dig] a diggit object.
	def initialize(folder)
		raise "Folder #{folder} is not a diggit folder." unless File.exist?(File.expand_path(DGIT_FOLDER, folder))
		@plugin_loader = PluginLoader.instance
		@folder = folder
	end

	# Load the journal from `.dgit/journal`
	# @return [void]
	def load_journal
		url_array = []
		IO.readlines(config_path(DGIT_SOURCES)).each { |l| url_array << l.strip }
		@journal = Oj.load_file(config_path(DGIT_JOURNAL))
		url_array.each do |url|
			@journal.add_source(url)
		end
	end

	# Save the journal to `.dgit/journal`
	# @return [void]
	def save_journal
		File.open(config_path(DGIT_SOURCES), "w") { |f| @journal.sources.each { |source| f.puts(source.url) } }
		Oj.to_file(config_path(DGIT_JOURNAL), @journal, indent: 2)
	end

	# Load the options from `.dgit/options`
	# @return [void]
	def load_options
		@options = Oj.load_file(config_path(DGIT_OPTIONS))
	end

	# Save the options to `.dgit/options`
	# @return [void]
	def save_options
		Oj.to_file(config_path(DGIT_OPTIONS), options)
	end

	# Load the config from `.dgit/config`
	# @return [void]
	def load_config
		@config = Config.new(Oj.load_file(config_path(DGIT_CONFIG)))
	end

	# Save the config to `.dgit/config`
	# @return [void]
	def save_config
		config_hash = @config.to_hash
		Oj.to_file(config_path(DGIT_CONFIG), config_hash)
	end

	# Clone the repository of all sources with the given source ids.
	# @param source_ids [Array<Integer>] the ids of the sources.
	# @return [void]
	def clone(*source_ids)
		@journal.sources_by_ids(*source_ids).select { |s| s.entry.new? }.each(&:clone)
	ensure
		save_journal
	end

	# Perform the given analyses on sources with the given ids using the given mode.
	# @param source_ids [Array<Integer>] the ids of the sources.
	# @param analyses [Array<String>] the names of the analyses.
	# @param mode [Symbol] the mode: `:run`, `:rerun` or `:clean`.
	# @return [void]
	def analyze(source_ids = [], analyses = [], mode = :run)
		@journal.sources_by_ids(*source_ids).select { |s| s.entry.cloned? }.each do |s|
			@config.get_analyses(*analyses).each do |klass|
				a = klass.new(@options)
				s.load_repository
				a.source = s
				clean(a, s.entry) if clean_mode?(mode) && s.entry.has?(a)
				run(a, s.entry) if run_mode?(mode) && !s.entry.has?(a)
			end
		end
	end

	# Perform the given joins on sources with the given ids using the given mode.
	# @param source_ids [Array<Integer>] the ids of the sources.
	# @param joins [Array<String>] the names of the analyses.
	# @param mode [Symbol] the mode: `:run`, `:rerun` or `:clean`.
	# @return [void]
	def join(source_ids = [], joins = [], mode = :run)
		@config.get_joins(*joins).each do |klass|
			j = klass.new(@options)
			clean(j, @journal.workspace) if clean_mode?(mode) && @journal.workspace.has?(j)
			source_array = @journal.sources_by_ids(*source_ids).select do |s|
				s.entry.cloned? && (klass.required_analyses - s.entry.performed.map(&:name)).empty?
			end
			j.sources = source_array
			run(j, @journal.workspace) if run_mode?(mode) && !source_array.empty? && !@journal.workspace.has?(j)
		end
	end

		private

	def clean_mode?(mode)
		mode == :rerun || mode == :clean
	end

	def run_mode?(mode)
		mode == :rerun || mode == :run
	end

	def clean(runnable, placeholder)
		placeholder.clean(runnable)
		entry = RunnableEntry.new(runnable)
		begin
			runnable.clean
		rescue StandardError => e
			entry.toc
			entry.error = e
			placeholder.canceled << entry
			Log.error "Error cleaning #{runnable.name}: #{e}"
			e.backtrace.each { |l| Log.debug(l) }
		ensure
			save_journal
		end
	end

	def run(runnable, placeholder)
		entry = RunnableEntry.new(runnable)
		begin
			runnable.run
		rescue StandardError => e
			entry.toc
			entry.error = e
			placeholder.canceled << entry
			Log.error "Error running #{runnable.name}: #{e}"
			e.backtrace.each { |l| Log.debug(l) }
		else
			entry.toc
			placeholder.performed << entry
		ensure
			save_journal
		end
	end
end

Class Method Details

.init(folder = '.') ⇒ Dig

Initialize and return the diggit instance into the given folder.

Parameters:

  • folder (String) (defaults to: '.')

    the path to the folder.

Returns:

  • (Dig)

    the instance.



325
326
327
328
329
330
331
# File 'lib/dgit/core.rb', line 325

def self.init(folder = '.')
	@diggit = Dig.new(folder)
	@diggit.load_options
	@diggit.load_config
	@diggit.load_journal
	@diggit
end

.init_dir(folder = '.') ⇒ void

This method returns an undefined value.

Initialize a folder to be a diggit folder by creating an empty configuration. It creates a ‘.dgit` folder containing a `journal`, `config`, `options` files. It also creates an empty `sources` folder and an empty `plugins` folder. Directory creation is skipped if the `.dgit` folder already exists.

Parameters:

  • folder (String) (defaults to: '.')

    the path to the folder.



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# File 'lib/dgit/core.rb', line 339

def self.init_dir(folder = '.')
	dgit_folder = File.expand_path(DGIT_FOLDER, folder)
	unless File.exist?(dgit_folder)
		FileUtils.mkdir(dgit_folder)
		Oj.to_file(File.expand_path(DGIT_CONFIG, dgit_folder), Config.empty_config)
		Oj.to_file(File.expand_path(DGIT_OPTIONS, dgit_folder), {})
		FileUtils.touch(File.expand_path(DGIT_SOURCES, dgit_folder))
		Oj.to_file(File.expand_path(DGIT_JOURNAL, dgit_folder), Journal.new)
	end
	FileUtils.mkdir(File.expand_path('sources', folder)) unless File.exist?(File.expand_path('sources', folder))
	return if File.exist?(File.expand_path("plugins", folder))
	FileUtils.mkdir_p(File.expand_path("plugins", folder))
	FileUtils.mkdir_p(File.expand_path("plugins/analysis", folder))
	FileUtils.mkdir_p(File.expand_path("plugins/addon", folder))
	FileUtils.mkdir_p(File.expand_path("plugins/join", folder))
end

.itDig

Returns the diggit instance.

Returns:

  • (Dig)

    the instance.



317
318
319
320
# File 'lib/dgit/core.rb', line 317

def self.it
	raise "Diggit has not been initialized." if @diggit.nil?
	@diggit
end

Instance Method Details

#analyze(source_ids = [], analyses = [], mode = :run) ⇒ void

This method returns an undefined value.

Perform the given analyses on sources with the given ids using the given mode.

Parameters:

  • source_ids (Array<Integer>) (defaults to: [])

    the ids of the sources.

  • analyses (Array<String>) (defaults to: [])

    the names of the analyses.

  • mode (Symbol) (defaults to: :run)

    the mode: ‘:run`, `:rerun` or `:clean`.



436
437
438
439
440
441
442
443
444
445
446
# File 'lib/dgit/core.rb', line 436

def analyze(source_ids = [], analyses = [], mode = :run)
	@journal.sources_by_ids(*source_ids).select { |s| s.entry.cloned? }.each do |s|
		@config.get_analyses(*analyses).each do |klass|
			a = klass.new(@options)
			s.load_repository
			a.source = s
			clean(a, s.entry) if clean_mode?(mode) && s.entry.has?(a)
			run(a, s.entry) if run_mode?(mode) && !s.entry.has?(a)
		end
	end
end

#clone(*source_ids) ⇒ void

This method returns an undefined value.

Clone the repository of all sources with the given source ids.

Parameters:

  • source_ids (Array<Integer>)

    the ids of the sources.



425
426
427
428
429
# File 'lib/dgit/core.rb', line 425

def clone(*source_ids)
	@journal.sources_by_ids(*source_ids).select { |s| s.entry.new? }.each(&:clone)
ensure
	save_journal
end

#config_path(name) ⇒ String

Return the path of the given config file

Parameters:

  • name (String)

    name of the file

Returns:

  • (String)

    the path to the file.



359
360
361
# File 'lib/dgit/core.rb', line 359

def config_path(name)
	File.expand_path(name, File.expand_path(DGIT_FOLDER, @folder))
end

#file_path(name) ⇒ String

Return the path of the given file in the diggit folder

Parameters:

  • name (String)

    name of the file

Returns:

  • (String)

    the path to the file.



366
367
368
# File 'lib/dgit/core.rb', line 366

def file_path(name)
	File.expand_path(name, @folder)
end

#join(source_ids = [], joins = [], mode = :run) ⇒ void

This method returns an undefined value.

Perform the given joins on sources with the given ids using the given mode.

Parameters:

  • source_ids (Array<Integer>) (defaults to: [])

    the ids of the sources.

  • joins (Array<String>) (defaults to: [])

    the names of the analyses.

  • mode (Symbol) (defaults to: :run)

    the mode: ‘:run`, `:rerun` or `:clean`.



453
454
455
456
457
458
459
460
461
462
463
# File 'lib/dgit/core.rb', line 453

def join(source_ids = [], joins = [], mode = :run)
	@config.get_joins(*joins).each do |klass|
		j = klass.new(@options)
		clean(j, @journal.workspace) if clean_mode?(mode) && @journal.workspace.has?(j)
		source_array = @journal.sources_by_ids(*source_ids).select do |s|
			s.entry.cloned? && (klass.required_analyses - s.entry.performed.map(&:name)).empty?
		end
		j.sources = source_array
		run(j, @journal.workspace) if run_mode?(mode) && !source_array.empty? && !@journal.workspace.has?(j)
	end
end

#load_configvoid

This method returns an undefined value.

Load the config from ‘.dgit/config`



411
412
413
# File 'lib/dgit/core.rb', line 411

def load_config
	@config = Config.new(Oj.load_file(config_path(DGIT_CONFIG)))
end

#load_journalvoid

This method returns an undefined value.

Load the journal from ‘.dgit/journal`



381
382
383
384
385
386
387
388
# File 'lib/dgit/core.rb', line 381

def load_journal
	url_array = []
	IO.readlines(config_path(DGIT_SOURCES)).each { |l| url_array << l.strip }
	@journal = Oj.load_file(config_path(DGIT_JOURNAL))
	url_array.each do |url|
		@journal.add_source(url)
	end
end

#load_optionsvoid

This method returns an undefined value.

Load the options from ‘.dgit/options`



399
400
401
# File 'lib/dgit/core.rb', line 399

def load_options
	@options = Oj.load_file(config_path(DGIT_OPTIONS))
end

#save_configvoid

This method returns an undefined value.

Save the config to ‘.dgit/config`



417
418
419
420
# File 'lib/dgit/core.rb', line 417

def save_config
	config_hash = @config.to_hash
	Oj.to_file(config_path(DGIT_CONFIG), config_hash)
end

#save_journalvoid

This method returns an undefined value.

Save the journal to ‘.dgit/journal`



392
393
394
395
# File 'lib/dgit/core.rb', line 392

def save_journal
	File.open(config_path(DGIT_SOURCES), "w") { |f| @journal.sources.each { |source| f.puts(source.url) } }
	Oj.to_file(config_path(DGIT_JOURNAL), @journal, indent: 2)
end

#save_optionsvoid

This method returns an undefined value.

Save the options to ‘.dgit/options`



405
406
407
# File 'lib/dgit/core.rb', line 405

def save_options
	Oj.to_file(config_path(DGIT_OPTIONS), options)
end