lib/fig/environment.rb in fig-0.1.3 vs lib/fig/environment.rb in fig-0.1.5

- old
+ new

@@ -52,10 +52,27 @@ end end result end + def apply_config_statement(base_package, statement) + case statement + when Path + append_variable(base_package, statement.name, statement.value) + when Set + set_variable(base_package, statement.name, statement.value) + when Include + include_config(base_package, statement.package_name, statement.config_name, statement.version_name) + when Command + # ignore + else + fail "Unexpected statement: #{statement}" + end + end + + private + def include_config(base_package, package_name, config_name, version_name) package = lookup_package(package_name || base_package.package_name, version_name) apply_config(package, config_name || "default") end @@ -71,35 +88,19 @@ else @variables[name] = value end end - private - def with_environment old_env = {} begin @variables.each { |key,value| old_env[key] = ENV[key]; ENV[key] = value } yield ensure old_env.each { |key,value| ENV[key] = value } end end - def apply_config_statement(base_package, statement) - case statement - when Path - append_variable(base_package, statement.name, statement.value) - when Set - set_variable(base_package, statement.name, statement.value) - when Include - include_config(base_package, statement.package_name, statement.config_name, statement.version_name) - when Command - # ignore - else - fail "Unexpected statement: #{statement}" - end - end def lookup_package(package_name, version_name) package = @packages[package_name] if package.nil? package = @repository.load_package(package_name, version_name || DEFAULT_VERSION_NAME)