Class: Gem::Tasks::Sign::Checksum

Inherits:
Task
  • Object
show all
Defined in:
lib/rubygems/tasks/sign/checksum.rb

Overview

The sign:checksum task.

Constant Summary

Constants included from Printing

Printing::ANSI_BRIGHT, Printing::ANSI_CLEAR, Printing::ANSI_GREEN, Printing::ANSI_RED, Printing::ANSI_YELLOW, Printing::DEBUG_PREFIX, Printing::ERROR_PREFIX, Printing::STATUS_PREFIX

Instance Attribute Summary collapse

Attributes inherited from Task

#project

Instance Method Summary collapse

Methods inherited from Task

#bundle, #gem, #gemspec_tasks, #invoke, #namespaced_tasks, #run, #task?

Methods included from Printing

#debug, #error, #status

Constructor Details

#initialize(md5: true, sha1: true, sha2: false, sha512: false) {|_self| ... } ⇒ Checksum

Initializes the sign:checksum task.

Parameters:

  • md5 (Boolean) (defaults to: true)

    Specifies whether MD5 checksums are enabled.

  • sha1 (Boolean) (defaults to: true)

    Specifies whether SHA1 checksums are enabled.

  • sha2 (Boolean) (defaults to: false)

    Specifies whether SHA2 checksums are enabled.

  • sha512 (Boolean) (defaults to: false)

    Specifies whether SHA512 checksums are enabled.

Yields:

  • (_self)

Yield Parameters:



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rubygems/tasks/sign/checksum.rb', line 50

def initialize(md5: true, sha1: true, sha2: false, sha512: false)
  super()

  @md5    = md5
  @sha1   = sha1
  @sha2   = sha2
  @sha512 = sha512

  yield self if block_given?
  define
end

Instance Attribute Details

#md5=(value) ⇒ Boolean (writeonly)

Enables or disables MD5 checksums.

Returns:

  • (Boolean)


18
19
20
# File 'lib/rubygems/tasks/sign/checksum.rb', line 18

def md5=(value)
  @md5 = value
end

#sha1=(value) ⇒ Boolean (writeonly)

Enables or disables SHA1 checksums.

Returns:

  • (Boolean)


23
24
25
# File 'lib/rubygems/tasks/sign/checksum.rb', line 23

def sha1=(value)
  @sha1 = value
end

#sha2=(value) ⇒ Boolean (writeonly)

Enables or disables SHA2 checksums.

Returns:

  • (Boolean)


28
29
30
# File 'lib/rubygems/tasks/sign/checksum.rb', line 28

def sha2=(value)
  @sha2 = value
end

#sha512=(value) ⇒ Boolean (writeonly)

Enables or disables SHA512 checksums.

Returns:

  • (Boolean)


33
34
35
# File 'lib/rubygems/tasks/sign/checksum.rb', line 33

def sha512=(value)
  @sha512 = value
end

Instance Method Details

#defineObject

Defines the sign:checksum tasks.



93
94
95
96
97
# File 'lib/rubygems/tasks/sign/checksum.rb', line 93

def define
  super(:checksum)

  task :checksum => 'sign:checksum'
end

#md5?Boolean

Specifies whether MD5 checksums are enabled.

Returns:

  • (Boolean)


67
# File 'lib/rubygems/tasks/sign/checksum.rb', line 67

def md5?; @md5; end

#sha1?Boolean

Specifies whether SHA1 checksums are enabled.

Returns:

  • (Boolean)


74
# File 'lib/rubygems/tasks/sign/checksum.rb', line 74

def sha1?; @sha1; end

#sha2?Boolean

Specifies whether SHA2 checksums are enabled.

Returns:

  • (Boolean)


81
# File 'lib/rubygems/tasks/sign/checksum.rb', line 81

def sha2?; @sha2; end

#sha512?Boolean

Specifies whether SHA512 checksums are enabled.

Returns:

  • (Boolean)


88
# File 'lib/rubygems/tasks/sign/checksum.rb', line 88

def sha512?; @sha512; end

#sign(path) ⇒ Object

Prints the checksums of a package.

Parameters:

  • path (String)

    The path to the package.



107
108
109
110
111
112
113
114
115
116
# File 'lib/rubygems/tasks/sign/checksum.rb', line 107

def sign(path)
  status "Checksums for #{File.basename(path)}:"

  puts
  puts "  md5:    #{Digest::MD5.file(path)}"    if @md5
  puts "  sha1:   #{Digest::SHA1.file(path)}"   if @sha1
  puts "  sha2:   #{Digest::SHA2.file(path)}"   if @sha2
  puts "  sha512: #{Digest::SHA512.file(path)}" if @sha512
  puts
end