Sha256: 7a142725d5e84ea570a2147ab24bc1434effdd1743c33d8f4d0cd0e57f8fb2ba
Contents?: true
Size: 1.02 KB
Versions: 48
Compression:
Stored size: 1.02 KB
Contents
require 'active_support/concern' require 'active_support/core_ext/array/wrap' require 'active_support/inflector' require 'yaml' # Provides methods relating to persisting commit metadata module CommitMetadataPersistable extend ActiveSupport::Concern included do attr_accessor :commit end private def load_last_commit_data load_hash_matching(*commit.parents.map(&:oid))[:payload] end def load_current_commit_data load_hash_matching(commit.oid)[:payload] end def load_hash_matching(*commits) match = Array.wrap(YAML.load_file(filename)). detect { |h| commits.include? h[:commit] } match || {} rescue Errno::ENOENT {} end def save_current_commit_data(data) hashes = [ load_hash_matching(*commit.parents.map(&:oid)), { commit: commit.oid, payload: data } ].reject(&:blank?) File.write(filename, YAML.dump(hashes)) end def filename "rake_ci.#{name}.yml" end def name self.class.name.demodulize.underscore.sub(/_helper\z/, '') end end
Version data entries
48 entries across 48 versions & 1 rubygems