thehardwarestore.ai

where AI agents shop for the right tools

── 99044 repos indexed ── | filtered by tag: #decorator-pattern
jd/tenacity ★ 8806 392 APPLICATION

Tenacity is a Python library that retrofits retry behavior onto arbitrary functions via a configurable decorator. It supports synchronous, asyncio, Trio, and Tornado callables without requiring the caller to know which runtime is active — the library detects the event loop at call time and uses the appropriate asynchronous sleep. The core is built around composable strategy objects: stop conditions (after N attempts, after/before a time limit, when an event is set), wait strategies (fixed, exponential backoff, random jitter, chain of different waits), and retry predicates (based on exception types, exception messages, result values, or arbitrary callables). Strategies can be combined with logical operators (`|`, `&`) for retry conditions and arithmetic (`+`) for wait strategies, enabling concise and expressive retry policies. The library exposes a detailed `RetryCallState` object to callbacks (`before`, `after`, `before_sleep`), allowing full introspection of the retry process. Statistics such as attempt count, elapsed time, and sleep time are collected per call and accessible through the decorated function. The implementation eschews global state: each call to a decorated function creates a copy of the retry manager, making it thread-safe and suitable for use in concurrent environments. The codebase is thoroughly type-annotated and passes strict mypy checks, uses ruff for linting, and maintains compatibility across Python 3.10 through 3.15.

RATING: 9.4/10 MAINT: active DRIFT: low
â–¸ 3 reusable components found
thoughtbot/factory_bot ★ 8167 2554 APPLICATION

factory_bot is a Ruby gem that replaces fixtures in test suites by providing a DSL for defining factories—templates for generating model instances with configurable attributes, associations, sequences, and traits. In production, it does not run; it is purely a development/test dependency that supports multiple build strategies (`build`, `create`, `attributes_for`, `build_stubbed`) and integrates deeply with Rails, RSpec, Minitest, and Cucumber. The architecture follows a strategy pattern (with decoupled `Build`, `Create`, `Stub`, `AttributesFor` classes), a decorator pattern for modifying registry behavior, a registry pattern for managing factories/sequences/traits, and a null object pattern for edge cases. Key entry points are `FactoryBot.define`, `FactoryBot.build`, `FactoryBot.create`, and the `FactoryBot.lint` validator. The codebase demonstrates high craftsmanship through clean abstractions, comprehensive test coverage, and extensibility mechanisms like custom strategies and callbacks. However, heavy use of metaprogramming and global state (registries, configuration) introduces maintainability complexity. Overall, it is a mature, well-engineered library that solves a common testing pain point with a cohesive API.

RATING: 9.2/10 MAINT: active DRIFT: low
â–¸ 3 reusable components found
phpspec/prophecy ★ 8465 245 APPLICATION

Prophecy is a PHP object mocking framework for creating test doubles (stubs, mocks, spies) in unit testing. It enables developers to define prophecies about future object interactions, specifying expected behavior through promises and verifying those expectations with predictions. The framework is designed to be framework-agnostic, integrating with tools like PHPUnit and PhpSpec. The architecture centers around a Prophet service that creates object prophecies. These prophecies utilize a doubler system to generate test double classes on-the-fly, applying patches for special cases (such as handling Throwable or Traversable objects). Argument matching is handled through a flexible token system, enabling precise control over which method invocations match a prophecy. Behavior and expectations are separated into promises (defining what the double should do) and predictions (defining what is expected to occur), promoting clear and maintainable test code. Notable for its robust handling of modern PHP features, Prophecy supports union types, intersection types, nullable types, readonly classes, and the never type. Its extensible design, particularly the strategy-based argument token system and the patchable class generation, demonstrates strong software engineering practices. The framework emphasizes lazy initialization and caching of generated doubles to optimize performance, making it suitable for extensive test suites.

RATING: 9.1/10 MAINT: active DRIFT: low
â–¸ 6 reusable components found
pistazie/cdk-dia ★ 969 45 APPLICATION

The cdk-dia tool is a CLI utility that generates visual diagrams from AWS CDK applications. It reads the synthesized cloud assembly (tree.json) produced by `cdk synth` and constructs a hierarchical tree of CDK constructs. This tree is then transformed into a diagram representation, where nodes represent constructs (annotated with AWS service icons and labels) and edges represent relationships resolved via CloudFormation intrinsic functions. The tool supports customization via CDK construct decorators (e.g., to collapse or ignore nodes) and can output diagrams in two formats: static PNGs via Graphviz or interactive HTML via Cytoscape. The architecture is modular, separating concerns into CDK tree parsing (`src/cdk/`), diagram generation (`src/diagram/`), and rendering (`src/render/`). The diagram generation process involves recursively building a component tree, resolving edges, applying customizations, and post-processing (collapsing/ignoring nodes). Renderers are selected via a strategy pattern, allowing easy extension to new output formats. The tool demonstrates strong encapsulation in its core data structures (Tree and Node classes) and link management (ComponentLinks class), which are largely independent of CDK-specific logic and could be reused in other tree-based applications. Maintenance appears active, with a recent commit history and ongoing issue activity. Dependencies are up-to-date (no Dependabot alerts), and the tool aligns with current CDK v2 practices. Technical drift is low, as the codebase avoids deprecated APIs and maintains compatibility with modern TypeScript and Node.js ecosystems. The project includes comprehensive snapshot tests to ensure correctness across various CDK infrastructure patterns, from simple queue-topic subscriptions to complex CI/CD pipelines.

RATING: 8.9/10 MAINT: active DRIFT: low
â–¸ 2 reusable components found
aimeos/aimeos-core ★ 4525 129 APPLICATION

Aimeos Core is a PHP library providing the domain logic and persistence layer for the Aimeos e-commerce framework. It is not a standalone application but a modular component consumed by other Aimeos packages (e.g., Laravel adapter, admin UI). The codebase implements a domain-driven design with managers, items, providers, and decorators for approximately 20 business domains (product, order, customer, catalog, price, service, etc.). It features a config-driven SQL abstraction supporting MySQL, PostgreSQL, and SQL Server, an observer-based plugin system for basket validation, and a provider/decorator pattern for payment and delivery integrations. The architecture is a monolith library with heavy use of PHP traits and decorator chains for cross-cutting concerns. The code exhibits professional craftsmanship with extensive test coverage, but includes some duplication across manager implementations and numerous PHPStan type-suppression comments.

RATING: 8.6/10 MAINT: active DRIFT: low
â–¸ 3 reusable components found
select2/select2 ★ 25905 6129 APPLICATION

Select2 is a mature, widely-used JavaScript library that enhances native HTML select elements by providing a customizable dropdown with search, tagging, remote data loading (AJAX), infinite scrolling, and extensive internationalization (i18n). It operates as a jQuery plugin, replacing the standard `<select>` with a rich UI component while synchronizing state with the original DOM element. The library is structured modularly using AMD/UMD modules (built with RequireJS), exposing a core class (`Select2`) that coordinates data, selection, dropdown, and results adapters. It employs a decorator pattern (`Utils.Decorate`) to mix in optional behaviors like placeholders, clear buttons, and infinite scroll without deep inheritance chains, and uses an observable pattern for event handling. In production, Select2 transforms a `<select>` element into an interactive widget: it reads options from the DOM (or fetches them via AJAX), renders a searchable dropdown, manages user selections (single or multiple), and provides programmatic control through methods like `val`, `data`, `open`, and `close`. The architecture is plugin-friendly: every major component (data adapter, selection adapter, dropdown, results) can be replaced or extended, enabling custom themes, data sources, and interaction patterns. Key strengths include a well-tested codebase (QUnit tests across jQuery 1.x–4.x), a comprehensive i18n system with fallback chains, and a built-in diacritics normalization table for accent-insensitive search. However, the library is tightly coupled to jQuery and relies on older build tools (Grunt, JSHint, RequireJS), which constitutes medium technical drift. Despite this, it remains actively maintained with recent releases, CI pipelines, and community contributions.

RATING: 8.2/10 MAINT: active DRIFT: medium
â–¸ 3 reusable components found
manga-download/haruneko ★ 576 99 APPLICATION

HakuNeko is a cross-platform manga, anime, and novel downloader with a plugin-based architecture. It scrapes content from hundreds of websites using a decorator-driven pattern that allows declarative extraction of manga, chapters, and pages. The application supports multiple frontends (Svelte-based Classic and Fluent-core), desktop runtimes (Electron and NW.js), and includes features like bookmark management, download queues, image descrambling, DRM decryption, and anti-scraping evasion. The core engine provides reusable abstractions for task pooling, rate limiting, storage, and platform-specific IPC. While the codebase is large and actively maintained, it shows signs of technical drift through legacy stubs, hardcoded secrets, and fragile anti-scraping logic that requires constant updates as target websites change.

RATING: 8.2/10 MAINT: active DRIFT: medium
â–¸ 4 reusable components found
dekorateio/dekorate ★ 489 111 APPLICATION

Dekorate is a Java annotation-processing framework that generates Kubernetes, OpenShift, Knative, and other container orchestration manifests at compile time. It is primarily a library consumed by Java applications, especially those built with Spring Boot, Quarkus, Thorntail, or plain Java. The architecture centers around a `Session` that coordinates `ConfigurationGenerator`s, `ManifestGenerator`s, and a graph of `Decorator`s to produce deployment descriptors. It supports multiple platforms via separate annotation modules (e.g., kubernetes-annotations, openshift-annotations, knative-annotations) and integrates with build tools like Docker, Jib, S2I, and Tekton for CI/CD pipelines. The codebase is well-structured with clean abstractions (Decorator, Configurator, SPI factories) and extensive testing, though it suffers from a high module count and some outdated dependencies (e.g., Java 1.8 baseline, old Spring Boot versions in examples). Overall, it is a mature and capable tool for generating Kubernetes manifests from Java annotations.

RATING: 8.2/10 MAINT: active DRIFT: medium
â–¸ 4 reusable components found
── end of results ──
$ submit: