{"action":"created","issue":{"url":"https://api.github.com/repos/caskroom/homebrew-cask/issues/22014","repository_url":"https://api.github.com/repos/caskroom/homebrew-cask","labels_url":"https://api.github.com/repos/caskroom/homebrew-cask/issues/22014/labels{/name}","comments_url":"https://api.github.com/repos/caskroom/homebrew-cask/issues/22014/comments","events_url":"https://api.github.com/repos/caskroom/homebrew-cask/issues/22014/events","html_url":"https://github.com/caskroom/homebrew-cask/pull/22014","id":160533240,"number":22014,"title":"Introduce block syntax for `url` stanza","user":{"login":"claui","id":1239874,"avatar_url":"https://avatars.githubusercontent.com/u/1239874?v=3","gravatar_id":"","url":"https://api.github.com/users/claui","html_url":"https://github.com/claui","followers_url":"https://api.github.com/users/claui/followers","following_url":"https://api.github.com/users/claui/following{/other_user}","gists_url":"https://api.github.com/users/claui/gists{/gist_id}","starred_url":"https://api.github.com/users/claui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/claui/subscriptions","organizations_url":"https://api.github.com/users/claui/orgs","repos_url":"https://api.github.com/users/claui/repos","events_url":"https://api.github.com/users/claui/events{/privacy}","received_events_url":"https://api.github.com/users/claui/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/caskroom/homebrew-cask/labels/awaiting%20maintainer%20feedback","name":"awaiting maintainer feedback","color":"ffdc00"},{"url":"https://api.github.com/repos/caskroom/homebrew-cask/labels/core","name":"core","color":"b10dc9"},{"url":"https://api.github.com/repos/caskroom/homebrew-cask/labels/enhancement","name":"enhancement","color":"0074d9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-06-15T21:55:36Z","updated_at":"2016-06-18T19:45:30Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/caskroom/homebrew-cask/pulls/22014","html_url":"https://github.com/caskroom/homebrew-cask/pull/22014","diff_url":"https://github.com/caskroom/homebrew-cask/pull/22014.diff","patch_url":"https://github.com/caskroom/homebrew-cask/pull/22014.patch"},"body":"### Changes to the core\r\n\r\n- [x] Followed [hacking.md](https://github.com/caskroom/homebrew-cask/blob/master/doc/development/hacking.md).\r\n\r\n___\r\n\r\n## Issue\r\n\r\nSome providers use disposable URLs, which need to be constructed from some sort of landing site ([recent example](https://github.com/caskroom/homebrew-cask/pull/21952#issuecomment-225855234)). Doing such expensive things in the middle of a Cask definition [has proven difficult](https://github.com/caskroom/homebrew-versions/pull/293#issuecomment-48755213) in the past. Loading a Cask would become unacceptably slow if HTTP/S requests were done in Cask definitions.\r\n\r\n## Solution\r\n\r\nAlbeit rarely, such cases do pop up every now and then; so I decided to write this PR, which introduces an **optional block syntax** for the `url` stanza:\r\n\r\n```rb\r\nurl do\r\n  # No known stable URL; fetching disposable URL from landing site\r\n  open('https://example.com/app/landing') do |landing_page|\r\n    content = landing_page.read\r\n    parse(content) # => https://example.com/download?23309800482283\r\n  end\r\nend\r\n```\r\n\r\nThe block is only evaluated when needed, for example on download time or when auditing a Cask. It is never evaluated when loading a Cask.\r\n\r\nThe return value of the block is either a `String`, or a `String, Hash` tuple; the latter case is for additional options such as `referrer`.\r\n\r\n## Implementation note\r\n\r\nFor `stanza_proxy.rb`, I could have used `SimpleDelegator` but it turned out to be much faster to roll my own logic.\r\n\r\nThe proxy is designed to be easily reused for other stanzas if needed.\r\n\r\n## Credits\r\n\r\nThanks @tobadia for contributing the regex/`open-uri` snippet in `audacity.rb`, which also triggered the idea for this PR.\r\n\r\n## Feedback\r\n\r\nPinging @caskroom/maintainers for opinions (and for suggestions to improve my convoluted English in the docs). Thanks!\r\n"},"comment":{"url":"https://api.github.com/repos/caskroom/homebrew-cask/issues/comments/226961389","html_url":"https://github.com/caskroom/homebrew-cask/pull/22014#issuecomment-226961389","issue_url":"https://api.github.com/repos/caskroom/homebrew-cask/issues/22014","id":226961389,"user":{"login":"vitorgalvao","id":1699443,"avatar_url":"https://avatars.githubusercontent.com/u/1699443?v=3","gravatar_id":"","url":"https://api.github.com/users/vitorgalvao","html_url":"https://github.com/vitorgalvao","followers_url":"https://api.github.com/users/vitorgalvao/followers","following_url":"https://api.github.com/users/vitorgalvao/following{/other_user}","gists_url":"https://api.github.com/users/vitorgalvao/gists{/gist_id}","starred_url":"https://api.github.com/users/vitorgalvao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vitorgalvao/subscriptions","organizations_url":"https://api.github.com/users/vitorgalvao/orgs","repos_url":"https://api.github.com/users/vitorgalvao/repos","events_url":"https://api.github.com/users/vitorgalvao/events{/privacy}","received_events_url":"https://api.github.com/users/vitorgalvao/received_events","type":"User","site_admin":false},"created_at":"2016-06-18T19:45:30Z","updated_at":"2016-06-18T19:45:30Z","body":"I wonder in which fun way `cask-repair` will blow up with these casks. I’ll likely just make it abort if it finds a cask with a block `url`."}}
{"actor":{"display_login":"vitorgalvao"}}