{"id":13878526,"url":"https://github.com/nxt-insurance/nxt_init","last_synced_at":"2025-10-04T09:12:22.830Z","repository":{"id":34239719,"uuid":"168742977","full_name":"nxt-insurance/nxt_init","owner":"nxt-insurance","description":"Define initializers and attribute readers for your arguments with a single line of code","archived":false,"fork":false,"pushed_at":"2025-08-01T00:02:25.000Z","size":84,"stargazers_count":22,"open_issues_count":16,"forks_count":0,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-08-25T21:05:02.194Z","etag":null,"topics":["attribute-readers","initializer","ruby","ruby-on-rails","sugar"],"latest_commit_sha":null,"homepage":"","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/nxt-insurance.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-02-01T18:35:03.000Z","updated_at":"2024-04-27T14:42:54.000Z","dependencies_parsed_at":"2024-02-07T10:51:11.516Z","dependency_job_id":"790d4db5-4b6e-4ba6-b550-e232f40c88b7","html_url":"https://github.com/nxt-insurance/nxt_init","commit_stats":{"total_commits":79,"total_committers":6,"mean_commits":"13.166666666666666","dds":0.5443037974683544,"last_synced_commit":"5786f176ec4c93b3d6703596f8cc7350456f1481"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/nxt-insurance/nxt_init","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nxt-insurance%2Fnxt_init","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nxt-insurance%2Fnxt_init/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nxt-insurance%2Fnxt_init/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nxt-insurance%2Fnxt_init/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nxt-insurance","download_url":"https://codeload.github.com/nxt-insurance/nxt_init/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nxt-insurance%2Fnxt_init/sbom","scorecard":{"id":699676,"data":{"date":"2025-08-11","repo":{"name":"github.com/nxt-insurance/nxt_init","commit":"9aa889918cdd4095a38d6c38eab83f9075ebd9bb"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"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":"Code-Review","score":0,"reason":"Found 0/3 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":"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":"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":"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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"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":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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"}},{"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":9,"reason":"1 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-cr5q-6q9f-rq6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 28 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-22T04:53:48.066Z","repository_id":34239719,"created_at":"2025-08-22T04:53:48.066Z","updated_at":"2025-08-22T04:53:48.066Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278290614,"owners_count":25962578,"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-10-04T02:00:05.491Z","response_time":63,"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":["attribute-readers","initializer","ruby","ruby-on-rails","sugar"],"created_at":"2024-08-06T08:01:52.153Z","updated_at":"2025-10-04T09:12:22.786Z","avatar_url":"https://github.com/nxt-insurance.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"[![CircleCI](https://circleci.com/gh/nxt-insurance/nxt_init.svg?style=svg)](https://circleci.com/gh/nxt-insurance/nxt_init)\n\n# NxtInit\n\nCreate an initializer that accepts option arguments and define private readers for your \narguments at the same time. \n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'nxt_init'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install nxt_init\n\n## Usage\n\nNxtInit removes some boilerplate. Instead of writing your initializer and (private) attribute readers each and every time like so:\n\n```ruby\nclass GetSafe\n  def initialize(frontend:, backend:)\n    @frontend = frontend\n    @backend = backend\n  end\n  \n  private \n  \n  attr_reader :frontend, :backend\nend\n```\n\nYou can instead do the following:\n\n```ruby\nclass GetSafe\n  include NxtInit\n  attr_init :frontend, :backend\nend\n\nGetSafe.new # KeyError (NxtInit attr_init key :frontend was missing at initialization!\nGetSafe.new(frontend: 'React', backend: 'Ruby on Rails') #\u003cGetSafe:0x00007f81fb8506b8 @frontend=\"React\", @backend=\"Ruby on Rails\"\u003e\n```\n\n### Optional arguments and defaults\n\nIn order to provide default values you can simply use the hash syntax to define your defaults. \nIf you want to make an attribute optional, just pass nil as the default argument. \nIf there is no default value and you did not provide one when initializing your class, you will get a KeyError.\n\n```ruby\nclass GetSafe\n  include NxtInit\n  attr_init frontend: 'React', \n            backend: -\u003e { 'Ruby on Rails' }, \n            middleware: nil\nend\n\nGetSafe.new #\u003cGetSafe:0x00007fab608e1918 @frontend=\"React\", @backend=\"Ruby on Rails\", @middleware=nil\u003e\n```\n\n### BEWARE of Global Defaults\n\n```ruby\nclass GetSafe\n  include NxtInit\n  attr_init frontend: [], # this is global and shared between all classes\n            backend: -\u003e { [] } # this is local to an instance of the class\nend\n\nGetSafe.new.send(:frontend).object_id =\u003e 70236117045360\nGetSafe.new.send(:frontend).object_id =\u003e 70236117045360\n\nGetSafe.new.send(:backend).object_id =\u003e 70236143937240\nGetSafe.new.send(:backend).object_id =\u003e 70236121600680\n```\n\n### Preprocessors\n\nIf you want to preprocess your attribute somehow, you can define a preprocessor block to which the original attribute will be yielded.\nNote that you can also call methods in your block if you have some heavier lifting to do.\n\n```ruby\nclass GetSafe\n  include NxtInit\n  attr_init date: -\u003e (date) { date \u0026\u0026 (date.is_a?(Date) ? date : Date.parse(date)) }\nend\n\nGetSafe.new(date: '2020/12/12').send(:date) # will give you the date\nGetSafe.new(date: nil).send(:date) # would give you nil\nGetSafe.new # would raise KeyError (NxtInit attr_init key :date was missing at initialization!)\n```\n\nAlso you can still pass in nil if your block can handle it. If the attribute is not provided on initialization again a KeyError will be raised. \n\n### Inheritance\n\nWhen you inherit from a class that already includes NxtInit you can add further attributes to your subclass and overwrite existing options\nsimply by using attr_init for the same attributes. Check out the specs for more examples.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/nxt-insurance/nxt_init.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnxt-insurance%2Fnxt_init","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnxt-insurance%2Fnxt_init","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnxt-insurance%2Fnxt_init/lists"}