Class: Hbc::DSL::Appcast

Inherits:
Object
  • Object
show all
Defined in:
Library/Homebrew/cask/lib/hbc/dsl/appcast.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, **parameters) ⇒ Appcast

Returns a new instance of Appcast



8
9
10
11
12
# File 'Library/Homebrew/cask/lib/hbc/dsl/appcast.rb', line 8

def initialize(uri, **parameters)
  @uri        = URI(uri)
  @parameters = parameters
  @checkpoint = parameters[:checkpoint]
end

Instance Attribute Details

#checkpointObject (readonly)

Returns the value of attribute checkpoint



6
7
8
# File 'Library/Homebrew/cask/lib/hbc/dsl/appcast.rb', line 6

def checkpoint
  @checkpoint
end

#parametersObject (readonly)

Returns the value of attribute parameters



6
7
8
# File 'Library/Homebrew/cask/lib/hbc/dsl/appcast.rb', line 6

def parameters
  @parameters
end

#uriObject (readonly)

Returns the value of attribute uri



6
7
8
# File 'Library/Homebrew/cask/lib/hbc/dsl/appcast.rb', line 6

def uri
  @uri
end

Instance Method Details

#calculate_checkpointObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'Library/Homebrew/cask/lib/hbc/dsl/appcast.rb', line 14

def calculate_checkpoint
  curl_executable, *args = curl_args(
    "--compressed", "--location", "--fail", uri,
    user_agent: :fake
  )
  result = SystemCommand.run(curl_executable, args: args, print_stderr: false)

  checkpoint = if result.success?
    processed_appcast_text = result.stdout.gsub(%r{<pubDate>[^<]*</pubDate>}m, "")
    Digest::SHA2.hexdigest(processed_appcast_text)
  end

  {
    checkpoint: checkpoint,
    command_result: result,
  }
end

#to_sObject



36
37
38
# File 'Library/Homebrew/cask/lib/hbc/dsl/appcast.rb', line 36

def to_s
  uri.to_s
end

#to_yamlObject



32
33
34
# File 'Library/Homebrew/cask/lib/hbc/dsl/appcast.rb', line 32

def to_yaml
  [uri, parameters].to_yaml
end