{"id":15502524,"url":"https://github.com/itmammoth/constantinopolis","last_synced_at":"2025-07-22T22:02:01.658Z","repository":{"id":16325193,"uuid":"19074420","full_name":"itmammoth/constantinopolis","owner":"itmammoth","description":"Setting constants solution for ruby applications.","archived":false,"fork":false,"pushed_at":"2022-10-03T09:44:12.000Z","size":16,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-14T06:34:54.484Z","etag":null,"topics":["constant","gem","javascript","rails","ruby"],"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/itmammoth.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-04-23T15:15:47.000Z","updated_at":"2022-10-03T09:42:22.000Z","dependencies_parsed_at":"2022-09-05T14:50:58.866Z","dependency_job_id":null,"html_url":"https://github.com/itmammoth/constantinopolis","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/itmammoth/constantinopolis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itmammoth%2Fconstantinopolis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itmammoth%2Fconstantinopolis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itmammoth%2Fconstantinopolis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itmammoth%2Fconstantinopolis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itmammoth","download_url":"https://codeload.github.com/itmammoth/constantinopolis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itmammoth%2Fconstantinopolis/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266580279,"owners_count":23951190,"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-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["constant","gem","javascript","rails","ruby"],"created_at":"2024-10-02T09:10:09.537Z","updated_at":"2025-07-22T22:02:01.583Z","avatar_url":"https://github.com/itmammoth.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Constantinopolis\n\nConstantinopolis allows you to set constants from your ERBed YAML file.\nRemarkably, your constants are available not only in ruby context, but in javascript's.\nIt works with Rails, Sinatra, or any Ruby projects.\nIt's inspired by [settingslogic](https://github.com/binarylogic/settingslogic).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'constantinopolis'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install constantinopolis\n\n## Usage\n\n### Setup your Fort class\n\nYou need to create a class in your application like below.\n\n```ruby\nclass Istanbul \u003c Constantinopolis::Fort # Any class name you like\n  yml \"#{Rails.root}/config/istanbul.yml\"  # Indicate your yaml file path.\n  namespace Rails.env  # Indicate top level namespace (If you want).\nend\nIstanbul.build!  # Don't forget this line!\n```\n\nIf you are setting for a rails application, it's better to put this file in ```config/initializer```\n\n### Reload\nIf Constantinopolis is used on rails `development` environment, it'll automatically be reloaded when its yaml file is updated.\n\nTo manually reload, just invoke the method `reload!`.\n\n```ruby\nex)\nclass Istanbul \u003c Constantinopolis::Fort\n  ...\nend\n...\n\n# Anywhere you want to reload it\nIstanbul.reload!\n```\n\n### Define constants\n\nSecondly, define constant YAML file.\nOf course, you can use ERB expressions in it.\nTop level keys are used for 'namespace' if you indicated it in your Fort class.\n\n```yaml\ndefaults: \u0026defaults\n  common: Common value\n\ndevelopment:\n  \u003c\u003c: *defaults\n  greeting: Hello, development!\n  number: 1\n  memorable_date: \u003c%= Date.today %\u003e\n  is:\n    located: Turkey\n\ntest:\n  \u003c\u003c: *defaults\n  greeting: Hello, test!\n  number: 2\n  memorable_date: \u003c%= Date.today + 1 %\u003e\n  is:\n    located: Turkey\n\nproduction:\n  \u003c\u003c: *defaults\n  greeting: Hello, production!\n  number: 3\n  memorable_date: \u003c%= Date.today + 2 %\u003e\n  is:\n    located: Turkey\n```\n\n### Access from Ruby\n\nCongratulation!\nyou've been already able to access these constants anywhere like below.\n\n```ruby\nIstanbul.common          #=\u003e \"Common value\"\nIstanbul.greeting        #=\u003e \"Hello, development!\"\nIstanbul.number          #=\u003e 1\nIstanbul.memorable_date  #=\u003e Wed, 23 Apr 2014\nIstanbul.is.located      #=\u003e Turkey\n```\n\n### Access from Javascript\n\nYou can access your constants in javascript the same way as in ruby context.\nConstantinopolis provides you a simple helper method to define javascript's constants.\n\n```html\n\u003c%= javascript_tag Istanbul.js_code %\u003e\u003c!-- You need to call this line before using constants. --\u003e\n\n\u003ch1\u003eJavascript context\u003c/h1\u003e\n\u003cp id=\"common\"\u003e\u003c/p\u003e\n\u003cp id=\"greeting\"\u003e\u003c/p\u003e\n\u003cp id=\"number\"\u003e\u003c/p\u003e\n\u003cp id=\"memorable_date\"\u003e\u003c/p\u003e\n\u003cp id=\"is-located\"\u003e\u003c/p\u003e\n\n\u003c%= javascript_tag do %\u003e\n  document.getElementById(\"common\").innerText = Istanbul.common;\n  document.getElementById(\"greeting\").innerText = Istanbul.greeting;\n  document.getElementById(\"number\").innerText = Istanbul.number;\n  document.getElementById(\"memorable_date\").innerText = Istanbul.memorable_date;\n  document.getElementById(\"is-located\").innerText = Istanbul.is.located;\n\u003c% end %\u003e\n```\n\nIt's can be a nice to define ```\u003c%= javascript_tag Istanbul.js_code %\u003e``` in ```layouts/application.html.erb``` if you are developing a rails application.\n\n## Contributing\n\n1. Fork it ( http://github.com/itmammoth/constantinopolis/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitmammoth%2Fconstantinopolis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitmammoth%2Fconstantinopolis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitmammoth%2Fconstantinopolis/lists"}