Class: GitoriousMuninPlugins::Config
- Inherits:
-
Object
- Object
- GitoriousMuninPlugins::Config
- Defined in:
- lib/gitorious-munin-plugins/config.rb
Constant Summary collapse
- GITORIOUS_CONF_PATH =
"/etc/gitorious.conf"
Instance Method Summary collapse
- #database_yaml ⇒ Object
-
#fetch(key, default_value = nil) ⇒ Object
Fetch line matching #key= in /etc/gitorious.conf.
- #gitorious_config ⇒ Object
- #gitorious_home ⇒ Object
- #rails_env ⇒ Object
Instance Method Details
#database_yaml ⇒ Object
20 21 22 23 24 |
# File 'lib/gitorious-munin-plugins/config.rb', line 20 def database_yaml database_yaml = gitorious_home + "config/database.yml" raise NotFound, "No database.yml found in #{database_yml}" unless database_yaml.exist? database_yaml end |
#fetch(key, default_value = nil) ⇒ Object
Fetch line matching #key= in /etc/gitorious.conf
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/gitorious-munin-plugins/config.rb', line 27 def fetch(key, default_value=nil) return ENV[key] if ENV[key] begin config_file = File.read(GITORIOUS_CONF_PATH) rescue Errno::ENOENT abort <<-MSG Gitorious configuration file #{GITORIOUS_CONF_PATH} was not found, and environment variable #{key} was not set, exiting. MSG end result = config_file.scan(/^#{key}=(.*)$/).flatten.first if result result elsif default_value default_value end end |
#gitorious_config ⇒ Object
5 6 7 8 9 |
# File 'lib/gitorious-munin-plugins/config.rb', line 5 def gitorious_config yaml_file = fetch("GITORIOUS_HOME") gitorious_yml = gitorious_home + "config/gitorious.yml" YAML::load_file(gitorious_yml)[rails_env] end |
#gitorious_home ⇒ Object
15 16 17 18 |
# File 'lib/gitorious-munin-plugins/config.rb', line 15 def gitorious_home path = fetch("GITORIOUS_HOME") Pathname(path) end |
#rails_env ⇒ Object
11 12 13 |
# File 'lib/gitorious-munin-plugins/config.rb', line 11 def rails_env @rails_env ||= fetch("RAILS_ENV", "production") end |