Sha256: 5e61d5bc37fe041552a1aaef11f2ad596c3e0f0105a282dfccc523086a19dd2a

Contents?: true

Size: 1.08 KB

Versions: 17

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module YKPod
  module YKExchangeTool
    require 'cocoapods-ykutility/tools/yk_log_tool'
    require 'file_exists'
    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

17 entries across 17 versions & 1 rubygems

Version Path
cocoapods-ykutility-3.0.4 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-3.0.3 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-3.0.2 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-3.0.1 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-3.0.0 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-2.0.9 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-2.0.8 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-2.0.7 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-2.0.6 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-2.0.5 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-2.0.4 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-2.0.3 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-2.0.2 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-2.0.1 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-2.0.0 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-1.0.2 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb
cocoapods-ykutility-1.0.1 lib/cocoapods-ykutility/command/create/yk_exchange_tool.rb