Class: Docman::ComponentsTagger

Inherits:
Taggers::Tagger show all
Defined in:
lib/docman/taggers/components_tagger.rb

Instance Attribute Summary

Attributes inherited from Command

#type

Instance Method Summary collapse

Methods inherited from Taggers::Tagger

create, #initialize, register_tagger

Methods inherited from Command

#add_action, #add_actions, #config, create, #describe, #initialize, #perform, #prefix, register_command, #replace_placeholder, #run_actions, #run_with_hooks

Methods included from Logging

#log, logger, #logger, #prefix, #properties_info, #with_logging

Constructor Details

This class inherits a constructor from Docman::Taggers::Tagger

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/docman/taggers/components_tagger.rb', line 8

def execute
  tag = ''
  time = Time.now.strftime("%Y-%m-%d-%H-%M-%S")
  state = @caller['state']
  if @caller.docroot_config.structure['root']['type'] == 'root'
    tag_parts = []
    tag_parts << "#{state}--#{time}"
    @caller.build_results.each { |component_name, component_build_result|
      unless component_name == 'master'
        tag_parts << "#{component_name}-#{component_build_result['version']}"
      end
    }
    tag = tag_parts.join('--')
  else
    if @caller.build_results['master']['version_type'] == 'tag'
      tag = "#{state}--#{@caller.build_results['master']['version']}"
    else
      tag = "#{state}--#{time}--#{@caller.build_results['master']['version']}"
    end
  end
  tag_sliced = tag.slice(0, 250).slice(/^(.+)[^a-zA-Z0-9]*$/, 1)
  tag_sliced
end