Module: MetadataHandler

Included in:
Describe
Defined in:
lib/get/subcommand/describe/metadata.rb

Overview

Module with methods to handle tag metadata.

To add a new metadata type, create a new method and link it to a symbol.

Constant Summary collapse

@@metadata_computers =
{}

Class Method Summary collapse

Class Method Details

.compute_metadata(metadata_specs) ⇒ Object



43
44
45
46
47
48
# File 'lib/get/subcommand/describe/metadata.rb', line 43

def ()
  
    .split(',')
    .map { |element| @@metadata_computers[element.to_sym].call }
    .join('-')
end

.current_dateObject



32
33
34
# File 'lib/get/subcommand/describe/metadata.rb', line 32

def current_date
  Time.now.strftime('%0Y%0m%0d')
end

.included(_mod) ⇒ Object



50
51
52
# File 'lib/get/subcommand/describe/metadata.rb', line 50

def self.included(_mod)
  init_computers
end

.init_computersObject



36
37
38
39
# File 'lib/get/subcommand/describe/metadata.rb', line 36

def init_computers
  @@metadata_computers[:sha] = proc { last_commit_sha }
  @@metadata_computers[:date] = proc { current_date }
end

.last_commit_shaObject



28
29
30
# File 'lib/get/subcommand/describe/metadata.rb', line 28

def last_commit_sha
  `git --no-pager log -n 1 --pretty=%h`.strip
end