Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

primitive

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

primitive

  • 1.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Primitive

Gem Version CI License: MIT

This library contains the most root objects I found myself re-implementing over and over. It is meant to serve as an abstract base for object modeling a domain.

Installation

To install through Rubygems:

gem install primitive

You can also add this to your Gemfile using:

bundle add primitive

Primitive::Entity

Base class for objects identified by a string value (ID). Extension examples:

class Team < Primitive::Entity
  attr_reader :name

  def initialize(id:, name:)
    super(id)

    @name = name
  end
end

# Not allowing direct manipulation of ID in the case it is controlled by the repository.
class Player < Primitive::Entity
  attr_reader :name

  def initialize(name:)
    super()

    @name = name
  end
end

Several features are now provided by its base-class via the ID attribute:

  • Case-insensitive equality: #eql? and #==
  • Object hashing: #hash
  • Sorting: #<=>
  • Outputting: #to_s

Primitive::Repository

An interface that describes how a repository should function for loading/saving entities. A concrete example (albeit simple) is the Primitive::CompactFile class which leverages YAML for serialization. Note that ID, in this case, is representative of the file path.

Contributing

Development Environment Configuration

Basic steps to take to get this repository compiling:

  1. Install Ruby (check primitive.gemspec for versions supported)
  2. Install bundler (gem install bundler)
  3. Clone the repository (git clone git@github.com:mattruggio/primitive.git)
  4. Navigate to the root folder (cd primitive)
  5. Install dependencies (bundle)

Running Tests

To execute the test suite run:

bin/rspec spec --format documentation

Alternatively, you can have Guard watch for changes:

bin/guard

Also, do not forget to run Rubocop:

bin/rubocop

And auditing the dependencies:

bin/bundler-audit check --update

And Sorbet:

bin/srb

Publishing

Note: ensure you have proper authorization before trying to publish new versions.

After code changes have successfully gone through the Pull Request review process then the following steps should be followed for publishing new versions:

  1. Merge Pull Request into main
  2. Update version.rb using semantic versioning
  3. Install dependencies: bundle
  4. Update CHANGELOG.md with release notes
  5. Commit & push main to remote and ensure CI builds main successfully
  6. Run bin/rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Code of Conduct

Everyone interacting in this codebase, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

License

This project is MIT Licensed.

FAQs

Package last updated on 23 Jun 2024

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc