{"id":13747344,"url":"https://github.com/jbodah/suggest_rb","last_synced_at":"2025-05-09T08:32:30.204Z","repository":{"id":56896814,"uuid":"165308467","full_name":"jbodah/suggest_rb","owner":"jbodah","description":":question: tells you which method does the thing you want to do","archived":false,"fork":false,"pushed_at":"2019-04-29T20:11:34.000Z","size":28,"stargazers_count":246,"open_issues_count":1,"forks_count":4,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-24T14:25:17.730Z","etag":null,"topics":["developer-tools","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jbodah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-11T20:55:40.000Z","updated_at":"2023-12-10T07:55:10.000Z","dependencies_parsed_at":"2022-08-21T01:20:40.946Z","dependency_job_id":null,"html_url":"https://github.com/jbodah/suggest_rb","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbodah%2Fsuggest_rb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbodah%2Fsuggest_rb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbodah%2Fsuggest_rb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jbodah%2Fsuggest_rb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jbodah","download_url":"https://codeload.github.com/jbodah/suggest_rb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253217144,"owners_count":21873021,"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":["developer-tools","ruby"],"created_at":"2024-08-03T06:01:25.649Z","updated_at":"2025-05-09T08:32:29.920Z","avatar_url":"https://github.com/jbodah.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Suggest\n\ntells you which method does the thing you want to do\n\n## Disclaimer\n\nI don't recommend you ship this in your Gemfile. Keep it in your system's gems (e.g. `gem install`) and load it as needed (e.g. `irb -rsuggest`, `RUBY_OPT=-rsuggest irb`, etc)\n\n## Installation\n\n```\ngem install suggest_rb\n```\n\n## Usage\n\n```rb\nrequire 'suggest'\n\n# Object#what_returns? tells you which method returns the value\n[1,2,3].what_returns? 1\n=\u003e [:first, :min]\n\n# You can also specify the args you want that method to take\n[1,2,3].what_returns? [1], args: [1]\n=\u003e [:first, :take, :grep, :min]\n\n# By default, it only returns methods that don't mutate the object\n[1,2,3].what_returns? [1], args: [1], allow_mutation: true\n=\u003e [:first, :take, :shift, :grep, :min]\n\n# It works on several core modules including String\n\"HELLO\".what_returns? \"hello\"\n=\u003e [:downcase, :swapcase]\n\n# You can also specify a block that you want the method to accept\n[1,2,3,4].what_returns?({true =\u003e [2,4], false =\u003e [1,3]}) { |n| n % 2 == 0 }\n=\u003e [:group_by]\n\n# Object#what_mutates? tells you which method changes the object to the desired state\n[1,2,3].what_mutates? [2, 3]\n=\u003e [:shift]\n\n# You can also match on the return value\n[1,2,3].what_mutates? [2, 3], returns: 1\n=\u003e [:shift]\n\n[1,2,3].what_mutates? [2, 3], returns: 2\n=\u003e []\n\n# You can specify which args to pass to the method\n[1,2,3].what_mutates? [3], args: [2]\n=\u003e [:shift]\n\n# It also works on a bunch of core modules\n\"HELLO\".what_mutates? \"hello\"\n=\u003e [:swapcase!, :downcase!]\n\n# And you can give it a block as well\n[1,2,3,4].what_mutates? [2,4] { |n| n % 2 == 0 }\n=\u003e [:select!, :keep_if]\n\n# You can use a lambda as an expected\n[1,2,3,4].what_returns? -\u003e (something_that) { something_that.to_i == 4 }\n=\u003e [:count, :length, :size, :last, :max]\n\n# It respects the ruby version\n# ruby 2.4.3\n{a: 1, b: 2}.what_returns?({})\n=\u003e []\n# ruby 2.5.0\n{a: 1, b: 2}.what_returns?({})\n=\u003e [:slice]\n```\n\n## Note to Self\n\nSnippet to use in `bin/console` for finding methods for blacklisting:\n\n```\nSuggest::SUGGEST_MODS.flat_map { |k| [k].product(k.instance_methods) }.select { |k, v| v == :rand }.map { |k, v| k.instance_method(v).owner }.uniq\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbodah%2Fsuggest_rb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjbodah%2Fsuggest_rb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjbodah%2Fsuggest_rb/lists"}