{"id":17761909,"url":"https://github.com/srghma/require_module","last_synced_at":"2025-07-02T19:32:54.710Z","repository":{"id":56891887,"uuid":"117220720","full_name":"srghma/require_module","owner":"srghma","description":"Evaluates file content inside Module.new, with cache","archived":false,"fork":false,"pushed_at":"2018-05-29T08:20:00.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-23T14:47:03.655Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/srghma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-12T09:22:30.000Z","updated_at":"2018-05-29T08:20:01.000Z","dependencies_parsed_at":"2022-08-21T00:20:40.436Z","dependency_job_id":null,"html_url":"https://github.com/srghma/require_module","commit_stats":null,"previous_names":["bjornmelgaard/require_module"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/srghma/require_module","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srghma%2Frequire_module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srghma%2Frequire_module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srghma%2Frequire_module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srghma%2Frequire_module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/srghma","download_url":"https://codeload.github.com/srghma/require_module/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srghma%2Frequire_module/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263203446,"owners_count":23430033,"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":[],"created_at":"2024-10-26T19:49:09.987Z","updated_at":"2025-07-02T19:32:54.516Z","avatar_url":"https://github.com/srghma.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# require_module\n\n[![Build Status](https://travis-ci.org/BjornMelgaard/require_module.svg?branch=master)](https://travis-ci.org/BjornMelgaard/require_module)\n[![Gem Version](https://badge.fury.io/rb/require_module.svg)](https://badge.fury.io/rb/require_module)\n\nEvaluates file content inside Module.new, with cache\n\n# Install\n```rb\ngem 'require_module'\n```\n\n# API\n\n## require_module(fullpath)\n\nEvaluates file content inside Module.new and returns new module\n\n```rb\nrequire_module('/home/user/rubyapp/lib', cache: false) # returns #\u003cModule:0000012312\u003e\nrequire_module('/home/user/rubyapp/lib') # returns :HomeUserRubyappLib\n```\n\n## require_module_relative(relative_path)\n\nSimilar to \"require_module\", but path is relative to file, where function is executed\n\nCheck `lib/require_module.rb` for more\n\n\n# Example\nIf you don't want you modules to intersect, they should have unique name.\nI was tired of coming up with new names, so created this gem.\n\nInstead of\n\n```rb\n# lib.rb\nmodule GloballyUniqueName\n  module_function\n\n  def somefn\n    'Ima helper'\n  end\nend\n```\n\n```rb\n# consumer.rb\nrequire_relative './lib'\n\nmodule Consumer\n  include GloballyUniqueName\n\n  def foo\n    somefn == 'Ima helper'\n  end\nend\n```\n\nYou can write this\n\n```rb\n# lib.rb\nmodule_function\n\ndef somefn\n  'Ima helper'\nend\n```\n\n```rb\n# consumer.rb\nmodule Consumer\n  include require_module_relative('./lib')\n\n  def foo\n    somefn == 'Ima helper'\n  end\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrghma%2Frequire_module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsrghma%2Frequire_module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrghma%2Frequire_module/lists"}