Sha256: 2e4bd2c4667111c99f34f37bec11ad241c5a51649ac38563408b7e7c4c76651b

Contents?: true

Size: 918 Bytes

Versions: 1

Compression:

Stored size: 918 Bytes

Contents

require 'digest'
module Pod
  class Command
    class Bin < Command
      class GetChecksum < Bin
        self.summary = '根据输入的podfile路径返回该podfile对应checksum(类似文件MD5值)'
        self.description = <<-DESC
          #{summary}
        DESC

        def self.options
          [
            %w[--path=podfile路径]
          ].concat(super).uniq
        end

        def initialize(argv)
          @path = argv.option('path', "")
          super
        end

        def run
          puts calculate_checksum(@path)
        end
        # 计算checksum值
        def calculate_checksum(file_path)
          return "" unless File.exist?(file_path)
          content = File.read(file_path)
          checksum = Digest::SHA1.hexdigest(content)
          checksum = checksum.encode('UTF-8') if checksum.respond_to?(:encode)
          return checksum
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cocoapods-meitu-bin-1.2.0 lib/cocoapods-meitu-bin/command/bin/get_checksum.rb