clsx-ruby 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 043652e6d2bc00c77d0409b45cb15f361cd1fb417af14db62892be42ed2a1815
4
- data.tar.gz: dbacda2ec82ed045800345914fec73339d1dfee64df87e33305a5a8b5cf7c118
3
+ metadata.gz: 3f20a56982120e4142d5932688887cc7f4b38a3596e01ce8aacf1f7b5b15f8d4
4
+ data.tar.gz: ebbd199c2d2ad139c2dda52680953778092b21708e01aef7b09d4619d932333a
5
5
  SHA512:
6
- metadata.gz: 26c9443192380c6b8415923df85df04d78add5cead6a676d78739410261cbeb277f8e6c4856b15761355dd61becfc09ad6aec7870d530f78bb5d3fcfbd358893
7
- data.tar.gz: 919462b5126de045d8a2b1d63ef5e3da4fb04156ef62c9c3e4985922d05dd041997fcbc473f1aab7495d61914e87b09cdf88b2f1448f0fb80b8c3c3006115763
6
+ metadata.gz: 5ed8a104aac715ac054d3399f6cf0c6e15a1b5a2df6307218c5f31172ebe7c1aca261d24b8b7ed23e3a06974002c2c1b9af7f857b4a4ebf4e90eea3694e75050
7
+ data.tar.gz: 83a0ea7711cab8e01b9eb8f71376af34e51d21bbbbd7da6091e1abe323d4145228c6e8ed44ec13f6421670ad1685a7857c531e198c100e553f77771d4183db45
data/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## v1.1.2
11
+
12
+ ### Changed
13
+
14
+ - Improved gemspec description and README marketing copy
15
+ - Switched gemspec to whitelist approach for included files
16
+
10
17
  ## v1.1.1
11
18
 
12
19
  ### Added
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # clsx-ruby [![Gem Version](https://img.shields.io/gem/v/clsx-ruby)](https://rubygems.org/gems/clsx-ruby) [![Codecov](https://img.shields.io/codecov/c/github/svyatov/clsx-ruby)](https://app.codecov.io/gh/svyatov/clsx-ruby) [![CI](https://github.com/svyatov/clsx-ruby/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/svyatov/clsx-ruby/actions?query=workflow%3ACI) [![GitHub License](https://img.shields.io/github/license/svyatov/clsx-ruby)](LICENSE.txt)
2
2
 
3
- > The fastest Ruby utility for constructing CSS class strings conditionally. Perfect for Tailwind CSS utility classes. Zero dependencies.
3
+ > The fastest, framework-agnostic conditional CSS class builder for Ruby.
4
+ > Perfect for ViewComponent, Phlex, Tailwind CSS or just standalone.
4
5
 
5
- Ruby port of the JavaScript [clsx](https://github.com/lukeed/clsx) package — a faster, smarter alternative to Rails `class_names`. Works with Rails, Sinatra, Hanami, or plain Ruby.
6
+ Inspired by the JavaScript [clsx](https://github.com/lukeed/clsx) package. Works with any Ruby codebase.
6
7
 
7
8
  ## Quick Start
8
9
 
@@ -25,11 +26,15 @@ Clsx['btn', 'btn-primary', active: is_active, disabled: is_disabled]
25
26
  # => "btn btn-primary active" (when is_active is truthy, is_disabled is falsy)
26
27
  ```
27
28
 
29
+ ## Rails Integration
30
+
31
+ For Rails integration (adds `clsx` and `cn` helpers to all views), see [clsx-rails](https://github.com/svyatov/clsx-rails).
32
+
28
33
  ## Why clsx-ruby?
29
34
 
30
35
  ### Blazing fast
31
36
 
32
- **38x faster** than Rails `class_names` across every scenario:
37
+ **3-8x faster** than Rails `class_names` across every scenario:
33
38
 
34
39
  | Scenario | clsx-ruby | Rails `class_names` | Speedup |
35
40
  |---|---|---|---|
@@ -243,10 +248,6 @@ end
243
248
  Clsx['', proc {}, -> {}, nil, false, true] # => nil
244
249
  ```
245
250
 
246
- ## Rails Integration
247
-
248
- For automatic Rails view helper integration (adds `clsx` and `cn` helpers to all views), see [clsx-rails](https://github.com/svyatov/clsx-rails).
249
-
250
251
  ## Development
251
252
 
252
253
  ```bash
data/lib/clsx/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Clsx
4
- VERSION = '1.1.1'
4
+ VERSION = '1.1.2'
5
5
  end
metadata CHANGED
@@ -1,15 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clsx-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Svyatov
8
- bindir: exe
8
+ bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
- description: A tiny utility for constructing CSS class strings conditionally
12
+ description: Build CSS class strings from conditional expressions, hashes, arrays,
13
+ or nested structures. Framework-agnostic. Perfect for ViewComponent, Phlex, and
14
+ Tailwind CSS. Works with any Ruby codebase.
13
15
  email:
14
16
  - leonid@svyatov.com
15
17
  executables: []
@@ -17,7 +19,6 @@ extensions: []
17
19
  extra_rdoc_files: []
18
20
  files:
19
21
  - CHANGELOG.md
20
- - CLAUDE.md
21
22
  - LICENSE.txt
22
23
  - README.md
23
24
  - lib/clsx.rb
@@ -46,5 +47,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
47
  requirements: []
47
48
  rubygems_version: 4.0.6
48
49
  specification_version: 4
49
- summary: clsx / classnames for Ruby
50
+ summary: The fastest conditional CSS class builder for Ruby
50
51
  test_files: []
data/CLAUDE.md DELETED
@@ -1,138 +0,0 @@
1
- # CLAUDE.md
2
-
3
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
-
5
- ## Project Overview
6
-
7
- clsx-ruby is a Ruby gem that provides a utility (`clsx`/`cn`) for constructing CSS class strings conditionally. It's a Ruby port of the JavaScript [clsx](https://github.com/lukeed/clsx) package, adapted for Ruby conventions. Framework-agnostic — works with Rails, Sinatra, Hanami, or plain Ruby.
8
-
9
- ## Common Commands
10
-
11
- ```bash
12
- # Run all tests and linting (default rake task)
13
- bundle exec rake
14
-
15
- # Run tests only
16
- bundle exec rake test
17
-
18
- # Run a single test file
19
- bundle exec ruby -Itest test/clsx/helper_test.rb
20
-
21
- # Run a specific test method
22
- bundle exec ruby -Itest test/clsx/helper_test.rb -n test_with_strings
23
-
24
- # Run linter
25
- bundle exec rake rubocop
26
-
27
- # Run benchmark
28
- bundle exec ruby benchmark/run.rb
29
-
30
- # Install dependencies
31
- bin/setup
32
-
33
- # Release a new version (update version.rb first)
34
- # Builds gem, creates git tag, pushes to rubygems.org
35
- # OTP is fetched automatically from 1Password
36
- bundle exec rake release
37
- ```
38
-
39
- ## Architecture
40
-
41
- The gem has a minimal structure:
42
-
43
- - `lib/clsx.rb` - Entry point; extends `Clsx` with `Helper`, defines `Clsx[]` and `Cn[]` shortcuts
44
- - `lib/clsx/helper.rb` - Core implementation with `clsx` method and `cn` alias
45
- - `lib/clsx/version.rb` - Version constant
46
-
47
- ### API
48
-
49
- - **`Clsx['foo', bar: true]`** — primary bracket API via `self.[]`
50
- - **`Cn['foo', bar: true]`** — short alias (defined only if `Cn` constant is not taken)
51
- - **`Clsx.clsx(...)`** / **`Clsx.cn(...)`** — module methods
52
- - **`include Clsx::Helper`** — mixin giving `clsx()` and `cn()` instance methods
53
-
54
- The helper uses an optimized algorithm with fast-paths for common cases (single string, string array, simple hash) and Hash-based deduplication for complex inputs.
55
-
56
- ## Key Behaviors
57
-
58
- - Returns `nil` (not empty string) when no classes apply — prevents rendering empty `class=""` attributes
59
- - Eliminates duplicate classes automatically
60
- - Ruby falsy values are only `false` and `nil` (unlike JS, `0`, `''`, `[]`, `{}` are truthy)
61
- - Ignores `Proc`/lambda objects and boolean `true` values
62
- - Supports complex hash keys like `{ %w[foo bar] => true }` which resolve recursively
63
-
64
- ## Benchmarking
65
-
66
- `benchmark/original.rb` contains the **previous version** of the algorithm for comparison. It must always reflect the last committed version from the main branch — not some ancient baseline.
67
-
68
- **Rule:** Before making any algorithm or performance change to `lib/clsx/helper.rb`, copy the current main-branch implementation into `benchmark/original.rb` (wrapping in `module ClsxOriginal` — method names stay the same, no renaming needed). This ensures `bundle exec ruby benchmark/run.rb` compares the new code against its immediate predecessor, giving meaningful before/after numbers.
69
-
70
- ## Commit Convention
71
-
72
- This project follows [Conventional Commits v1.0.0](https://www.conventionalcommits.org/en/v1.0.0/).
73
-
74
- Format: `<type>[optional scope]: <description>`
75
-
76
- ### Types
77
-
78
- | Type | Description | Version bump |
79
- |------|-------------|--------------|
80
- | `feat` | New feature | MINOR |
81
- | `fix` | Bug fix | PATCH |
82
- | `docs` | Documentation only | — |
83
- | `style` | Formatting, whitespace | — |
84
- | `refactor` | Code change (no feature/fix) | — |
85
- | `perf` | Performance improvement | — |
86
- | `test` | Adding/fixing tests | — |
87
- | `build` | Build system or dependencies | — |
88
- | `ci` | CI configuration | — |
89
- | `chore` | Maintenance tasks | — |
90
-
91
- ### Breaking Changes
92
-
93
- Use `!` after type or add `BREAKING CHANGE:` footer. Breaking changes trigger a MAJOR version bump.
94
-
95
- ## Changelog Format
96
-
97
- This project follows [Keep a Changelog v1.1.0](https://keepachangelog.com/en/1.1.0/).
98
-
99
- Allowed categories in **required order**:
100
-
101
- 1. **Added** — new features
102
- 2. **Changed** — changes to existing functionality
103
- 3. **Deprecated** — soon-to-be removed features
104
- 4. **Removed** — removed features
105
- 5. **Fixed** — bug fixes
106
- 6. **Security** — vulnerability fixes
107
-
108
- Rules:
109
- - Categories must appear in the order listed above within each release section
110
- - Each category must appear **at most once** per release section — always append to an existing category rather than creating a duplicate
111
- - Do NOT use non-standard categories like "Updated", "Internal", or "Breaking changes"
112
- - Breaking changes should be prefixed with **BREAKING:** within the relevant category (typically Changed or Removed)
113
-
114
- `CHANGELOG.md` must stay current on every feature branch. After each commit, ensure the `## Unreleased` section at the top accurately reflects all user-facing changes on the branch. Add the section if it doesn't exist. Keep entries concise — one bullet per logical change. On release, the `## Unreleased` heading gets replaced with the version number.
115
-
116
- The unreleased section describes the **net result** compared to the last release, not a history of intermediate steps. When a later change supersedes an earlier one, update or remove the stale bullet — don't accumulate entries that no longer reflect reality.
117
-
118
- ## Documentation Style
119
-
120
- All classes and methods must have YARD documentation. Follow these conventions:
121
-
122
- - Always leave a **blank line** between the main description and `@` attributes (params, return, etc.)
123
- - Document all public methods with description, params, and return types
124
- - Document all private methods with params and return types, add description for complex logic
125
- - Include `@example` blocks for non-obvious usage patterns
126
- - **Omit descriptions that just repeat the code** — if the method name and signature make it obvious, only include `@param`, `@return` tags without a description
127
-
128
- ## Releasing a New Version
129
-
130
- This project follows [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html):
131
- - **MAJOR** — breaking changes (incompatible API changes)
132
- - **MINOR** — new features (backwards-compatible)
133
- - **PATCH** — bug fixes (backwards-compatible)
134
-
135
- 1. Update `lib/clsx/version.rb` with the new version number
136
- 2. Update `CHANGELOG.md`: change `## Unreleased` to `## vX.Y.Z` and add new empty `## Unreleased` section
137
- 3. Commit changes: `chore: bump version to X.Y.Z`
138
- 4. Release: `bundle exec rake release`