Class: DeltaTest::Stats
- Inherits:
-
Object
- Object
- DeltaTest::Stats
- Defined in:
- lib/delta_test/stats.rb
Constant Summary collapse
- TABLE_FILENAME_TPL =
'%s.table'.freeze
- TABLE_FILENAME_PATTERN =
'*.table'.freeze
Instance Attribute Summary collapse
-
#base_git ⇒ Object
readonly
Returns the value of attribute base_git.
-
#stats_git ⇒ Object
readonly
Returns the value of attribute stats_git.
Instance Method Summary collapse
- #base_commit ⇒ Object
- #commit_dir ⇒ Object
-
#initialize(head: false) ⇒ Stats
constructor
A new instance of Stats.
- #table_file_path ⇒ Object
Constructor Details
Instance Attribute Details
#base_git ⇒ Object (readonly)
Returns the value of attribute base_git.
6 7 8 |
# File 'lib/delta_test/stats.rb', line 6 def base_git @base_git end |
#stats_git ⇒ Object (readonly)
Returns the value of attribute stats_git.
7 8 9 |
# File 'lib/delta_test/stats.rb', line 7 def stats_git @stats_git end |
Instance Method Details
#base_commit ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/delta_test/stats.rb', line 19 def base_commit return @base_commit if defined?(@base_commit) if @head @base_commit = @base_git.rev_parse('HEAD') else indexes = @stats_git.ls_files .map { |f| f.split('/').take(2).join('') } .to_set @base_commit = @base_git.ls_hashes(DeltaTest.config.stats_life) .find { |h| indexes.include?(h) } end @base_commit end |
#commit_dir ⇒ Object
36 37 38 39 40 41 |
# File 'lib/delta_test/stats.rb', line 36 def commit_dir return unless base_commit return @commit_dir if defined?(@commit_dir) @commit_dir = DeltaTest.config.stats_path.join(*base_commit.unpack('A2A*')) end |
#table_file_path ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/delta_test/stats.rb', line 43 def table_file_path return unless commit_dir return @table_file_path if defined?(@table_file_path) if @head @table_file_path = commit_dir.join(TABLE_FILENAME_TPL % [DeltaTest.tester_id]) else file = Dir.glob(commit_dir.join(TABLE_FILENAME_PATTERN)).max do |f| File.basename(f).split('-').take(2).join('.').to_f end @table_file_path = file @table_file_path = Pathname.new(file) if file end @table_file_path end |