{"id":17500366,"url":"https://github.com/zzet/persey","last_synced_at":"2025-04-23T02:26:38.380Z","repository":{"id":13530060,"uuid":"16221461","full_name":"zzet/persey","owner":"zzet","description":"Persey help you easily manage the configuration, depending on the environment.","archived":false,"fork":false,"pushed_at":"2024-11-09T19:02:54.000Z","size":64,"stargazers_count":24,"open_issues_count":1,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-21T20:19:57.031Z","etag":null,"topics":["configuration","configuration-by-code","configuration-by-environment","dsl","hacktoberfest","ini","json","rails","ruby","settings","toml","yaml"],"latest_commit_sha":null,"homepage":"","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/zzet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-25T00:41:42.000Z","updated_at":"2024-11-09T19:02:59.000Z","dependencies_parsed_at":"2022-09-02T21:01:00.410Z","dependency_job_id":null,"html_url":"https://github.com/zzet/persey","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzet%2Fpersey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzet%2Fpersey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzet%2Fpersey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zzet%2Fpersey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zzet","download_url":"https://codeload.github.com/zzet/persey/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250356470,"owners_count":21417094,"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","configuration-by-code","configuration-by-environment","dsl","hacktoberfest","ini","json","rails","ruby","settings","toml","yaml"],"created_at":"2024-10-19T18:08:59.486Z","updated_at":"2025-04-23T02:26:38.356Z","avatar_url":"https://github.com/zzet.png","language":"Ruby","readme":"# Persey [![Build Status](https://travis-ci.org/zzet/persey.svg?branch=master)](https://travis-ci.org/zzet/persey) [![Gem Version](https://badge.fury.io/rb/persey.svg)](http://badge.fury.io/rb/persey)[![Code Climate](https://codeclimate.com/github/zzet/persey.svg)](https://codeclimate.com/github/zzet/persey) [![Downloads count](https://img.shields.io/gem/dt/persey.svg)](https://img.shields.io/gem/dt/persey.svg)\n\n\n## Summary\n\nPersey help you easily manage the configuration, depending on the environment.\nThe main objective is to provide opportunities to reuse the\nconfiguration provided by the project, as the default configuration.\n\n## Problem\n\nFor the occurrence of the gem was a few prerequisites.\n\n * Work on opensource projects that support the relevance of problem configurations, changing the appearance of new versions and functionality.\n * Use in the project configuration, diversity in different files, and the inability to unite all in one configuration\n * Desire to use sensitive data as easily as those that can be safely stored in the repository.\n * Sometimes configuration happens in a variety of formats: yaml, json, ini\n\nI do not want to engage in writing parsers, I want to work fine :)\n\nThis solution allows to **accumulate** different configs in one, with the **possibility of reusability** of configuration options and **simple override**. It uses an **intuitive DSL**.\n\n## Installing\n\nAdd this to your `Gemfile`:\n\n``` ruby\ngem \"persey\", '\u003e= 1.0.0'\n```\n\nGenerate default config file\n\n``` bash\n$ rails g persey:install\n```\n\n## Examples\n\n### Definition\n\n``` ruby\n# Rails.root are not initialized here\napp_path = File.expand_path('../../', __FILE__)\n\n# your redis config\nredis_config = File.join(app_path, 'config', 'redis.yml.example')\n\n# your project config\n# as example - it's default options from opensource\n# you don't want redeclare then with copy default file\nproject_config = File.join(app_path, 'config', 'project.yml.example')\n\n# some different environment specifed configuration options in separate config\nproject_env_config = File.join(app_path, 'config', \"project.#{Rails.env}.yml\")\n\n# config for awesome gem\nawesome_gem_config = File.join(app_path, 'config', 'awesome_gem_config.yml')\n\n# config with secret keys\n# you don't want store this config in repository and copy to secret folder on host machine\nmy_secret_key_config = '/home/user/secret/keys.yml'\n\n# We support not only YAML\n# Also JSON\nmy_node_js_config = '/rest/u/apps/node/config.json'\n# And TOML\nmy_berkshelf_config = File.join(app_path, 'provisioning', '.berkshelf')\n# And INI\nmy_ini_config = File.join(app_path, 'provisioning', 'php.ini') # lol\n\n# Persey.init ENV[\"environment\"] do # set current environment\nPersey.init Rails.env do # set current environment\n  source :yaml, redis_config,         :redis              # set specific namespace for settings (mount config in :redis key)\n  source :yaml, project_config                            # if project config and project_env_config have some options keys\n  source :yaml, project_env_config                        # last declared keys overwite before declared\n  source :yaml, awesome_gem_config,   :awesome_gem        # it's good to mount unknown configs to special :namespace\n  source :yaml, my_secret_key_config, :secret             # no comments. It's secret!\n  source :json, my_node_js_config,    :node_js_namespace\n  source :toml, my_berkshelf_config,  :berkshelf_namespace\n  source :ini,  my_ini_config,        :ini_namespace\n\n  env :production do\n    site_name 'Example'\n    web do\n      # domain   'example.com'   # domain described in project_env_config\n                                 # you can use them, or overwirite here\n      protocol 'https'           # we overwrite prolocol option here\n                                 # by default was 'http', but we need some little security\n      port      12345            # more, more security!\n      # and now we use configs for our options, which are not declared in any config\n      uri      -\u003e { \"#{protocol}://#{domain}:#{port}\" }\n    end\n\n    site_uri   -\u003e { web.uri }    # we can re-re-use different options\n\n    email do\n      pop do\n        address 'pop.example.com'\n        port    110\n      end\n      smtp do\n        address 'smtp.example.com'\n        port    25\n      end\n    end\n  end\n\n  env :development, :parent =\u003e :production do\n    web do\n      domain   'localhost'\n      protocol 'http'\n      port      9292\n    end\n    email do\n      smtp do\n        address 'smpt.text.example.com'\n      end\n    end\n  end\nend\n```\nIf you generate Persey config with run `rails g persey:install` in your `config/application.rb` were added strings to run config initialization. If you do not run installer, you can specify of run config manually. For example:\n\nin your `config/application.rb`\n\n``` ruby\n#...\n# We require gem here\nrequire \"persey\"\nrequire File.expand_path('../config', __FILE__)\n\nmodule AppName\n  # If you don't want use configs with call Persey.config\n  # you can do something like it:\n  def self.config\n    Persey.config\n  end\n\n  class Application \u003c Rails::Application\n    # ...\n  end\nend\n\n```\n\n### Usage\n\n``` ruby\nconfig = Persey.config\n\nconfig.site_name      # =\u003e 'Example'\nconfig.web.uri        # =\u003e 'https://example.com:80'\nconfig.site_uri       # =\u003e 'https://example.com:80'\nconfig.email.pop.port # =\u003e 110\n\nAppName.config.site_name # =\u003e 'Example'\n```\n\n### Rails\n\ndefine your config in `config/config.rb`\n\n``` ruby\nPersey.init Rails.env do\n  # settings\nend\n```\n\nreload\n\n``` ruby\n# config/environments/development.rb\nActionDispatch::Reloader.to_prepare do\n  load Rails.root.join('config/config.rb')\nend\n```\n\n## Supported config formats\n\n* YAML\n* JSON\n* TOML\n* INI\n\n## Similar\n\n* https://github.com/kaize/configus (this gem based on configus)\n* https://github.com/markbates/configatron\n* https://github.com/railsjedi/rails_config\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Added some feature'`)\n6. Push to the branch (`git push origin my-new-feature`)\n7. Create new Pull Request\n\n## Another help\n\nYou can give me feedback with issue.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzzet%2Fpersey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzzet%2Fpersey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzzet%2Fpersey/lists"}