Class: Diggit::Analysis Abstract

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

Overview

This class is abstract.

Subclass and override run and clean to implement a custom analysis class.

Base class for Diggit analyses. Diggit analyses are applied on each source that has been succesfully cloned. They can access the Diggit addons through the addons attribute.

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, repo, options, addons, globs) ⇒ Analysis

Create a new analysis.

Parameters:

  • source (String)

    the URL of the source to be analyzed.

  • repo (Rugged::Repository)

    the Rugged Repository object corresponding to the source.

  • options (Hash)

    a hash containing the Diggit options.

  • addons (Hash{Symbol => Addon})

    a hash containing the loaded Diggit addons, indexed by names.

  • globs (Hash)

    a hash shared between all analyses of a source.



64
65
66
67
68
69
70
# File 'lib/diggit_core.rb', line 64

def initialize(source, repo, options, addons, globs)
  @source = source
  @repo = repo
  @options = options
  @addons = addons
  @globs = globs
end

Instance Attribute Details

#addonsHash{Symbol => Addon} (readonly)

Returns a hash containing the loaded Diggit addons, indexed by names.

Returns:

  • (Hash{Symbol => Addon})

    a hash containing the loaded Diggit addons, indexed by names.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/diggit_core.rb', line 55

class Analysis

  # Create a new analysis.
  #
  # @param source [String] the URL of the source to be analyzed.
  # @param repo [Rugged::Repository] the Rugged Repository object corresponding to the source.
  # @param options [Hash] a hash containing the Diggit options.
  # @param addons [Hash{Symbol => Addon}] a hash containing the loaded Diggit addons, indexed by names.
  # @param globs [Hash] a hash shared between all analyses of a source.
  def initialize(source, repo, options, addons, globs)
    @source = source
    @repo = repo
    @options = options
    @addons = addons
    @globs = globs
  end

  # Run the analysis.
  # @abstract
  def run
    raise NoMethodError.new "Subclass responsability"
  end

  # Clean the data produced by the analysis.
  # @abstract
  def clean
    raise NoMethodError.new "Subclass responsability"
  end

end

#globsHash

Returns a hash shared between all analyses of a source.

Returns:

  • (Hash)

    a hash shared between all analyses of a source.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/diggit_core.rb', line 55

class Analysis

  # Create a new analysis.
  #
  # @param source [String] the URL of the source to be analyzed.
  # @param repo [Rugged::Repository] the Rugged Repository object corresponding to the source.
  # @param options [Hash] a hash containing the Diggit options.
  # @param addons [Hash{Symbol => Addon}] a hash containing the loaded Diggit addons, indexed by names.
  # @param globs [Hash] a hash shared between all analyses of a source.
  def initialize(source, repo, options, addons, globs)
    @source = source
    @repo = repo
    @options = options
    @addons = addons
    @globs = globs
  end

  # Run the analysis.
  # @abstract
  def run
    raise NoMethodError.new "Subclass responsability"
  end

  # Clean the data produced by the analysis.
  # @abstract
  def clean
    raise NoMethodError.new "Subclass responsability"
  end

end

#optionsHash (readonly)

Returns a hash containing the Diggit options.

Returns:

  • (Hash)

    a hash containing the Diggit options.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/diggit_core.rb', line 55

class Analysis

  # Create a new analysis.
  #
  # @param source [String] the URL of the source to be analyzed.
  # @param repo [Rugged::Repository] the Rugged Repository object corresponding to the source.
  # @param options [Hash] a hash containing the Diggit options.
  # @param addons [Hash{Symbol => Addon}] a hash containing the loaded Diggit addons, indexed by names.
  # @param globs [Hash] a hash shared between all analyses of a source.
  def initialize(source, repo, options, addons, globs)
    @source = source
    @repo = repo
    @options = options
    @addons = addons
    @globs = globs
  end

  # Run the analysis.
  # @abstract
  def run
    raise NoMethodError.new "Subclass responsability"
  end

  # Clean the data produced by the analysis.
  # @abstract
  def clean
    raise NoMethodError.new "Subclass responsability"
  end

end

#repoRugged::Repository (readonly)

Returns the Rugged Repository object corresponding to the source.

Returns:

  • (Rugged::Repository)

    the Rugged Repository object corresponding to the source.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/diggit_core.rb', line 55

class Analysis

  # Create a new analysis.
  #
  # @param source [String] the URL of the source to be analyzed.
  # @param repo [Rugged::Repository] the Rugged Repository object corresponding to the source.
  # @param options [Hash] a hash containing the Diggit options.
  # @param addons [Hash{Symbol => Addon}] a hash containing the loaded Diggit addons, indexed by names.
  # @param globs [Hash] a hash shared between all analyses of a source.
  def initialize(source, repo, options, addons, globs)
    @source = source
    @repo = repo
    @options = options
    @addons = addons
    @globs = globs
  end

  # Run the analysis.
  # @abstract
  def run
    raise NoMethodError.new "Subclass responsability"
  end

  # Clean the data produced by the analysis.
  # @abstract
  def clean
    raise NoMethodError.new "Subclass responsability"
  end

end

#sourceString (readonly)

Returns the URL of the source to be analyzed.

Returns:

  • (String)

    the URL of the source to be analyzed.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/diggit_core.rb', line 55

class Analysis

  # Create a new analysis.
  #
  # @param source [String] the URL of the source to be analyzed.
  # @param repo [Rugged::Repository] the Rugged Repository object corresponding to the source.
  # @param options [Hash] a hash containing the Diggit options.
  # @param addons [Hash{Symbol => Addon}] a hash containing the loaded Diggit addons, indexed by names.
  # @param globs [Hash] a hash shared between all analyses of a source.
  def initialize(source, repo, options, addons, globs)
    @source = source
    @repo = repo
    @options = options
    @addons = addons
    @globs = globs
  end

  # Run the analysis.
  # @abstract
  def run
    raise NoMethodError.new "Subclass responsability"
  end

  # Clean the data produced by the analysis.
  # @abstract
  def clean
    raise NoMethodError.new "Subclass responsability"
  end

end

Instance Method Details

#cleanObject

This method is abstract.

Clean the data produced by the analysis.



80
81
82
# File 'lib/diggit_core.rb', line 80

def clean
  raise NoMethodError.new "Subclass responsability"
end

#runObject

This method is abstract.

Run the analysis.



74
75
76
# File 'lib/diggit_core.rb', line 74

def run
  raise NoMethodError.new "Subclass responsability"
end