{"id":31765797,"url":"https://github.com/mjacobus/koine-attributes","last_synced_at":"2025-10-10T00:27:02.167Z","repository":{"id":56880373,"uuid":"89273127","full_name":"mjacobus/koine-attributes","owner":"mjacobus","description":"Stronger attributes for ruby","archived":false,"fork":false,"pushed_at":"2020-03-26T21:41:06.000Z","size":95,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-19T03:59:06.267Z","etag":null,"topics":["type-safety","value-object"],"latest_commit_sha":null,"homepage":null,"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/mjacobus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-24T18:21:28.000Z","updated_at":"2021-06-03T17:22:36.000Z","dependencies_parsed_at":"2022-08-20T11:30:06.052Z","dependency_job_id":null,"html_url":"https://github.com/mjacobus/koine-attributes","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/mjacobus/koine-attributes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjacobus%2Fkoine-attributes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjacobus%2Fkoine-attributes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjacobus%2Fkoine-attributes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjacobus%2Fkoine-attributes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mjacobus","download_url":"https://codeload.github.com/mjacobus/koine-attributes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjacobus%2Fkoine-attributes/sbom","scorecard":{"id":651274,"data":{"date":"2025-08-11","repo":{"name":"github.com/mjacobus/koine-attributes","commit":"a6b711ddf2017e3d1c3227f5fe37f2ea8dbdee3d"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.5,"checks":[{"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":"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":"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":"Code-Review","score":0,"reason":"Found 0/28 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":"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":"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":"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":"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 12 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-21T13:34:08.009Z","repository_id":56880373,"created_at":"2025-08-21T13:34:08.009Z","updated_at":"2025-08-21T13:34:08.009Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278854648,"owners_count":26057503,"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-07T02:00:06.786Z","response_time":59,"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":["type-safety","value-object"],"created_at":"2025-10-10T00:26:51.026Z","updated_at":"2025-10-10T00:27:02.161Z","avatar_url":"https://github.com/mjacobus.png","language":"Ruby","readme":"# Koine::Attributes\n\nStrong attributes for ruby ruby objects.\n\nYes, there are [so many alternative solutions already](#alternative-solutions)! Why then? Cause some times people need distractions at the airports.\n\n[![Build Status](https://travis-ci.org/mjacobus/koine-attributes.svg?branch=master)](https://travis-ci.org/mjacobus/koine-attributes)\n[![Coverage Status](https://coveralls.io/repos/github/mjacobus/koine-attributes/badge.svg?branch=master)](https://coveralls.io/github/mjacobus/koine-attributes?branch=master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mjacobus/koine-attributes/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mjacobus/koine-attributes/?branch=master)\n[![Code Climate](https://codeclimate.com/github/mjacobus/koine-attributes/badges/gpa.svg)](https://codeclimate.com/github/mjacobus/koine-attributes)\n[![Issue Count](https://codeclimate.com/github/mjacobus/koine-attributes/badges/issue_count.svg)](https://codeclimate.com/github/mjacobus/koine-attributes)\n\n[![Gem Version](https://badge.fury.io/rb/koine-attributes.svg)](https://badge.fury.io/rb/koine-attributes)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'koine-attributes'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install koine-attributes\n\n## Usage\n\n ```ruby\n class Person\n   include Koine::Attributes\n\n   attributes do\n     attribute :name, :string\n     attribute :birthday, :date\n\n     # or\n     attribute :birthday, Koine::Attributes::Adapter::Date.new\n   end\n end\n\n peson = Person.new\n person.name = 'John Doe'\n person.birtday = '2001-02-31' # Date Object can also be given\n\n person.name # =\u003e 'John Doe'\n person.birthday # =\u003e #\u003cDate 2001-02-31\u003e\n\n person.attributes.to_h   # =\u003e {\n                          #   name: 'John Doe',\n                          #   birthday: #\u003cDate 2001-02-31\u003e\n                          # }\n ```\n\nOptions:\n\n ```ruby\n attributes do\n   attribute :name, Koine::Attributes::Adapters::Date.new.with_default_value('guest')\n\n   # or\n   attribute :name, :string, -\u003e(adapter) { adapter.with_default_value('guest') }\n end\n```\n\n## Adapter's methods\n\n- with_default_value(default, \u0026block)\n- with_nil_value(value = nil, \u0026block)\n\n\n Also, a constructor can be created by the API\n\n ```ruby\n class Person\n   include Koine::Attributes\n\n   attributes initializer: true do\n     attribute :name, :string\n     attribute :birthday, :date\n   end\n end\n\n person = Person.new(name: 'John Doe', birthday: '2001-01-31')\n\n # foo: attribute will raise error\n person = Person.new(name: 'John Doe', birthday: '2001-01-31', foo: :bar)\n ```\n\n You can disable strict mode\n\n ```ruby\n class Person\n   include Koine::Attributes\n\n   attributes initializer: { strict: false } do\n     attribute :name, :string\n     attribute :birthday, :date\n   end\n end\n\n # foo will be ignored\n person = Person.new(name: 'John Doe', birthday: '2001-01-31', foo: :bar)\n ```\n\n```ruby\nclass Product\n  include Koine::Attributes\n\n  attributes do\n    attribute :price, MyCustom::Money.new\n    attribute :available, :boolean, -\u003e(attribues){ attributes.with_default_value(true) }\n    attribute :available, Koine::Attributes::Drivers::Boolean.new.with_default_value(true)\n    attribute :tags, array_of(:string)\n    attribute :config, hash_of(:symbol, :string)\n\n    # if you want to costumize the above\n    attribute :config, hash_of(:symbol, :string) do |adapter|\n      adapter.for_keys.with_nil_value\n      adapter.for_values.with_nil_value\n    end\n  end\nend\n\nproduct = Product.new\n\nproduct.available #  =\u003e true\nproduct.available = 0\nproduct.available #  =\u003e false\n\nproduct.price = { currency: 'USD', value: 100 }\n\nproduct.tags = ['new']\n\nproduct.config = { short_url: 'http://config.url' }\n\n# or\nproduct.price = \"100 USD\"\n```\n\n```ruby\nclass MyCustom::Money\n  attr_accessor :attribute_name\n\n  def default_value\n    return 'some default_value'\n  end\n\n  def coerce(*values)\n    Money.new(values.first, values.last)\n  end\nend\n\nproduct = Product.new\n\nproduct.available #  =\u003e true\nproduct.available = 0\nproduct.available #  =\u003e false\n\nproduct.price = { currency: 'USD', value: 100 }\n\n# or\nproduct.price = \"100 USD\"\n```\n\n### Value objects\n\n```ruby\nclass Location\n  include Koine::Attributes\n\n  attributes initializer: { freeze: true } do\n    attribute :lat, :float\n    attribute :lon, :float\n  end\nend\n\nlocation = Location.new(lat: 1, lon: 2)\nnew_location = location.with_lon(3)\n```\n\n### Standard types\n\n```ruby\n- :any\n- :array_of\n- :boolean\n- :date\n- :float\n- :hash_of\n- :integer\n- :string\n  - empty_to_nil\n  - trim_empty_spaces\n- :symbol\n- :time\n```\n\n### Alternative solutions\n\n- [attributed_object](https://github.com/jgroeneveld/attributed_object)\n- [virtus](https://github.com/solnic/virtus)\n- [dry-struct](https://github.com/dry-rb/dry-struct)\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/mjacobus/koine-attributes. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjacobus%2Fkoine-attributes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmjacobus%2Fkoine-attributes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjacobus%2Fkoine-attributes/lists"}