{"id":16102355,"url":"https://github.com/sshaw/require3","last_synced_at":"2026-02-22T07:02:24.197Z","repository":{"id":56891885,"uuid":"173394923","full_name":"sshaw/require3","owner":"sshaw","description":"Kernel#require something and make it accessible via a different namespace.","archived":false,"fork":false,"pushed_at":"2019-04-27T03:20:07.000Z","size":15,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-01T23:16:03.515Z","etag":null,"topics":["alias","import","metaprogramming","namespace","require","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/sshaw.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-03-02T02:41:28.000Z","updated_at":"2024-10-23T19:45:47.000Z","dependencies_parsed_at":"2022-08-21T00:50:31.095Z","dependency_job_id":null,"html_url":"https://github.com/sshaw/require3","commit_stats":null,"previous_names":["sshaw/require2"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2Frequire3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2Frequire3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2Frequire3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2Frequire3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sshaw","download_url":"https://codeload.github.com/sshaw/require3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247033577,"owners_count":20872523,"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":["alias","import","metaprogramming","namespace","require","ruby"],"created_at":"2024-10-09T18:53:37.230Z","updated_at":"2026-02-22T07:02:19.156Z","avatar_url":"https://github.com/sshaw.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# require3\n\n`Kernel#require` something and make its contents accessible via a different namespace.\n\n[![Build Status](https://travis-ci.org/sshaw/require3.svg?branch=master)](https://travis-ci.org/sshaw/require3)\n\n## Usage\n\n```rb\nrequire \"require3\"  # Oh the irony\n```\n\nNow load the desired files and specify some rules:\n```rb\nrequire3 \"some/very/long/name/here\" =\u003e \"*\"\n```\n\nThis will make everything accessible via the top-level namespace. It's the same as:\n```rb\nrequire \"some/very/long/name/here\"\ninclude Some::Very::Long::Name::Here\n```\n\nOr access it as `Foo`:\n```rb\nrequire3 \"some/very/long/name/here\" =\u003e \"foo\"\n```\n\nSame as:\n```rb\nrequire \"some/very/long/name/here\"\nFoo = Some::Very::Long::Name::Here\n```\n\nIf you only want to access `Foo` and `Bar`:\n```rb\nrequire3 \"some/very/long/name/here\" =\u003e %w[foo bar]\n```\n\nSame as:\n```rb\nrequire \"some/very/long/name/here\"\nFoo = Some::Very::Long::Name::Here::Foo\nBar = Some::Very::Long::Name::Here::Bar\n```\n\nYou can also provide the names as `Symbol`s and/or using their proper case:\n```rb\nrequire3 \"some/very/long/name/here\" =\u003e [:Foo, \"Bar\"]\n```\n\nUse a `Hash` to specify alternate names:\n```rb\nrequire3 \"some/very/long/name/here\" =\u003e { :foo =\u003e \"foo_hoo\", :bar =\u003e \"BarHar\" }\n```\n\n\nSame as:\n```rb\nrequire \"some/very/long/name/here\"\nFooHoo = Some::Very::Long::Name::Here::Foo\nBarHar = Some::Very::Long::Name::Here::Bar\n```\n\nOr:\n```\nrequire3 \"some/very/long/name/here\" =\u003e { \"Some::Very::Foo\" =\u003e \"foo\", :bar =\u003e \"BarHar\" }\n```\n\nSame as:\n```rb\nrequire \"some/very/long/name/here\"\nFoo = Some::Very::Foo\nBarHar = Some::Very::Long::Name::Here::Bar\n```\n\n`require3` mostly behaves like `Kernerl#require` but, if what you want to alias does not exist, a `NameError` will be raised.\n\nPath names are converted to class names using the same rules as [Rails' `String#camelize`](https://api.rubyonrails.org/v4.2.6/classes/ActiveSupport/Inflector.html#method-i-camelize) (though this library _is not_ a dependency). If this conversion fails you must explicitly provide the name. A convoluted example:\n\n```rb\n# This fails as we try to alias Net::Http\nrequire3 \"net/http\" =\u003e \"n\"\n\n# Do this instead\nrequire3 \"net/http\" =\u003e { \"Net::HTTP\" =\u003e \"n\" }\n```\n\n## See Also\n\n* [aliased](https://metacpan.org/pod/aliased) - The Perl module that served as inspiration\n* [Modulation](https://github.com/digital-fabric/modulation) - Add explicit import and export declarations to your code\n* [class2](https://github.com/sshaw/class2) - Easily create hierarchies that support nested attributes, type conversion, serialization and more\n* [alias2](https://github.com/sshaw/alias2) - Make classes, modules, and constants accessible via a different namespace.\n\n## Author\n\nSkye Shaw [skye.shaw AT gmail]\n\n## License\n\nReleased under the MIT License: http://www.opensource.org/licenses/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsshaw%2Frequire3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsshaw%2Frequire3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsshaw%2Frequire3/lists"}