Class: GitMiner::Core
- Inherits:
-
Object
- Object
- GitMiner::Core
- Defined in:
- lib/git_miner/core.rb
Instance Method Summary collapse
- #alter ⇒ Object
-
#initialize(engine:, dispatch:, prefix:) ⇒ Core
constructor
A new instance of Core.
- #mine ⇒ Object
- #report ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(engine:, dispatch:, prefix:) ⇒ Core
Returns a new instance of Core.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/git_miner/core.rb', line 3 def initialize(engine:, dispatch:, prefix:) GitMiner.logger.info("Initializing") GitMiner.logger.debug("- Prefix: #{prefix}") GitMiner.logger.debug("- Engine: #{engine::IDENTIFIER}") GitMiner.logger.debug("- Dispatch: #{dispatch::IDENTIFIER}") @prefix = prefix @now = Time.now.utc @engine = engine.new( prefix: @prefix, now: @now, ) @dispatch = dispatch.new( prefix: @prefix, engine: @engine ) end |
Instance Method Details
#alter ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/git_miner/core.rb', line 62 def alter raise "Prerequisite: Require mining to be completed first" unless @mining_result = @now - @mining_result. committer_date = @now - @mining_result.committer_offset GitMiner.logger.debug("Amending git") GitUtil.update_current_ref(, committer_date) GitMiner.logger.info("New SHA: #{@mining_result.sha}") end |
#mine ⇒ Object
48 49 50 51 52 |
# File 'lib/git_miner/core.rb', line 48 def mine GitMiner.logger.info("Mining for SHA: #{@prefix}") @mining_result = @dispatch.execute end |
#report ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/git_miner/core.rb', line 54 def report raise "Prerequisite: Require mining to be completed first" unless @mining_result GitMiner.logger.debug("Mining completed.") GitMiner.logger.debug("Author offset: #{@mining_result.}") GitMiner.logger.debug("Committer offset: #{@mining_result.committer_offset}") end |
#validate ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/git_miner/core.rb', line 25 def validate str = "Test content" expected = "bca20547e94049e1ffea27223581c567022a5774" current = @engine.sha1(str) unless expected == current = <<~ERROR Invalid sha computation logic Expected: #{expected} (#{expected.size}) Generated: #{current} (#{current.size}) ERROR raise() end unless @prefix[/^[0-9a-f]{1,32}$/] raise(UserError, "Invalid prefix, expected '^[0-9a-f]{1,32}$'") end GitMiner.logger.debug("Prefix validation: Accepted") end |