{"id":18071581,"url":"https://github.com/cho45/config-env","last_synced_at":"2025-04-12T02:44:02.125Z","repository":{"id":1590778,"uuid":"2104983","full_name":"cho45/Config-ENV","owner":"cho45","description":null,"archived":false,"fork":false,"pushed_at":"2022-06-11T02:09:55.000Z","size":92,"stargazers_count":6,"open_issues_count":2,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T22:22:27.811Z","etag":null,"topics":["configuration","perl","phase"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cho45.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","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":"2011-07-26T04:02:03.000Z","updated_at":"2022-06-09T23:40:48.000Z","dependencies_parsed_at":"2022-07-11T03:47:29.610Z","dependency_job_id":null,"html_url":"https://github.com/cho45/Config-ENV","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cho45%2FConfig-ENV","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cho45%2FConfig-ENV/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cho45%2FConfig-ENV/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cho45%2FConfig-ENV/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cho45","download_url":"https://codeload.github.com/cho45/Config-ENV/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248507995,"owners_count":21115730,"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":["configuration","perl","phase"],"created_at":"2024-10-31T09:15:51.865Z","updated_at":"2025-04-12T02:44:02.097Z","avatar_url":"https://github.com/cho45.png","language":"Perl","readme":"[![Actions Status](https://github.com/cho45/Config-ENV/actions/workflows/test.yml/badge.svg)](https://github.com/cho45/Config-ENV/actions)\n# NAME\n\nConfig::ENV - Various config determined by %ENV\n\n# SYNOPSIS\n\n    package MyConfig;\n    \n    use Config::ENV 'PLACK_ENV'; # use $ENV{PLACK_ENV} to determine config\n    \n    common +{\n      name =\u003e 'foobar',\n    };\n    \n    config development =\u003e +{\n      dsn_user =\u003e 'dbi:mysql:dbname=user;host=localhost',\n    };\n    \n    config test =\u003e +{\n      dsn_user =\u003e 'dbi:mysql:dbname=user;host=localhost',\n    };\n    \n    config production =\u003e +{\n      dsn_user =\u003e 'dbi:mysql:dbname=user;host=127.0.0.254',\n    };\n    \n    config production_bot =\u003e +{\n      parent('production'),\n      bot =\u003e 1,\n    };\n\n    # Use it\n\n    use MyConfig;\n    MyConfig-\u003eparam('dsn_user'); #=\u003e ...\n\n# DESCRIPTION\n\nConfig::ENV is for switching various configurations by environment variable.\n\n# CONFIG DEFINITION\n\nuse this module in your config package:\n\n    package MyConfig;\n    use Config::ENV 'FOO_ENV';\n\n    common +{\n      name =\u003e 'foobar',\n    };\n\n    config development =\u003e +{};\n    config production  =\u003e +{};\n\n    1;\n\n- common($hash)\n\n    Define common config. This $hash is merged with specific environment config.\n\n- config($env, $hash);\n\n    Define environment config. This $hash is just enabled in $env environment.\n\n- parent($env);\n\n    Expand $env configuration to inherit it.\n\n- load($filename);\n\n    \\`do $filename\\` and expand it. This can be used following:\n\n        # MyConfig.pm\n        common +{\n          API_KEY =\u003e 'Set in config.pl',\n          API_SECRET =\u003e 'Set in config.pl',\n          load('config.pl),\n        };\n\n        # config.pl\n        +{\n          API_KEY =\u003e 'XFATEAFAFASG',\n          API_SECRET =\u003e 'ced3a7927fcf22cba72c2559326be2b8e3f14a0f',\n        }\n\n## EXPORT\n\nYou can specify default export name in config class. If you specify 'export' option as following:\n\n    package MyConfig;\n    use Config::ENV 'FOO_ENV', export =\u003e 'config';\n\n    ...;\n\nand use it with 'config' function.\n\n    package Foobar;\n    use MyConfig; # exports 'config' function\n\n    config-\u003eparam('...');\n\n# METHODS\n\n- config-\u003eparam($name)\n\n    Returns config variable named $name.\n\n- $guard = config-\u003elocal(%hash)\n\n    This is for scope limited config. You can use this when you use other values in temporary. Returns guard object.\n\n        is config-\u003eparam('name'), 'original value';\n        {\n          my $guard = config-\u003elocal(name =\u003e 'localized');\n          is config-\u003eparam('name'), 'localized';\n        };\n        is config-\u003eparam('name'), 'original value';\n\n- config-\u003eenv\n\n    Returns current environment name.\n\n- config-\u003ecurrent\n\n    Returns current configuration as HashRef.\n\n# AUTHOR\n\ncho45 \u003ccho45@lowreal.net\u003e\n\n# SEE ALSO\n\n# LICENSE\n\nThis library is free software; you can redistribute it and/or modify\nit under the same terms as Perl itself.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcho45%2Fconfig-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcho45%2Fconfig-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcho45%2Fconfig-env/lists"}