{"id":22980997,"url":"https://github.com/rubyworks/rc","last_synced_at":"2025-08-13T17:33:43.099Z","repository":{"id":2934415,"uuid":"3946179","full_name":"rubyworks/rc","owner":"rubyworks","description":"The best way to manage your tool configurations.","archived":false,"fork":false,"pushed_at":"2013-01-22T14:27:42.000Z","size":1188,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-30T17:44:06.001Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://rubyworks.github.com/rc","language":"Ruby","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/rubyworks.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","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":"2012-04-06T02:30:43.000Z","updated_at":"2024-02-21T15:34:33.000Z","dependencies_parsed_at":"2022-08-21T00:20:44.243Z","dependency_job_id":null,"html_url":"https://github.com/rubyworks/rc","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Frc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Frc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Frc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Frc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubyworks","download_url":"https://codeload.github.com/rubyworks/rc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229773540,"owners_count":18122031,"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-12-15T01:46:34.687Z","updated_at":"2024-12-15T01:46:35.520Z","avatar_url":"https://github.com/rubyworks.png","language":"Ruby","readme":"# RC - Runtime Configuration\n\n[Homepage](http://rubyworks.github.com/rc) /\n[Report Issue](http://github.com/rubyworks/rc/issues) /\n[Source Code](http://github.com/rubyworks/rc)\n( [![Build Status](https://secure.travis-ci.org/rubyworks/rc.png)](http://travis-ci.org/rubyworks/rc)\n  [![Gem Version](https://badge.fury.io/rb/rc.png)](http://badge.fury.io/rb/rc) )\n\n\n## About\n\nRC is a is multi-tenant runtime configuration system for Ruby tools.\nIt is designed to facilitate Ruby-based configuration for multiple\ntools in a single file, and designed to work whether the tool\nhas built-in support for RC or not. The syntax is simple, universally\napplicable, yet flexible.\n\nRC can be used with any Ruby-based commandline tool or library utilized by\nsuch tool, where there exists some means of configuring it via a toplevel/global\ninterface; or the tool has been designed to directly support RC, of course.\n\n\n## Installation\n\nTo use RC with tools that support RC directly, there is likely nothing to\ninstall. Installing the tool should install `rc` via a dependency and\nload runtime configurations when the tool is used.\n\nTo use RC with a tool that does not provide built-in support, first install\nthe RC library, typically via RubyGems:\n\n    gem install rc\n\nThen add `-rc` to your system's `RUBYOPT` environment variable.\n\n    $ export RUBYOPT='-rc'\n\nYou will want to add that to your `.bashrc`, `.profile` or equivalent configuration\nscript, so it is always available.\n\n\n## Instruction\n\nTo use RC in a project create a configuration file called either `.ruby` or `.rubyrc`. \nThe longer name has precedence if both are present. In this file add configuration blocks\nby name of the commandline tool.\n\nFor example, let's demonstrate how we could use this to configure Rake tasks.\n(Yes, Rake is not the most obvious choice, since developers are just as happy\nto keep using a Rakefile. But using Rake as an example serves to show that it\n*can* be done, and also it makes a good tie-in with next example.)\n\n    $ cat .rubyrc\n    config :rake do\n      desc 'generate yard docs'\n      task :yard do\n        sh 'yard'\n      end\n    end\n\nNow when `rake` is run the tasks defined in this configuration will be available.\n\nYou might wonder why anyone would do this. That's where the *multi-tenancy*\ncomes into play. Let's add another configuration.\n\n    $ cat .rubyrc\n    title = \"MyApp\"\n\n    config :rake do\n      desc 'generate yard docs'\n      task :yard do\n        sh \"yard doc --title #{title}\"\n      end\n    end\n\n    config :qedoc do |doc|\n      doc.title = \"#{title} Demos\"\n    end\n\nNow we have configuration for both the `rake` tool and the `qedoc` tool in\na single file. Thus we gain the advantage of reducing the file count of our \nproject while pulling our tool configurations together into one place.\nMoreover, these configurations can potentially share settings as demonstrated\nhere via the `title` local variable.\n\nOf course, if we want configurations stored in multiple files, that can be done\ntoo. Simple use the `import` method to load them, e.g.\n\n    import 'rc/*.rb'\n\nRC also supports profiles, either via a `profile` block:\n\n    profile :cov do\n      config :qed do\n        require 'simplecov'\n        ...\n      end\n    end\n\nOr via a keyword parameter:\n\n    config 'qed', profile: 'cov' do\n      require 'simplecov'\n      ...\n    end\n\nWhen utilizing the tool, set the profile via an environment variable.\n\n    $ profile=cov qed\n\nRC also support just `p` as a convenient shortcut.\n\n    $ p=cov qed\n\nSome tools that support RC out-of-the-box, may support a profile command\nline option for specifying the profile.\n\n    $ qed -p cov\n\nBeyond mere namespacing, some tools might utilize profiles for a more specific\npurpose fitting the tool. Consult the tool's documentation for details.\n\nConfigurations can also be pulled in from other gems using the `from` option.\n\n    config :qed, :profile=\u003e'simplecov', :from=\u003e'qed'\n\nAs long as a project includes its `.rubyrc` file (and any imported files)\nin it's gem package, it's possible to share configurations in this manner.\n\n\n## Customization\n\nA tool can provide dedicated support for RC by loading `rc/api` and using the\n`configure` method to define a configuration procedure. For example, \nthe `detroit` project defines:\n\n    require 'rc/api'\n\n    RC.configure 'detroit' do |config|\n      if config.command?\n        Detroit.rc_config \u003c\u003c config\n      end\n    end\n\nIn our example, when `detroit` is required this configuration will be processed.\nThe `if config.command?` condition ensures that it only happens if the config's\n`command` property matches the current command, i.e. `$0 == 'detroit'`. We see\nhere that Detroit stores the configuration for later use. When Detroit gets\naround to doing it's thing, it checks this `rc_config` setting and evaluates\nthe configurations found there.\n\nIt is important that RC be required first, ideally before anything else. This\nensures it will pick up all configured features.\n\nSome tools will want to support a command line option for selecting a \nconfiguration profile. RC has a convenience method to make this very\neasy to do. For example, `qed` uses it:\n\n    RC.profile_switch('qed', '-p', '--profile')\n\nIt does not remove the argument from `ARGV`, so the tool's command line option\nparser should still account for it. This simply ensures RC will know what the\nprofile is by setting `ENV['profile']` to the entry following the switch.\n\n\n## Dependencies\n\n### Libraries\n\nRC depends on the [Finder](http://rubyworks.github.com/finder) library\nto provide reliable load path and Gem searching. This is used when importing\nconfigurations from other projects. (It's very much a shame Ruby and RubyGems\ndoes not have this kind of functionality built-in.)\n\n### Core Extensions\n\nRC uses two core extensions, `#to_h`, which applies to a few different\nclasses, and `String#tabto`. These are *copied* from\n[Ruby Facets](http://rubyworks.github.com/facets) to ensure a high\nstandard of interoperability.\n\nBoth of these methods have been suggested for inclusion in Ruby proper.\nPlease head over to Ruby Issue Tracker and add your support.\n\n* http://bugs.ruby-lang.org/issues/749\n* http://bugs.ruby-lang.org/issues/6056\n\n\n## Release Notes\n\nPlease see HISTORY.md file.\n\n\n## Copyrights\n\nCopyright (c) 2011 Rubyworks\n\nConfection is distributable in accordance with the **BSD-2-Clause** license.\n\nSee LICENSE.txt file for details.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyworks%2Frc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyworks%2Frc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyworks%2Frc/lists"}