Class: Docman::CleanChangedCmd

Inherits:
Command
  • Object
show all
Defined in:
lib/docman/commands/clean_changed_cmd.rb

Instance Attribute Summary

Attributes inherited from Command

#type

Instance Method Summary collapse

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

#executeObject

TODO: Keep files feature



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/docman/commands/clean_changed_cmd.rb', line 12

def execute
  if File.directory? @context['full_build_path']
    if @context.need_rebuild?
      return false if @context['type'] == 'dir'
      return false if @context['type'] == 'root' and @context['build_type'] == :dir_builder and not GitUtil.repo?(@context['full_build_path'])
      return false if @context['type'] == 'root' and @context['build_type'] == :git_direct_builder and GitUtil.repo?(@context['full_build_path'])
      if @context['type'] == 'repo'
        if @context['build_type'] == :git_direct_builder
          return false if GitUtil.repo?(@context['full_build_path'])
        end
      end
      log("Remove #{@context['full_build_path']}")
      FileUtils.rm_rf @context['full_build_path']
    end
  end
end

#validate_commandObject



6
7
8
9
# File 'lib/docman/commands/clean_changed_cmd.rb', line 6

def validate_command
  raise "Please provide 'context'" if @context.nil?
  raise "Context should be of type 'Info'" unless @context.is_a? Docman::Info
end