{"id":15405710,"url":"https://github.com/zverok/rubyseeds","last_synced_at":"2025-10-06T21:10:00.500Z","repository":{"id":36291561,"uuid":"40596092","full_name":"zverok/rubyseeds","owner":"zverok","description":"Ruby core extensions repository (not a gem!)","archived":false,"fork":false,"pushed_at":"2017-09-05T15:15:28.000Z","size":24,"stargazers_count":28,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-17T13:57:26.180Z","etag":null,"topics":["core","monkey-patching","ruby"],"latest_commit_sha":null,"homepage":null,"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/zverok.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":"2015-08-12T11:01:12.000Z","updated_at":"2020-05-18T13:58:32.000Z","dependencies_parsed_at":"2022-09-04T12:40:48.871Z","dependency_job_id":null,"html_url":"https://github.com/zverok/rubyseeds","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zverok/rubyseeds","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Frubyseeds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Frubyseeds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Frubyseeds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Frubyseeds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zverok","download_url":"https://codeload.github.com/zverok/rubyseeds/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zverok%2Frubyseeds/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278680258,"owners_count":26027266,"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-06T02:00:05.630Z","response_time":65,"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":["core","monkey-patching","ruby"],"created_at":"2024-10-01T16:18:20.928Z","updated_at":"2025-10-06T21:10:00.423Z","avatar_url":"https://github.com/zverok.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RubySeeds: core_ext done right.\n\n_In the core of apple, there are apple seeds. In your core_ext.rb should\nbe RubySeeds._\n\nIt is not unusual for Ruby developers to have own and favourite set of\nruby core classes extensions (typically lying somewhere in project tree in\n`core_ext.rb`), dragged from project to project, growing, becoming cluttered\nyet beloved.\n\nOther developers rely on some external thing like ActiveSupport or Ruby\nFacets to extend their core classes. And if it is not there, its nowhere.\n\nRubySeeds is different.\n\n## So, what is RubySeeds?\n\nRubySeeds is **not a gem**. On my strong opinion, there is no good in\nmixing together everything somebody can need in core classes. The same\nway, there's no good to make a small gem of each useful idea.\n\nRubySeeds is just an easily navigable [**list of code snippets**](https://github.com/zverok/rubyseeds/blob/master/RubySeeds.md)\nwith clean and simple explanations. Those snippets are thought to be just\ndroppable in your projects `lib/core_ext.rb` (with possible renamings\nand improvements).\n\nSnippets selected for RubySeeds posess those common qualities:\n* targeting shorter, yet clean code (not \"clever\" or \"magic\");\n* as small dependencies between snippets as possible;\n* as clean method names as possible;\n* snippets' code itself should be small and easily verifieble \"by eyes\"\n  (yet tested);\n* strong emphasis on \"more chainable code\", method chaining is cool;\n* strong emphasis on data processing with Ruby, so most of RubySeeds do\n  shorten some container transformations.\n\n## Usage\n\nThere's one huge, yet (supposedly) easily-navigable page with all seeds\ndescribed: [RubySeeds.md](https://github.com/zverok/rubyseeds/blob/master/RubySeeds.md).\n(In future will be separate page with collapsible code.)\n\nYou just browse it, select what you like, expand **Code** section and\ncopy-paste it into your `core_ext.rb` or wherever you want.\n\n### Refinements: highly recommended approach\n\nSince version 2.0, Ruby has [refinements](http://ruby-doc.org/core-2.1.1/doc/syntax/refinements_rdoc.html)\nwhich allows core (and other) classes to be extended not globally, but in\ncontext of some module.\n\nBefore refinements:\n```ruby\n# in core_ext.rb\nclass Hash\n  def symbolize_keys\n    # ...\n  end\nend\n\n# everywhere in code\nrequire 'core_ext'\n# now ANYWHERE Hash#symbolize_keys refers to your implementation... unless\n# you require something else, redefining it.\n```\n\nWith refinements:\n```ruby\n# in core_ext.rb\nmodule HashSymbolize\n  refine Hash do\n    def symbolize_keys\n      # ...\n    end\n  end\nend\n\n# in some concrete place:\nrequire 'core_ext'\nclass MyClass\n  using HashSymbolize\n  # now Hash#symbolize_keys can be used inside your class only\nend\n```\n\n## On \"monkey-patching is bad\" rant\n\nSomebody can say that adding functionality to core classess (even through\nrefinements) is a bad practice.\n\nIt may be (or maybe not) true for large\nenterprise-y systems with tens of juniors fixing your code here and there\nand some contractor just running through it wildly...\n\nYet for many small-to-medium data-processing tasks you just want to be\ncomfortable with code, having it clean and looking like chain of data\nprocessing calls. So, you just want\n`load(something).do_this.and_that.and_shit` instead of multiple\n`My::Deeply::Nested::Namespace.very_concrete_processing_method_name(data)`\ncalls. And you have it.\n\nAlso, take a look at Hal Fultons [post about \"monkey patching\"](http://rubyhacker.com/blog2/concerning-the-term-monkeypatching.html).\n\nAnd [here](http://zverok.github.io/blog/2016-09-28-monkeys.html) is my own latest post on the topic.\n\n## On possible name confusion\n\nThere was [rubyseeds](https://github.com/rubyseeds) organization on github,\nsomething about learning Ruby, I guess?..\n\nCurrent project have no relation to this group, and, as\n[the site](http://rubyseeds.github.io/materials/) seems to be dead, and\nI've already thinked out and loved the name when I found the organization,\nI allowed myself to keep the name.\n\n## Other nice things to say\n\nIf you are like me (= understand, while we sometimes add features to our\nbeloved language to make code clear and rational), you may like also those\nlibraries:\n\n* [backports](https://github.com/marcandre/backports) or [polyfill](https://github.com/AaronLasseigne/polyfill)\n  to have all the goodness of new Ruby versions in older ones;\n* [hashie](https://github.com/intridea/hashie), which is the most popular\n  way of treating hashes as a light-weight objects, as well as set of\n  really useful Hash extensions;\n* [naught](https://github.com/avdi/naught) -- a superior Ruby NullObject\n  pattern implementation, with lot of options;\n* [time_math2](https://github.com/zverok/time_math2) (shameless\n  self-promotion) -- the small and clean library dealing with everyday\n  `Time` tasks like \"next day\", \"prev day\", \"todays midnight\",\n  \"list of time periods of arbitrary length\" and so on (and NO\n  core_ext-ing this time! compatible with everything).\n\n## Contributing\n\nJust usual fork-change-push-make pull request process. Note (if you haven't\nalready), that RubySeeds is highly opionated set of extensions, so,\nthere's no guarantee that pull requests with new features will be accepted.\n\nNB: never try to update RubySeeds.md file -- it is built automatically from\ncode in `lib/**/*.rb`, with `rake build`.\n\n## License\n\nThose are code snippets barely dozen lines length. Let's say \"public\ndomain\", ok?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzverok%2Frubyseeds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzverok%2Frubyseeds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzverok%2Frubyseeds/lists"}