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

object_patch

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object_patch

  • 0.8.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

ObjectPatch

Please note this project isn't complete in either the generation or application of patches.

ObjectPatch is a pure ruby implementation of RFC6902 (JSON::Patch) for standard hashes, arrays, and scalar types. This will both generate patches as well as apply them.

Rather than restricting end-users to the native JSON library, ObjectPatch only operates on pure Ruby objects. These objects can be converted to a proper JSON encoding using the standard JSON library or any other JSON compliant encoder.

The application of patches is based on Hana. I greatly respect tenderlove but disagreed with pieces of his implementation. I could have chosen to make pull requests but since I was going to be extending the scope of the project I decided to create my own project. At the very least it seemed like a fun project to attempt.

The generation of patches attempts to do so in a way to minimize the size of the patch, this is particularily difficult in arrays where the deletion of a single element at the beginning may be hard to distinguish from the changing of multiple values and the removal of the last.

Installation

Add this line to your application's Gemfile:

gem 'object_patch'

And then execute:

$ bundle

Or install it yourself as:

$ gem install object_patch

Usage

TODO: Write usage instructions here

RFC6901

There is one thing that I implemented within this RFC that is either an extension or a violation of the RFC depending on your view of it. The violation specifically is I have allowed negative array addressing (ie -1 is the last element, -2 the second to last, &c). The absolute value of the index can't be greater than or equal to the the length of the array.

RFC6902

One thing to note is that while referencing RFC6902 (JSON::Patch) it came to my attention that the published RFC was missing a section that was part of the accepted revision (specifically the appendix). The revision of the document that was accepted by the IETF can be found here. This was gleaned from the public history of review of the RFC which is available here.

I referenced the draft version 10 for any information available in the appendix and the published version when the information was available there.

Contributing

  1. Fork it
  2. Create your feature branch off of the current develop head (git checkout -b my-new-feature origin/develop)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

I'll respond to all pull requests within two weeks, hopefully in under one.

FAQs

Package last updated on 18 Oct 2013

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