bin/fetch-telegram-methods in telegram-bot-0.16.1 vs bin/fetch-telegram-methods in telegram-bot-0.16.3

- old
+ new

@@ -1,14 +1,16 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + # # Fetch list of methods from Telegram docs. # Use it to update client.rb. require 'net/http' require 'nokogiri' -DOCS_URL = 'https://core.telegram.org/bots/api'.freeze +DOCS_URL = 'https://core.telegram.org/bots/api' page_html = Net::HTTP.get(URI(DOCS_URL)) doc = Nokogiri::HTML(page_html) # Select `h4`s, but use `h3`s to group them. @@ -16,14 +18,14 @@ chunk_while { |_, x| x.name == 'h4' }. map { |g| g.select { |x| x.name == 'h4' } }. map { |g| g.map(&:text) } # Method starts with lowercase and does not have spaces. -NOT_METHOD_REGEXP = /(\A[^a-z])|\s/ +NOT_METHOD_REGEXP = /(\A[^a-z])|\s/.freeze # Filter method names. method_list = headers. - map { |g| g.reject { |x| x.match?(NOT_METHOD_REGEXP) } }. + map { |g| g.grep_v(NOT_METHOD_REGEXP) }. reject(&:empty?) api_version = doc.text.match(/^(?:Introducing )?(Bot API ([\d\.]+))\.?$/) result = ['# Generated with bin/fetch-telegram-methods']