Sha256: f6a90ae9dd9f97817a544720a6e5f5eea6322b6beba27608ebebe542a31f2d29

Contents?: true

Size: 1.71 KB

Versions: 24

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 = 58
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

24 entries across 24 versions & 1 rubygems

Version Path
http-0.9.6 Rakefile
http-0.9.5 Rakefile
http-0.9.4 Rakefile
http-0.9.3 Rakefile
http-0.8.14 Rakefile
http-0.9.2 Rakefile
http-0.8.13 Rakefile
http-0.9.1 Rakefile
http-0.9.0 Rakefile
http-0.9.0.pre Rakefile
http-0.8.12 Rakefile
http-0.8.11 Rakefile
http-0.8.10 Rakefile
http-0.8.9 Rakefile
http-0.8.8 Rakefile
http-0.8.7 Rakefile
http-0.8.6 Rakefile
http-0.8.5 Rakefile
http-0.8.4 Rakefile
http-0.8.3 Rakefile