Class: Dragnet::Exporters::IDGenerator
- Inherits:
-
Object
- Object
- Dragnet::Exporters::IDGenerator
- Includes:
- Helpers::RepositoryHelper
- Defined in:
- lib/dragnet/exporters/id_generator.rb
Overview
Generates unique IDs for the Manual Test Records by hashing some of their properties into a hexadecimal SHA1.
Instance Attribute Summary collapse
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
Instance Method Summary collapse
-
#id_for(test_record) ⇒ String
Calculates the ID of the given MTR :reek:FeatureEnvy (Cannot be done in the TestRecord itself because it needs the Repository).
-
#initialize(repository) ⇒ IDGenerator
constructor
A new instance of IDGenerator.
Methods included from Helpers::RepositoryHelper
#relative_to_repo, #repo_base, #shorten_sha1
Constructor Details
#initialize(repository) ⇒ IDGenerator
Returns a new instance of IDGenerator.
19 20 21 |
# File 'lib/dragnet/exporters/id_generator.rb', line 19 def initialize(repository) @repository = repository end |
Instance Attribute Details
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
14 15 16 |
# File 'lib/dragnet/exporters/id_generator.rb', line 14 def repository @repository end |
Instance Method Details
#id_for(test_record) ⇒ String
Calculates the ID of the given MTR :reek:FeatureEnvy (Cannot be done in the TestRecord itself because it needs the Repository)
28 29 30 31 32 |
# File 'lib/dragnet/exporters/id_generator.rb', line 28 def id_for(test_record) string = "#{relative_to_repo(test_record.source_file)}#{test_record.id}" # noinspection RubyMismatchedReturnType (This is never nil) Digest::SHA1.hexdigest(string)[0...16] end |