Sha256: bfa992eff2000bafad16abc3ea5108cbfa0909792d029aef8d435db8c971c148

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module YKPod
  module YKExchangeTool
    require 'cocoapods-ykutility/tools/yk_log_tool'
    include YKPod::YKLogTool
    def updateFileDirs(rootDir, keyWord, destWord)
      Dir.glob("#{rootDir}/**/**/**/**").each do |name|
        next if File.directory?(name) == false
        name_new = name.gsub(keyWord, destWord)
        FileUtils.mv(name, name_new) unless name_new == name
      end

      # 改文件名

      fileArr = []
      Dir.glob("#{rootDir}/**/**/**/**").each do |name|
        next if Dir.exists? name

        name_new = name.gsub(keyWord, destWord)
        FileUtils.mv(name, name_new) unless name_new == name
        fileArr.append(name_new)
      end

      return fileArr
    end

    def updateFiles(file_arr, key_map)
      file_arr.each do |one|
        onefile = File.read one
        key_map.each do |key, dest|
          if key.blank? or dest.blank?
            next
          end
          onefile.gsub!(key, dest)
        end

        File.open(one, "w") { |file| file.puts onefile }
      end
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cocoapods-ykutility-0.0.17 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-0.0.16 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-0.0.15 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-0.0.14 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-0.0.13 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb