Class: Hbc::CLI::InternalAppcastCheckpoint

Inherits:
AbstractInternalCommand show all
Defined in:
Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb

Instance Attribute Summary

Attributes inherited from AbstractCommand

#args

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractInternalCommand

command_name, visible

Methods inherited from AbstractCommand

abstract?, command_name, run, visible

Methods included from Options

included, #process_arguments

Constructor Details

#initializeInternalAppcastCheckpoint

Returns a new instance of InternalAppcastCheckpoint



6
7
8
9
# File 'Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb', line 6

def initialize(*)
  super
  raise CaskUnspecifiedError if args.empty?
end

Class Method Details

.appcask_checkpoint(casks, calculate) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb', line 26

def self.appcask_checkpoint(casks, calculate)
  casks.each do |cask|
    if cask.appcast.nil?
      opoo "Cask '#{cask}' is missing an `appcast` stanza."
    else
      checkpoint = if calculate
        result = cask.appcast.calculate_checkpoint
        result[:checkpoint]
      else
        cask.appcast.checkpoint
      end

      if calculate && checkpoint.nil?
        onoe "Could not retrieve `appcast` checkpoint for cask '#{cask}': #{result[:command_result].stderr}"
      elsif casks.count > 1
        puts "#{checkpoint}  #{cask}"
      else
        puts checkpoint
      end
    end
  end
end

.appcask_checkpoint_for_url(urls) ⇒ Object



19
20
21
22
23
24
# File 'Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb', line 19

def self.appcask_checkpoint_for_url(urls)
  urls.each do |url|
    appcast = DSL::Appcast.new(url)
    puts appcast.calculate_checkpoint[:checkpoint]
  end
end

.helpObject



49
50
51
# File 'Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb', line 49

def self.help
  "prints or calculates a given Cask's or URL's appcast checkpoint"
end

.needs_init?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb', line 53

def self.needs_init?
  true
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
# File 'Library/Homebrew/cask/lib/hbc/cli/internal_appcast_checkpoint.rb', line 11

def run
  if args.all? { |t| t =~ %r{^https?://} && t !~ /\.rb$/ }
    self.class.appcask_checkpoint_for_url(args)
  else
    self.class.appcask_checkpoint(casks, calculate?)
  end
end