Sha256: 6ae7e1be42cb89e580f0efd57613fdd5ef3865e560c1ff6ff69438ba9d019bba

Contents?: true

Size: 1.71 KB

Versions: 23

Compression:

Stored size: 1.71 KB

Contents

#!/usr/bin/env rake
require "bundler/gem_tasks"

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

task :test => :spec

begin
  require "rubocop/rake_task"
  RuboCop::RakeTask.new
rescue LoadError
  task :rubocop do
    $stderr.puts "RuboCop is disabled"
  end
end

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 "Unassigned" == desc || "(Unused)" == desc

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

  File.open("./lib/http/response/status/reasons.rb", "w") do |io|
    io.puts <<-TPL.gsub(/^[ ]{6}/, "")
      # 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 => [:spec, :rubocop, :verify_measurements]

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
http-2.2.2 Rakefile
http-2.2.1 Rakefile
http-2.2.0 Rakefile
http-2.1.0 Rakefile
http-2.0.3 Rakefile
http-2.0.2 Rakefile
http-2.0.1 Rakefile
http-2.0.0 Rakefile
http-2.0.0.pre Rakefile
http-1.0.4 Rakefile
http-0.9.9 Rakefile
http-1.0.3 Rakefile
http-1.0.2 Rakefile
http-1.0.1 Rakefile
http-1.0.0 Rakefile
http-1.0.0.pre6 Rakefile
http-1.0.0.pre5 Rakefile
http-1.0.0.pre4 Rakefile
http-1.0.0.pre3 Rakefile
http-1.0.0.pre2 Rakefile