{"id":17942620,"url":"https://github.com/petercamilleri/option_list","last_synced_at":"2025-07-22T10:32:59.035Z","repository":{"id":12763615,"uuid":"15436950","full_name":"PeterCamilleri/option_list","owner":"PeterCamilleri","description":"For reference only. Obsolete as of Ruby 2.1.","archived":false,"fork":false,"pushed_at":"2021-05-19T20:06:34.000Z","size":335,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T03:55:53.784Z","etag":null,"topics":["parameters","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"HeinrichReimer/material-intro","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PeterCamilleri.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":"2013-12-25T15:24:59.000Z","updated_at":"2023-03-05T04:20:46.000Z","dependencies_parsed_at":"2022-09-02T12:50:56.987Z","dependency_job_id":null,"html_url":"https://github.com/PeterCamilleri/option_list","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterCamilleri%2Foption_list","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterCamilleri%2Foption_list/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterCamilleri%2Foption_list/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterCamilleri%2Foption_list/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PeterCamilleri","download_url":"https://codeload.github.com/PeterCamilleri/option_list/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245289780,"owners_count":20591131,"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":["parameters","ruby"],"created_at":"2024-10-29T03:06:30.423Z","updated_at":"2025-03-24T14:32:45.352Z","avatar_url":"https://github.com/PeterCamilleri.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OptionList\r\n\r\nThis gem addresses the fact that parameter validation is long and\r\ntedious and something needs to be done about that. This gem implements\r\nthe idea that parameters be described separately and validated in a\r\nsingle line of client method code.\r\n\r\nMost of what this gem does has been subsumed by the Ruby Language itself,\r\nstarting with version 1.9 and further with versions 2.0 and beyond.\r\n\r\nFinally, I'd like to add a personal note about this code. This was my first\r\nattempt at creating a gem. As such there is very much a newbie vibe to the\r\ncode. I hope you can chalk this up to just a part of the learning process.\r\nNone the less, if there are improvements that you (the reader) could suggest,\r\nI'd really appreciate hearing about them.\r\n\r\nThanks in advance, Peter.\r\n\r\n\r\n## Installation\r\n\r\nAdd this line to your application's Gemfile:\r\n\r\n    gem 'option_list'\r\n\r\nAnd then execute:\r\n\r\n    $ bundle\r\n\r\nOr install it yourself as:\r\n\r\n    $ gem install option_list\r\n\r\nThe options_list gem is at: ( https://rubygems.org/gems/options_list )\r\n\r\n## Usage\r\n\r\nThe use of option_list occurs in three phases: Describing the Parameters,\r\nPassing in Parameters and Validating/Accessing the Parameters. This can be\r\nseen in the following example:\r\n```ruby\r\nmodule ReadLine\r\n  #Create the parameter specification (simplified for brevity)\r\n  @spec = OptionList.new([:buffer, :history, :no_history], {:depth =\u003e 50}) do |options|\r\n    fail \"Depth must be an integer\" unless options.depth.is_a(Integer)\r\n    fail \"Depth must be positive\" if options.depth \u003c 1\r\n  end\r\n\r\n  class \u003c\u003c self\r\n    attr_reader :spec\r\n  end\r\n\r\n  def read_line(prompt, *options)\r\n    @options = ReadLine.spec.select(options)\r\n    #Further code deleted for brevity.\r\n    #Somewhere along the line it records the last line.\r\n    buffer_line(current_line)\r\n    current_line\r\n  end\r\n\r\n  def buffer_line(line)\r\n    @line_buffer \u003c\u003c line if @options.history?\r\n    @line_buffer.delete_at(0) if @line_buffer.length \u003e @options.depth\r\n  end\r\nend\r\n```\r\nThe option_list gem is described in the The option_list User's Guide\r\nwhich covers version 1.1.1 which has no material change from 1.1.3\r\n\r\n## Contributing\r\n\r\n#### Plan A\r\n\r\n1. Fork it ( https://github.com/PeterCamilleri/option_list/fork )\r\n2. Create your feature branch (`git checkout -b my-new-feature`)\r\n3. Commit your changes (`git commit -am 'Add some feature'`)\r\n4. Push to the branch (`git push origin my-new-feature`)\r\n5. Create new Pull Request\r\n\r\n#### Plan B\r\n\r\nGo to the GitHub repository and raise an issue calling attention to some\r\naspect that could use some TLC or a suggestion or an idea.\r\n\r\n## License\r\n\r\nThe gem is available as open source under the terms of the\r\n[MIT License](./LICENSE.txt).\r\n\r\n## Code of Conduct\r\n\r\nEveryone interacting in the fully_freeze project’s codebases, issue trackers,\r\nchat rooms and mailing lists is expected to follow the\r\n[code of conduct](./CODE_OF_CONDUCT.md).\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetercamilleri%2Foption_list","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetercamilleri%2Foption_list","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetercamilleri%2Foption_list/lists"}