Sha256: 497b4408b67ca88f1eca8eb0e2ca3be9cb7d45fa3e72f06d5ddfd647e79e6fd4

Contents?: true

Size: 1.58 KB

Versions: 15

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

require "bundler/gem_tasks"

require "rspec/core/rake_task"
RSpec::Core::RakeTask.new

require "rubocop/rake_task"
RuboCop::RakeTask.new

require "yardstick/rake/measurement"
Yardstick::Rake::Measurement.new do |measurement|
  measurement.output = "measurement/report.txt"
end

require "yardstick/rake/verify"
Yardstick::Rake::Verify.new do |verify|
  verify.require_exact_threshold = false
  verify.threshold = 55
end

task :generate_status_codes do
  require "http"
  require "nokogiri"

  url = "http://www.iana.org/assignments/http-status-codes/http-status-codes.xml"
  xml = Nokogiri::XML HTTP.get url
  arr = xml.xpath("//xmlns:record").reduce([]) do |a, e|
    code = e.xpath("xmlns:value").text.to_s
    desc = e.xpath("xmlns:description").text.to_s

    next a if %w[Unassigned (Unused)].include?(desc)

    a << "#{code} => #{desc.inspect}"
  end

  File.open("./lib/http/response/status/reasons.rb", "w") do |io|
    io.puts <<~TPL
      # AUTO-GENERATED FILE, DO NOT CHANGE IT MANUALLY

      require "delegate"

      module HTTP
        class Response
          class Status < ::Delegator
            # Code to Reason map
            #
            # @example Usage
            #
            #   REASONS[400] # => "Bad Request"
            #   REASONS[414] # => "Request-URI Too Long"
            #
            # @return [Hash<Fixnum => String>]
            REASONS = {
              #{arr.join ",\n              "}
            }.each { |_, v| v.freeze }.freeze
          end
        end
      end
    TPL
  end
end

task :default => %i[spec rubocop verify_measurements]

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
direct7-0.0.18 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/Rakefile
direct7-0.0.17 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/Rakefile
direct7-0.0.16 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/Rakefile
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/http-5.2.0/Rakefile
direct7-0.0.13 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/Rakefile
direct7-0.0.12 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/Rakefile
http-5.2.0 Rakefile
direct7-0.0.11 vendor/bundle/ruby/2.7.0/gems/http-5.1.1/Rakefile
http-5.1.1 Rakefile
http-5.1.0 Rakefile
http-5.0.4 Rakefile
http-5.0.3 Rakefile
http-5.0.2 Rakefile
http-5.0.1 Rakefile
http-5.0.0 Rakefile