Class: ShopifyTheme::Releases

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_theme/releases.rb

Defined Under Namespace

Classes: Release, VersionError

Instance Method Summary collapse

Instance Method Details

#allObject



22
23
24
25
26
27
28
29
# File 'lib/shopify_theme/releases.rb', line 22

def all
  @all ||= begin
    versioned_releases.reduce({'master' => master, 'latest' => latest}) do |all, release|
      all[release.version] = release
      all
    end
  end
end

#fetch!Object



16
17
18
19
20
# File 'lib/shopify_theme/releases.rb', line 16

def fetch!
  response = HTTParty.get(FEED_URL)
  raise "Could not retrieve feed from #{FEED_URL}" if response.code != 200
  @feed = RSS::Parser.parse(response.body)
end

#find(version) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/shopify_theme/releases.rb', line 31

def find(version)
  release = all[version]
  if release.nil?
    error = [
      "Invalid version '#{version}'.",
      "Valid versions are:",
    ].concat(all.keys.map{|v| "  #{v}"})
    raise VersionError, error.join("\n")
  end
  release
end