Class: Docman::Builders::GitProviderBuilder
- Inherits:
-
ProviderBuilder
- Object
- Hash
- Command
- Builder
- ProviderBuilder
- Docman::Builders::GitProviderBuilder
- Defined in:
- lib/docman/builders/git_provider_builder.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
- #build_with_provider ⇒ Object
- #changed_from_last_version? ⇒ Boolean
- #execute ⇒ Object
- #prepare_build_dir ⇒ Object
Methods inherited from ProviderBuilder
Methods inherited from Builder
#changed?, #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
#build_with_provider ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/docman/builders/git_provider_builder.rb', line 11 def build_with_provider docman_ignore_var = "DOCMAN_IGNORE" if ENV.has_key? docman_ignore_var and ENV[docman_ignore_var].length > 0 puts "Variable #{docman_ignore_var} => #{ENV[docman_ignore_var]}. Use ignore workflow." ignore = ['.git'] ignore_value = ENV[docman_ignore_var] ignore_array = ignore_value.split(":") ignore_array.each do |item| ignore.push(item) end ignore.uniq! find_ignore_array = [] ignore.each do |item| find_ignore_array.push("^#{File.join(@context['full_build_path'], item).gsub('.', '\.')}/.*$") path = '' item.split("/").each do |part| path = File.join(path, part) find_ignore_array.push("^#{File.join(@context['full_build_path'], path).gsub('.', '\.')}$") end end find_ignore = "-e \"#{find_ignore_array.join("\" -e \"")}\"" puts "FIND IGNORE => #{find_ignore}" `find #{@context['full_build_path']} -mindepth 1 -print0 | grep -z -v #{find_ignore} | xargs -0 -r -t rm -rf` if File.directory? @context['full_build_path'] FileUtils.rm_r self['target_path'] if @context.need_rebuild? and File.directory? self['target_path'] result = @provider.perform rsync_ignore_array = ignore.each do |item| "--exclude \"#{item}\"" end rsync_ignore = "--exclude=\"/#{rsync_ignore_array.join("\" --exclude=\"/")}\"" puts "RSYNC IGNORE => #{rsync_ignore}" `rsync -a #{rsync_ignore} #{self['target_path']}/. #{@context['full_build_path']}` else puts "Variable #{docman_ignore_var} not found. Use standard workflow." `find #{@context['full_build_path']} -mindepth 1 -maxdepth 1 -not -name '.git' -exec rm -rf {} \\;` if File.directory? @context['full_build_path'] FileUtils.rm_r self['target_path'] if @context.need_rebuild? and File.directory? self['target_path'] result = @provider.perform `rsync -a --exclude '.git' #{self['target_path']}/. #{@context['full_build_path']}` end result end |
#changed_from_last_version? ⇒ Boolean
59 60 61 |
# File 'lib/docman/builders/git_provider_builder.rb', line 59 def changed_from_last_version? @provider.changed_from_last_version? end |
#execute ⇒ Object
63 64 65 66 67 |
# File 'lib/docman/builders/git_provider_builder.rb', line 63 def execute prepare_build_dir @execute_result = build_with_provider changed_from_last_version? ? @execute_result : false end |
#prepare_build_dir ⇒ Object
7 8 9 |
# File 'lib/docman/builders/git_provider_builder.rb', line 7 def prepare_build_dir FileUtils.mkdir_p(@context['full_build_path']) end |