{"id":19483252,"url":"https://github.com/rubymoney/monetize","last_synced_at":"2025-05-13T23:04:21.625Z","repository":{"id":12752323,"uuid":"15425537","full_name":"RubyMoney/monetize","owner":"RubyMoney","description":"A library for converting various objects into `Money` objects.","archived":false,"fork":false,"pushed_at":"2025-04-30T21:11:03.000Z","size":233,"stargazers_count":436,"open_issues_count":5,"forks_count":108,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-05-07T10:33:47.046Z","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/RubyMoney.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2013-12-24T21:34:38.000Z","updated_at":"2025-03-31T09:25:32.000Z","dependencies_parsed_at":"2024-01-01T17:25:48.417Z","dependency_job_id":"acdd3d3e-cb5d-4b54-89bd-8471cbc44d8a","html_url":"https://github.com/RubyMoney/monetize","commit_stats":{"total_commits":195,"total_committers":55,"mean_commits":"3.5454545454545454","dds":0.7948717948717949,"last_synced_commit":"c8430d69be249d06839b37ae553ba22e765a375b"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyMoney%2Fmonetize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyMoney%2Fmonetize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyMoney%2Fmonetize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RubyMoney%2Fmonetize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RubyMoney","download_url":"https://codeload.github.com/RubyMoney/monetize/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254040491,"owners_count":22004552,"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-11-10T20:14:12.043Z","updated_at":"2025-05-13T23:04:21.570Z","avatar_url":"https://github.com/RubyMoney.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monetize\n\n[![Gem Version](https://badge.fury.io/rb/monetize.svg)](http://badge.fury.io/rb/monetize)\n[![Ruby](https://github.com/RubyMoney/monetize/actions/workflows/ruby.yml/badge.svg)](https://github.com/RubyMoney/monetize/actions/workflows/ruby.yml)\n[![Maintainability](https://api.codeclimate.com/v1/badges/a2cf7b7a170b4ca68fe8/maintainability)](https://codeclimate.com/github/RubyMoney/monetize/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/a2cf7b7a170b4ca68fe8/test_coverage)](https://codeclimate.com/github/RubyMoney/monetize/test_coverage)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)\n\nA library for converting various objects into `Money` objects.\n\n## Installation\n\nRun:\n\n    bundle add monetize\n\nOr install it yourself as:\n\n    $ gem install monetize\n\n## Usage\n\n```ruby\nMonetize.parse(\"USD 100\") == Money.new(100_00, \"USD\")\nMonetize.parse(\"EUR 100\") == Money.new(100_00, \"EUR\")\nMonetize.parse(\"GBP 100\") == Money.new(100_00, \"GBP\")\n\n\"100\".to_money == Money.new(100_00, \"USD\")\n```\n\nOptionally, enable the ability to assume the currency from a passed symbol. Otherwise, currency symbols will be ignored, and USD used as the default currency:\n\n```ruby\nMonetize.parse(\"£100\") == Money.new(100_00, \"USD\")\n\nMonetize.assume_from_symbol = true\n\nMonetize.parse(\"£100\") == Money.new(100_00, \"GBP\")\n\"€100\".to_money == Money.new(100_00, \"EUR\")\n```\n\nParsing can be improved where the input is not expected to contain fractional subunits.\nTo do this, set `Monetize.expect_whole_subunits = true`\n\n```ruby\nMonetize.parse('EUR 10,000') == Money.new(100_00, \"EUR\")\n\nMonetize.expect_whole_subunits = true\nMonetize.parse('EUR 10,000') == Money.new(10_000_00, \"EUR\")\n```\n\nWhy does this work?  If we expect fractional subunits then the parser will treat a single\ndelimiter as a decimal marker if it matches the currency's decimal marker.  But often\nthis is not the case - a European site will show $10.000 because that's the local format.\nAs a human, if this was a stock ticker we might expect fractional cents.  If it's a retail price we know it's actually an incorrect thousands separator.\n\n\nMonetize can also parse a list of values, returning an array-like object ([Monetize::Collection](lib/collection.rb)):\n\n```ruby\nMonetize.parse_collection(\"€80/$100\") == [Money.new(80_00, \"EUR\"), Money.new(100_00, \"USD\")]\nMonetize.parse_collection(\"€80, $100\") == [Money.new(80_00, \"EUR\"), Money.new(100_00, \"USD\")]\n\n# The #range? method detects the presence of a hyphen\nMonetize.parse_collection(\"€80-$100\").range? == true\n```\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubymoney%2Fmonetize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubymoney%2Fmonetize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubymoney%2Fmonetize/lists"}