Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (8.3%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

Basic Info
  • Host: GitHub
  • Owner: firstdraft
  • License: mit
  • Language: HTML
  • Default Branch: main
  • Size: 176 KB
Statistics
  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created 7 months ago · Last pushed 7 months ago
Metadata Files
Readme Changelog License Citation

README.md

Normalized Match

CI Gem Version Ruby Style Guide Coverage Status

A normalized string matcher for RSpec that ignores case, punctuation, and some whitespace differences.

Installation

Add this line to your application's Gemfile:

ruby gem "normalized_match"

And then execute:

$ bundle install

Or install it yourself as:

$ gem install normalized_match

Usage

```ruby require "normalized_match"

RSpec.describe "My test" do it "matches strings normalized" do actual = "Hello, World!" expected = "hello world"

expect(actual).to normalized_match(expected)

end end ```

The normalized_match matcher normalizes both strings by:

  • Converting to lowercase.
  • Removing all punctuation.
  • Collapsing internal whitespace (multiple spaces/tabs become single spaces).
  • Preserving line breaks for multi-line comparisons.
  • Stripping leading and trailing whitespace from lines.

When a match fails, it displays a helpful side-by-side comparison table showing both the normalized and original values.

Using Heredocs

When testing output that contains multiple lines, you can use Ruby's squiggly heredoc (<<~) to maintain nice indentation in your test files while automatically stripping leading whitespace:

```ruby RSpec.describe "Letter counter" do it "displays the letter count analysis" do # Your actual output might come from a method, script, etc. actual = run_codeblock(filename)

# Use squiggly heredoc for expected output
# This strips leading whitespace while preserving internal formatting
expected = <<~EXPECTED
  Letter count:
  H: 1
  e: 1
  l: 3
  o: 2
  W: 1
  r: 1
  d: 1
EXPECTED

expect(actual).to normalized_match(expected)

end end ```

Important: The squiggly heredoc (<<~) technique is especially useful because newlines within the expected content are significant to the matcher. In other words, the above test would not pass if it was written as:

ruby expected = "Letter count: H: 1 e: 1 l: 3 o: 2 W: 1 r: 1 d: 1"

And the actual output was:

Letter count: H: 1 e: 1 l: 3 o: 2 W: 1 r: 1 d: 1

Example Output

When strings don't match after normalization, the matcher displays a helpful table:

``` Normalized match failed!

To make it easier to match the expected output, we are "normalizing" both the actual output and expected output in this test. That means we lowercased, removed punctuation, and compacted whitespace in both.

But the actual output still doesn't contain the expected output. Can you spot the difference?

╔════════════╦══════════════════╦══════════════════╗ ║ ║ EXPECTED ║ ACTUAL ║ ╠════════════╬══════════════════╬══════════════════╣ ║ NORMALIZED ║ hello world ║ goodbye world ║ ╠════════════╬══════════════════╬══════════════════╣ ║ ORIGINAL ║ Hello, World! ║ Goodbye, World! ║ ╚════════════╩══════════════════╩══════════════════╝ ```

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bin/rake to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/firstdraft/normalized_match.

License

The gem is available as open source under the terms of the MIT License.

Owner

  • Name: firstdraft
  • Login: firstdraft
  • Kind: organization

Citation (CITATION.cff)

cff-version: 1.2.0
message: Please use the following metadata when citing this project in your work.
title: Normalized Match
abstract:
version: 0.0.0
license: Hippocratic-2.1
date-released: 2025-07-19
authors:
  - family-names: Betina
    given-names: Raghu
    affiliation: %<organization_label>s
    orcid: https://orcid.org/
keywords:
 - ruby
repository-code: https://github.com/undefined/normalized_match
repository-artifact: https://rubygems.org/gems/normalized_match
url: https://undefined.io/projects/normalized_match

GitHub Events

Total
  • Push event: 7
  • Create event: 3
Last Year
  • Push event: 7
  • Create event: 3

Packages

  • Total packages: 1
  • Total downloads:
    • rubygems 372 total
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
  • Total maintainers: 5
rubygems.org: normalized_match

A normalized string matcher for RSpec that ignores case, punctuation, and whitespace differences

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 372 Total
Rankings
Dependent packages count: 14.3%
Dependent repos count: 43.9%
Average: 50.3%
Downloads: 92.8%
Last synced: 6 months ago

Dependencies

.github/workflows/ci.yml actions
  • actions/checkout v4 composite
  • actions/upload-artifact v4 composite
  • ruby/setup-ruby v1 composite
Gemfile rubygems
  • amazing_print ~> 1.8 development
  • debug ~> 1.10 development
  • git-lint ~> 9.0 development
  • irb-kit ~> 1.1 development
  • rake ~> 13.2 development
  • repl_type_completor ~> 0.1 development
  • rspec ~> 3.13 development
  • simplecov ~> 0.22 development
  • standard ~> 1.0 development
normalized_match.gemspec rubygems
  • rspec ~> 3.0