lib/rim/module_helper.rb in esr-rim-1.4.0 vs lib/rim/module_helper.rb in esr-rim-1.4.2

- old
+ new

@@ -1,57 +1,57 @@ -require 'rim/processor' -require 'rim/rim_exception' -require 'rim/rim_info' -require 'rim/file_helper' -require 'rim/dirty_check' - -module RIM - -class ModuleHelper < Processor - - attr_reader :module_info - - def initialize(workspace_root, module_info, logger) - super(workspace_root, logger) - @module_info = module_info - @remote_url = get_absolute_remote_url(@module_info.remote_url) if @module_info.remote_url - @remote_path = remote_path(@module_info.remote_url) if @module_info.remote_url - @logger = logger - end - -protected - - # fetch module +mod+ into the .rim folder - # works both for initial fetch and updates - def fetch_module - FileUtils.mkdir_p git_path - RIM::git_session(git_path) do |s| - if !File.exist?(git_path + "/config") - s.execute("git clone --mirror #{@remote_url} #{git_path}") do |out, e| - raise RimException.new("Remote repository '#{@remote_url}' of module '#{@module_info.local_path}' not found.") if e - end - else - s.execute("git remote update") - end - end - git_path - end - - # prepare empty folder: remove all files not on the ignore list and empty folders - def prepare_empty_folder(local_path, ignores) - ignores = FileHelper.find_matching_files(local_path, true, ignores) - FileHelper.find_matching_files(local_path, true, "/**/*", File::FNM_DOTMATCH).each do |f| - if File.file?(f) && !ignores.include?(f) - FileUtils.rm(f) - end - end - FileHelper.remove_empty_dirs(local_path) - FileUtils.mkdir_p(local_path) - end - - def git_path - module_git_path(@remote_path) - end - -end - -end +require 'rim/processor' +require 'rim/rim_exception' +require 'rim/rim_info' +require 'rim/file_helper' +require 'rim/dirty_check' + +module RIM + +class ModuleHelper < Processor + + attr_reader :module_info + + def initialize(workspace_root, module_info, logger) + super(workspace_root, logger) + @module_info = module_info + @remote_url = get_absolute_remote_url(@module_info.remote_url) if @module_info.remote_url + @remote_path = remote_path(@module_info.remote_url) if @module_info.remote_url + @logger = logger + end + +protected + + # fetch module +mod+ into the .rim folder + # works both for initial fetch and updates + def fetch_module + FileUtils.mkdir_p git_path + RIM::git_session(git_path) do |s| + if !File.exist?(git_path + "/config") + s.execute("git clone --mirror #{@remote_url} #{git_path}") do |out, e| + raise RimException.new("Remote repository '#{@remote_url}' of module '#{@module_info.local_path}' not found.") if e + end + else + s.execute("git remote update") + end + end + git_path + end + + # prepare empty folder: remove all files not on the ignore list and empty folders + def prepare_empty_folder(local_path, ignores) + ignores = FileHelper.find_matching_files(local_path, true, ignores) + FileHelper.find_matching_files(local_path, true, "/**/*", File::FNM_DOTMATCH).each do |f| + if File.file?(f) && !ignores.include?(f) + FileUtils.rm(f) + end + end + FileHelper.remove_empty_dirs(local_path) + FileUtils.mkdir_p(local_path) + end + + def git_path + module_git_path(@remote_path) + end + +end + +end