Class: GitMiner::Engine::RubyEngine

Inherits:
AbstractEngine show all
Defined in:
lib/git_miner/engine/ruby_engine.rb

Constant Summary collapse

IDENTIFIER =
"Ruby"

Instance Method Summary collapse

Methods inherited from AbstractEngine

#initialize

Constructor Details

This class inherits a constructor from GitMiner::Engine::AbstractEngine

Instance Method Details

#mine(author_offset:, committer_offset:, qty:) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/git_miner/engine/ruby_engine.rb', line 12

def mine(author_offset:, committer_offset:, qty:)
  qty.times do
    current_sha = generate_sha(author_offset, committer_offset)

    if current_sha.start_with?(@prefix)
      return MiningResult.new(
        sha: current_sha,
        author_offset: author_offset,
        committer_offset: committer_offset,
      )
    end

    committer_offset += 1
    if committer_offset > author_offset
      author_offset += 1
      committer_offset = 0
    end
  end

  nil
end

#sha1(str) ⇒ Object



8
9
10
# File 'lib/git_miner/engine/ruby_engine.rb', line 8

def sha1(str)
  Digest::SHA1.hexdigest(str)
end