Class: Gem::Tasks::Sign::Checksum
- 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
-
#md5 ⇒ Boolean
writeonly
Enables or disables MD5 checksums.
-
#sha1 ⇒ Boolean
writeonly
Enables or disables SHA1 checksums.
-
#sha2 ⇒ Boolean
writeonly
Enables or disables SHA2 checksums.
-
#sha512 ⇒ Boolean
writeonly
Enables or disables SHA512 checksums.
Attributes inherited from Task
Instance Method Summary collapse
-
#define ⇒ Object
Defines the
sign:checksumtasks. -
#initialize(md5: true, sha1: true, sha2: false, sha512: false) {|_self| ... } ⇒ Checksum
constructor
Initializes the
sign:checksumtask. -
#md5? ⇒ Boolean
Specifies whether MD5 checksums are enabled.
-
#sha1? ⇒ Boolean
Specifies whether SHA1 checksums are enabled.
-
#sha2? ⇒ Boolean
Specifies whether SHA2 checksums are enabled.
-
#sha512? ⇒ Boolean
Specifies whether SHA512 checksums are enabled.
-
#sign(path) ⇒ Object
Prints the checksums of a package.
Methods inherited from Task
#bundle, #gem, #gemspec_tasks, #invoke, #namespaced_tasks, #run, #task?
Methods included from Printing
Constructor Details
#initialize(md5: true, sha1: true, sha2: false, sha512: false) {|_self| ... } ⇒ Checksum
Initializes the sign:checksum task.
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.
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.
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.
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.
33 34 35 |
# File 'lib/rubygems/tasks/sign/checksum.rb', line 33 def sha512=(value) @sha512 = value end |
Instance Method Details
#define ⇒ Object
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.
67 |
# File 'lib/rubygems/tasks/sign/checksum.rb', line 67 def md5?; @md5; end |
#sha1? ⇒ Boolean
Specifies whether SHA1 checksums are enabled.
74 |
# File 'lib/rubygems/tasks/sign/checksum.rb', line 74 def sha1?; @sha1; end |
#sha2? ⇒ Boolean
Specifies whether SHA2 checksums are enabled.
81 |
# File 'lib/rubygems/tasks/sign/checksum.rb', line 81 def sha2?; @sha2; end |
#sha512? ⇒ Boolean
Specifies whether SHA512 checksums are enabled.
88 |
# File 'lib/rubygems/tasks/sign/checksum.rb', line 88 def sha512?; @sha512; end |
#sign(path) ⇒ Object
Prints the checksums of a 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 |