{"id":29955029,"url":"https://github.com/foca/kaleidoscope","last_synced_at":"2025-08-03T17:09:26.683Z","repository":{"id":486403,"uuid":"112409","full_name":"foca/kaleidoscope","owner":"foca","description":"Easy and clean model factories for active record, without touching the internals","archived":false,"fork":false,"pushed_at":"2009-01-22T09:00:38.000Z","size":84,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-04-10T12:04:41.911Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/foca.png","metadata":{"files":{"readme":"README.markdown","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":"2009-01-22T06:55:24.000Z","updated_at":"2019-08-13T13:55:23.000Z","dependencies_parsed_at":"2022-07-14T14:31:21.918Z","dependency_job_id":null,"html_url":"https://github.com/foca/kaleidoscope","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/foca/kaleidoscope","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fkaleidoscope","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fkaleidoscope/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fkaleidoscope/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fkaleidoscope/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foca","download_url":"https://codeload.github.com/foca/kaleidoscope/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foca%2Fkaleidoscope/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268578914,"owners_count":24273089,"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-08-03T02:00:12.545Z","response_time":2577,"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":[],"created_at":"2025-08-03T17:09:16.446Z","updated_at":"2025-08-03T17:09:26.675Z","avatar_url":"https://github.com/foca.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"Kaleidoscope\n============\n\n**Simple** and **clean** object factories for ActiveRecord objects.\n\nKaleidoscopes are ridiculously simple objects, and they provide us with\nbeautiful images with almost no work on our part.\n\nExample plz?\n------------\n\n    Kaleidoscope.define do\n      factory(User) {{ :name =\u003e \"Foo Bar\", :email =\u003e \"foo@bar.com\", :password =\u003e \"test\" }}\n      factory(User, :admin) {{ :admin =\u003e true }}\n      factory(User, :named) do\n        lambda {|name| { :conditions =\u003e { :name =\u003e name }}}\n      end\n    end\n    \n    User.factory.create #=\u003e #\u003cUser id: 1, name: \"Foo Bar\", email: \"foo@bar.com\", password: \"test\", admin: false\u003e\n    User.admin.create #=\u003e #\u003cUser id: 2, name: nil, email: nil, password: nil, admin: true\u003e\n    \n    # Overwriting values\n    User.factory.create(:name =\u003e \"foca\") #=\u003e #\u003cUser id: 3, name: \"foca\", email: \"foo@bar.com\", password: \"test\", admin: false\u003e\n    \n    # Don't save values automatically\n    User.factory.new #=\u003e #\u003cUser id: nil, ...\u003e\n\nGenerating unique values\n------------------------\n\nMost of the time, our models require certain fields to have unique content. In \norder to generate that with Kaleidoscope, just call `Kaleidoscope.unique`:\n\n    Kaleidoscope.unique #=\u003e 0\n    Kaleidoscope.unique #=\u003e 1\n    # and so on, and so forth\n    \nIf you need repeatable values, call `Kaleidoscope.reset_uniques!` and the next\ncall to `Kaleidoscope.unique` will return 0 again.\n\nYou can pass a block to `unique`, in which case we will pass the unique value\nto the block and return whatever the block outputs:\n\n    Kaleidoscope.unique {|i| \"user_#{i}\" } #=\u003e \"user_0\"\n\nHow does it work?\n-----------------\n\nIt just uses named scopes behind the scenes. Each factory declaration defines\na new named scope with the provided name (or `factory` by default).\n\nThis means we don't touch *any* class. No methods are added on \n`ActiveRecord::Base`. \n\nIf the named scope already exists (or you have a class method with that\nsame name), the factory declaration will fail with an `ArgumentError`.\n\nBut enough README, read the code, the factory declaration is 5 lines of code.\nLiterally.\n\nWhy?\n----\n\nJust a thought experiment, but it might turn out to be useful after all. All \ncredit goes to [Jeremy McAnally][jeremy] for the original idea.\n\nLicense\n-------\n\nCopyright (c) 2009 [Jeremy McAnally][jeremy] \u0026 [Nicolás Sanguinetti][foca] for [entp][].\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n[jeremy]: http://github.com/jeremymcanally\n[foca]:   http://github.com/foca\n[entp]:   http://entp.com","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoca%2Fkaleidoscope","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoca%2Fkaleidoscope","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoca%2Fkaleidoscope/lists"}