Class: Gem::Commands::ChecksumCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::ChecksumCommand
- Defined in:
- lib/rubygems/commands/checksum_command.rb
Instance Method Summary collapse
- #arguments ⇒ Object
- #description ⇒ Object
- #execute ⇒ Object
-
#initialize ⇒ ChecksumCommand
constructor
A new instance of ChecksumCommand.
- #usage ⇒ Object
Constructor Details
#initialize ⇒ ChecksumCommand
Returns a new instance of ChecksumCommand.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rubygems/commands/checksum_command.rb', line 5 def initialize super 'checksum', 'Calculate the checksum for a gem' add_option('--compare-to', 'Boolean compare to the generated checksum') do |value, | [:compare_to] = value end add_option('--checksum-folder', 'Folder to write generated checksum to') do |value, | [:checksum_folder] = value end end |
Instance Method Details
#arguments ⇒ Object
22 23 24 |
# File 'lib/rubygems/commands/checksum_command.rb', line 22 def arguments "GEM_NAME the name of the gem you wish to hash" end |
#description ⇒ Object
30 31 32 33 34 |
# File 'lib/rubygems/commands/checksum_command.rb', line 30 def description <<END Calculcates the checksum for a gem END end |
#execute ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rubygems/commands/checksum_command.rb', line 36 def execute gem_path = next_optional_arg fail "No .gem path passed in" if gem_path.nil? checker = GemChecksum::Checker.new(gem_path) say checksum = checker.generate_checksum say checker.write_checksum(next_optional_arg) if [:checksum_folder] if [:compare_to] compare_to = next_optional_arg if checker.validate_checksum(compare_to) say "Checksum validated" else say "Calculated checksum not equal to given checksum: " << "\nExpected:\t#{compare_to}\nCalculcated:\t#{checksum}" end end end |
#usage ⇒ Object
26 27 28 |
# File 'lib/rubygems/commands/checksum_command.rb', line 26 def usage "#{program_name} GEM_NAME" end |