Skip to content

Commit a25657d

Browse files
authored
Merge pull request #1615 from git/book-release-asset-names
book2: match ebook release assets by name, not content-type
2 parents 1b9b54d + 4269034 commit a25657d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/tasks/book2.rake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,17 @@ task remote_genbook2: :environment do
222222

223223
begin
224224
rel = @octokit.latest_release(repo)
225-
get_url = -> (content_type) do
226-
asset = rel.assets.find { |asset| asset.content_type==content_type }
225+
get_url = -> (name_re) do
226+
asset = rel.assets.find { |asset| name_re.match(asset.name) }
227227
if asset
228228
asset.browser_download_url
229229
else
230230
nil
231231
end
232232
end
233-
book.ebook_pdf = get_url.call("application/pdf")
234-
book.ebook_epub = get_url.call("application/epub+zip")
235-
book.ebook_mobi = get_url.call("application/x-mobipocket-ebook")
233+
book.ebook_pdf = get_url.call(/\.pdf$/)
234+
book.ebook_epub = get_url.call(/\.epub$/)
235+
book.ebook_mobi = get_url.call(/\.mobi$/)
236236
rescue Octokit::NotFound
237237
book.ebook_pdf = nil
238238
book.ebook_epub = nil

0 commit comments

Comments
 (0)