Skip to content

Instantly share code, notes, and snippets.

@fj
Created June 19, 2010 15:06
Show Gist options
  • Save fj/444964 to your computer and use it in GitHub Desktop.
Save fj/444964 to your computer and use it in GitHub Desktop.
# in <project_root>/bin/magicwand
MagicWand::Configuration::Initializer.new(...)
# in <project_root>/data/root.yaml
---
apple: 100
banana: 200
coconut: 300
# ----------------------------------
# bad strategy:
# in <project_root>/lib/magicwand/configuration/initializer.rb
root_yaml = YAML.load_file(
File.expand_path("../../../../data/#{RootFileName}", __FILE__))
# ----------------------------------
# marginally better:
# in lib/magicwand/magicwand.rb
module MagicWand
# Project root directory.
ROOT = File.expand_path("../..", __FILE__)
end
# in <project_root>/lib/magicwand/configuration/initializer.rb
root_yaml = YAML.load_file(
File.expand_path("#{MagicWand::ROOT}/data/#{RootFileName}", __FILE__))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment