Class: Docman::Builders::GitStripBuilder

Inherits:
Builder show all
Defined in:
lib/docman/builders/git_strip_builder.rb

Instance Attribute Summary

Attributes inherited from Command

#type

Instance Method Summary collapse

Methods inherited from Builder

#config, create, #describe, #prefix, register_builder, #validate_command, #version

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::Command

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
# File 'lib/docman/builders/git_strip_builder.rb', line 17

def changed?
  stored_version = @context.stored_version['result']
  @version = GitUtil.get(@context['repo'], @context['temp_path'], @context.version_type, @context.version, nil, nil)
  stored_version != @version
end

#executeObject



7
8
9
10
11
12
13
14
15
# File 'lib/docman/builders/git_strip_builder.rb', line 7

def execute
  FileUtils.rm_r(@context['full_build_path']) if File.directory? @context['full_build_path']
  FileUtils.rm_r @context['temp_path'] if @context.need_rebuild? and File.directory? @context['temp_path']
  @version = GitUtil.get(@context['repo'], @context['temp_path'], @context.version_type, @context.version, nil, nil)
  FileUtils.mkdir_p(@context['full_build_path'])
  FileUtils.cp_r(Dir["#{@context['temp_path']}/."], @context['full_build_path'])
  FileUtils.rm_r(File.join(@context['full_build_path'], '.git')) if File.directory?(File.join(@context['full_build_path'], '.git'))
  GitUtil.repo_changed?(@context['full_build_path']) ? @version : false
end