{"id":17736558,"url":"https://github.com/toshimaru/ruby-short_url","last_synced_at":"2025-10-05T14:58:47.107Z","repository":{"id":31764152,"uuid":"35330383","full_name":"toshimaru/ruby-short_url","owner":"toshimaru","description":"Ruby implementation of python-short_url.","archived":false,"fork":false,"pushed_at":"2022-12-04T07:36:35.000Z","size":36,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-27T19:55:40.466Z","etag":null,"topics":["gem","ruby"],"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/toshimaru.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-09T13:53:48.000Z","updated_at":"2024-01-12T10:27:58.000Z","dependencies_parsed_at":"2023-01-14T19:43:50.879Z","dependency_job_id":null,"html_url":"https://github.com/toshimaru/ruby-short_url","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/toshimaru/ruby-short_url","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toshimaru%2Fruby-short_url","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toshimaru%2Fruby-short_url/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toshimaru%2Fruby-short_url/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toshimaru%2Fruby-short_url/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toshimaru","download_url":"https://codeload.github.com/toshimaru/ruby-short_url/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toshimaru%2Fruby-short_url/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278470181,"owners_count":25992203,"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-05T02:00:06.059Z","response_time":54,"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":["gem","ruby"],"created_at":"2024-10-26T00:23:27.175Z","updated_at":"2025-10-05T14:58:47.091Z","avatar_url":"https://github.com/toshimaru.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ruby::ShortUrl\n\n[![Gem Version](https://badge.fury.io/rb/ruby-short_url.svg)](http://badge.fury.io/rb/ruby-short_url)\n![Test](https://github.com/toshimaru/ruby-short_url/workflows/Test/badge.svg)\n![RuboCop](https://github.com/toshimaru/ruby-short_url/workflows/RuboCop/badge.svg)\n[![Test Coverage](https://codeclimate.com/github/toshimaru/ruby-short_url/badges/coverage.svg)](https://codeclimate.com/github/toshimaru/ruby-short_url/coverage)\n[![Code Climate](https://codeclimate.com/github/toshimaru/ruby-short_url/badges/gpa.svg)](https://codeclimate.com/github/toshimaru/ruby-short_url)\n\n## Description\n\nRuby implementation for generating Tiny URL. The implementation is based on [python-short_url](https://github.com/Alir3z4/python-short_url).\n\n\u003e A bit-shuffling approach is used to avoid generating consecutive, predictable URLs. However, the algorithm is deterministic and will guarantee that no collisions will occur.\n\u003e\n\u003e The URL alphabet is fully customizable and may contain any number of characters.\n\n\u003e The intended use is that incrementing, consecutive integers will be used as keys to generate the short URLs. For example, when creating a new URL, the unique integer ID assigned by a database could be used to generate the URL by using this module. Or a simple counter may be used. As long as the same integer is not used twice, the same short URL will not be generated twice.\n\nMore detail is [here](https://github.com/Alir3z4/python-short_url#short-url-generator).\n\n## Installation\n\nAdd this line to your application's `Gemfile`:\n\n```ruby\ngem 'ruby-short_url'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install ruby-short_url\n\n## Usage\n\n```rb\n# shorten id\nRuby::ShortUrl::Encoder.new.encode_url(123456) # =\u003e \"00crI\"\n\n# decode encoded\nRuby::ShortUrl::Encoder.new.decode_url(\"00crI\") # =\u003e 123456\n```\n\n### Create your own URL Shortner\n\n```rb\nclass CustomEncoder \u003c Ruby::ShortUrl::Encoder\n  def initialize\n    # Set your own custom alphabet and block_size\n    super(alphabet: \"0123abc\", block_size: 5)\n  end\nend\n```\n\n```rb\n# \u003e custom_encoder = CustomEncoder.new\n# =\u003e #\u003cCustomEncoder:0x007faf3babc830 @alphabet=\"0123abc\", @block_size=5, @mask=31, @mapping=[0, 1, 2, 3, 4]\u003e\n#\n# \u003e custom_encoder.encode_url(1)\n# =\u003e \"00022\"\n# \u003e custom_encoder.encode_url(2)\n# =\u003e \"00011\"\n# \u003e custom_encoder.encode_url(3)\n# =\u003e \"00033\"\n# \u003e custom_encoder.encode_url(4)\n# =\u003e \"0000a\"\n#\n# \u003e custom_encoder.decode_url(\"00022\")\n# =\u003e 1\n# \u003e custom_encoder.decode_url(\"00011\")\n# =\u003e 2\n# \u003e custom_encoder.decode_url(\"00033\")\n# =\u003e 3\n# \u003e custom_encoder.decode_url(\"0000a\")\n# =\u003e 4\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` 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`.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/toshimaru/ruby-short_url. 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## 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%2Ftoshimaru%2Fruby-short_url","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoshimaru%2Fruby-short_url","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoshimaru%2Fruby-short_url/lists"}