{"id":15588445,"url":"https://github.com/solnic/coercible","last_synced_at":"2025-04-13T04:58:42.724Z","repository":{"id":6058920,"uuid":"7284309","full_name":"solnic/coercible","owner":"solnic","description":"Powerful, flexible and configurable coercion library. And nothing more.","archived":false,"fork":false,"pushed_at":"2017-09-01T21:14:40.000Z","size":394,"stargazers_count":137,"open_issues_count":13,"forks_count":15,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-09T21:40:25.637Z","etag":null,"topics":[],"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/solnic.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-22T09:18:46.000Z","updated_at":"2024-03-26T02:36:47.000Z","dependencies_parsed_at":"2022-09-10T02:50:54.516Z","dependency_job_id":null,"html_url":"https://github.com/solnic/coercible","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solnic%2Fcoercible","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solnic%2Fcoercible/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solnic%2Fcoercible/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solnic%2Fcoercible/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/solnic","download_url":"https://codeload.github.com/solnic/coercible/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248643010,"owners_count":21138354,"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","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-10-02T22:40:20.725Z","updated_at":"2025-04-13T04:58:42.706Z","avatar_url":"https://github.com/solnic.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[gem]: https://rubygems.org/gems/coercible\n[travis]: https://travis-ci.org/solnic/coercible\n[gemnasium]: https://gemnasium.com/solnic/coercible\n[codeclimate]: https://codeclimate.com/github/solnic/coercible\n[coveralls]: https://coveralls.io/r/solnic/coercible\n[inchpages]: http://inch-ci.org/github/solnic/coercible/\n\n# Coercible\n\n[![Gem Version](https://badge.fury.io/rb/coercible.svg)][gem]\n[![Build Status](https://travis-ci.org/solnic/coercible.svg?branch=master)][travis]\n[![Dependency Status](https://gemnasium.com/solnic/coercible.png)][gemnasium]\n[![Code Climate](https://codeclimate.com/github/solnic/coercible/badges/gpa.svg)][codeclimate]\n[![Test Coverage](https://codeclimate.com/github/solnic/coercible/badges/coverage.svg)][codeclimate]\n[![Inline docs](http://inch-ci.org/github/solnic/coercible.svg?branch=master\u0026style=flat)][inchpages]\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'coercible'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install coercible\n\n## Usage\n\nCoercible gives you access to coercer objects where each object is responsible\nfor coercing only one type into other types. For example a string coercer knows\nonly how to coerce string objects, integer coercer knows only how to coerce integers\netc.\n\nHere's the most basic example:\n\n```ruby\ncoercer = Coercible::Coercer.new\n\n# coerce a string to a date\ncoercer[String].to_date('2012/12/25') # =\u003e #\u003cDate: 4912573/2,0,2299161\u003e\n\n# coerce a string to a boolean value\ncoercer[String].to_boolean('yes') # =\u003e true\n\n# you got the idea :)\n```\n\nFor more control you can configure your coercer like that:\n\n``` ruby\n# build coercer instance\ncoercer = Coercible::Coercer.new do |config|\n  config.string.boolean_map = { 'yup' =\u003e true, 'nope' =\u003e false }\nend\n\n# coerce a string to boolean\ncoercer[String].to_boolean('yup') # =\u003e true\ncoercer[String].to_boolean('nope') # =\u003e false\n```\n\nNote that at the moment only Integer and String are configurable. More configurable\ncoercers will be added later whenever we find good usecases.\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolnic%2Fcoercible","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolnic%2Fcoercible","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolnic%2Fcoercible/lists"}