{"id":19343511,"url":"https://github.com/hex0cter/clavatar","last_synced_at":"2025-11-09T17:31:50.920Z","repository":{"id":65607849,"uuid":"60971284","full_name":"hex0cter/clavatar","owner":"hex0cter","description":"Apply a hash into a Ruby class and return an instance of it.","archived":false,"fork":false,"pushed_at":"2016-06-20T15:36:30.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-07T14:32:52.220Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/clavatar","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hex0cter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-12T14:25:55.000Z","updated_at":"2016-06-13T19:21:13.000Z","dependencies_parsed_at":"2023-01-31T14:25:12.039Z","dependency_job_id":null,"html_url":"https://github.com/hex0cter/clavatar","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/hex0cter/clavatar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hex0cter%2Fclavatar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hex0cter%2Fclavatar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hex0cter%2Fclavatar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hex0cter%2Fclavatar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hex0cter","download_url":"https://codeload.github.com/hex0cter/clavatar/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hex0cter%2Fclavatar/sbom","scorecard":{"id":462703,"data":{"date":"2025-08-11","repo":{"name":"github.com/hex0cter/clavatar","commit":"4a9aa117937e018200d17b20e4f2c1fc042b4883"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Code-Review","score":0,"reason":"Found 0/14 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-19T11:34:33.958Z","repository_id":65607849,"created_at":"2025-08-19T11:34:33.958Z","updated_at":"2025-08-19T11:34:33.958Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":283544001,"owners_count":26853380,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-09T02:00:05.828Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T03:38:32.452Z","updated_at":"2025-11-09T17:31:50.903Z","avatar_url":"https://github.com/hex0cter.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The clavatar gem for Ruby\n\n**NOTICE: This gem is deprecated. Please replace it with the [hash2obj](https://rubygems.org/gems/hash2obj) gem.**\n\n[![Gem Version](https://badge.fury.io/rb/clavatar.svg)](https://badge.fury.io/rb/clavatar)\n[![Build Status](https://travis-ci.org/hex0cter/clavatar.svg?branch=master)](https://travis-ci.org/hex0cter/clavatar)\n\nClavatar is a ruby gem that converts a hash into a Ruby object.\n\nDuring the web development, it is common to transfer json between the browser and the server. When the json from the\nbrowser presents an object, you might need to convert it back into a Ruby object on the server side.\n\nNormally the class you want to convert to has to provide a method or constructor that takes a hash as argument. In that\nway you will have to implement the same interface for all the classes.\n\nClavatar provides another solution for this. When you want to convert a json (hash) into the object, you just need to\nprovide an existing instance of the same class. For example,\n\nWhen you call\n\n```ruby\nClavatar.cast(hash, object)\n```\n\nclavatar will first inspect all the internal data of object and find out which are writable (for instance,\nattr_accessor, attr_writer, etc.) and which are not (for instance, attr_reader, private members, etc).\n\nFor those that are not writable, clavatar attemps to call its constructor using the information provided by the hash.\nAt the moment clavatar supports the class constructor in any of the following forms:\n\n```ruby\nclass A\n    def initialize([param_1[, param_2[, ...]]] [param_x:[, param_y:[, ...]]] [**args])\n        ...\n    end\nend\n```\n\nOnce a new instance is created, clavatar just copies all the other accessible data to the new instance.\n\nBelow is an example of how to use clavatar:\n\n```ruby\nmodule TestModule\n  class MyKlass\n    attr_reader :b1\n    attr_reader :b2\n    attr_reader :b3\n    attr_reader :b4\n    attr_writer :b5\n    attr_writer :b6\n\n    def initialize(b1, b2 = 2, b3:, b4: 4, **args)\n      @b1 = b1\n      @b2 = b2\n      @b3 = b3\n      @b4 = b4\n      @b5 = args.fetch :b5, 0\n      @b6 = args.fetch :b6, 0\n    end\n\n    def get_attr_b5\n      @b5\n    end\n\n    def get_attr_b6\n      @b6\n    end\n  end\nend\n\nclass TestClavatarMixedParams \u003c Minitest::Test\n  def test_plain_attrs\n    old_obj = TestModule::MyKlass.new(1, b3: 3, b5:5)\n    old_obj.b6 = 6\n\n    new_obj = Clavatar.cast({b1: 11, b2: 12, b3: 13, b4: 14, b5: 15, b6: 16}, old_obj)\n    assert new_obj.b1 == 11\n    assert new_obj.b2 == 12\n    assert new_obj.b3 == 13\n    assert new_obj.b4 == 14\n    assert new_obj.get_attr_b5 == 15\n    assert new_obj.get_attr_b6 == 16\n  end\nend\n```\n\n## How to install?\n\nFrom a terminal run\n\n```bash\n  gem install clavatar\n```\n\nor add the following code into your Gemfiles:\n\n```ruby\n  gem 'clavatar'\n```\n\n## License\n\nThis code is free to use under the terms of the MIT license.\n\n## Contribution\n\nYou are more than welcome to raise any issues [here](https://github.com/hex0cter/clavatar/issues), or create a Pull Request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhex0cter%2Fclavatar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhex0cter%2Fclavatar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhex0cter%2Fclavatar/lists"}