Socket
Book a DemoInstallSign in
Socket

ruckt

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ruckt

0.1.1
bundlerRubygems
Version published
Maintainers
1
Created
Source

Ruckt

Gem Version RSpec Coverage Status

A flexible, type-safe struct generator for Ruby that automatically infers and creates Ruby Struct-like classes from arbitrary data sources with runtime type validation.

Features

  • Dynamic Struct Generation: Classes auto-created from hashes/data samples
  • Type Safety: Runtime type validation for all attributes
  • Nested Structures: Automatic handling of nested hashes
  • Query Methods: Automatic boolean attribute methods (e.g., active?)
  • Clear Error Messages: Descriptive errors for type mismatches

Installation

Add this line to your application's Gemfile:

gem 'ruckt'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install ruckt

Usage

Basic Example

require 'ruckt'

# Create a struct from a hash
data = {
  name: "Dave",
  age: 40,
  active: true
}

user = Ruckt.new(data)

# Access attributes
user.name      # => "Dave"
user.age       # => 40
user.active?   # => true

# Set attributes
user.name = "John"  # => works fine
user.age = "forty"  # => raises TypeError

Nested Structures

data = {
  name: "Dave",
  location: {
    city: "Sheffield",
    postcode: "S2"
  }
}

person = Ruckt.new(data)

# Access nested attributes
person.location.city      # => "Sheffield"
person.location.postcode  # => "S2"

# Type validation works for nested structures too
person.location.city = 123  # => raises TypeError

Development

After checking out the repo, run bundle install to install dependencies. Then, run rake spec to run the tests.

To install this gem onto your local machine, run bundle exec rake install.

Please ensure that any additions are fully covered by RSpec.

Contributing

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

License

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

FAQs

Package last updated on 27 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.