Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 2.19 KB

File metadata and controls

42 lines (30 loc) · 2.19 KB

AllTheHTTPs — Architecture Guide

Overview

A parody Ruby gem that randomly selects from installed HTTP client libraries for each request. The module name is AllTheHTTPs (capital HTTP, lowercase s). File names use snake_case all_the_https per Ruby convention.

Structure

  • lib/all_the_https.rb — Main entry point. Defines convenience methods (.get, .post, etc.) that delegate to a shared Client instance.
  • lib/all_the_https/version.rb — Gem version constant.
  • lib/all_the_https/response.rb — Normalized response object with status, body, headers, adapter_used, and success?.
  • lib/all_the_https/client.rb — Core logic. Discovers available adapters, randomly selects one per request, excludes GET-only adapters from non-GET requests.
  • lib/all_the_https/adapters/ — One file per HTTP client library (11 total). Each adapter implements adapter_name, display_name, available?, and request.

Adapter Contract

Every adapter class must implement:

  • .adapter_name — Returns a Symbol identifier (e.g., :net_http)
  • .display_name — Human-readable name for the announcement (e.g., "Net::HTTP")
  • .available? — Attempts require, returns true/false
  • .request(method, url, headers: {}, body: nil) — Executes the request, returns AllTheHTTPs::Response

Key Behaviors

  • Lazy loading: Adapters call require inside available? and rescue LoadError
  • GET-only filtering: OpenURI is excluded from non-GET request pools
  • Announcement: Each request prints which adapter was chosen to stdout
  • Stdlib fallback: Net::HTTP and OpenURI are always available as a baseline

Testing

  • Uses RSpec + WebMock
  • Adapter specs skip themselves if their gem isn't installed (skip "X not installed" unless described_class.available?)
  • Client/module specs force a known adapter via allow(...).to receive(:available_adapters) for determinism
  • AllTheHTTPs.reset! is called in before(:each) to clear memoization

Conventions

  • Module: AllTheHTTPs (not AllTheHttps)
  • Files: all_the_https (snake_case)
  • All adapters are class methods (no instances needed)
  • Response is a simple value object (no behavior beyond success? and inspect)