Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Opera Next Cask #747

Merged
merged 1 commit into from
Jul 13, 2013
Merged

Add Opera Next Cask #747

merged 1 commit into from
Jul 13, 2013

Conversation

joeyhoer
Copy link
Contributor

Add Opera Next cask which grabs the URL of the 'latest' version from the Opera Next website. The string &ext=.dmg is being appended to the URL to allow Cask to add the proper file extension to the downloaded file; this may be considered a bug in Cask.

May also pertain to #142.

Add Opera Next cask which grabs the URL of the 'latest' version from the Opera Next website. The string `&ext=.dmg` is being appended to the URL to allow Cask to add the proper file extension to the downloaded file.
nanoxd added a commit that referenced this pull request Jul 13, 2013
@nanoxd nanoxd merged commit 7535173 into Homebrew:master Jul 13, 2013
@@ -0,0 +1,7 @@
class OperaNext < Cask
url 'http://www.opera.com' << %x( curl -Ls 'http://www.opera.com/download/get/?partner=www&opsys=MacOS&product=Opera%20Next' | grep '/download/' | head -1 | perl -pe 's/.*'\\''(\\/.*)'\\''.*/$1/' | tr -d '\n' ) << '&amp;ext=.dmg'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm 👎 on this because it fires a curl request off every time the cask is evaluated. This includes brew cask list brew cask search brew cask info etc. If you're off a network for those commands, you're gonna have a bad time.

What we'd need to support dynamic URLs would be lazy URL definitions. Something like this.

class Foo < Cask
  url {
    # whatever ruby code you need to yield a proper URL
    "http://example.com/#{rand(1000)}"
  }
end

class Cask
  # optional string argument or block
  def self.url(url=nil, &block)
    @url = block || url
  end

  def url
    @url ||= @@url
    @url = @url.call if @url.is_a? Proc
  end
end

Obviously with less ugly cvar/ivar interaction. 😉

@joeyhoer
Copy link
Contributor Author

That didn't occur to me, but I totally agree that something like that is necessary. The advantage (as noted in #390) of using Ruby, rather than a static data structure, is to provide this type of flexibility. If we could leverage a similar technique for more casks, we could develop a system that requires less maintenance by delegating the responsibility of maintaining current links to the individual applications/developers. This would be especially valuable for applications that are updated frequently like WebKit Nightly and others.

One possible scenario is that the application is updated, but the 'latest' link is not. In this situation, we would simply need to update the cask's URL to point to the latest version (i.e. the most prevalent method of maintaining a cask's URL at the moment).

@Homebrew Homebrew locked and limited conversation to collaborators May 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants