Permalink
Browse files

support for STATE_DIRNAME and STATE_BASENAME environment variables

  • Loading branch information...
1 parent 7583a38 commit 3bba409fbde6b23983dfbbd6a2cd7de4bb8a2108 Garett Shulman committed Sep 7, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/main/program/class_methods.rb
@@ -269,7 +269,9 @@ def run(&block)
end
def state_path(*state_path, &block)
- @state_path = File.join(Util.home, ".#{ name }") unless defined?(@state_path)
+ state_dirname = ENV['STATE_DIRNAME'] || Util.home
+ state_basename = ENV['STATE_BASENAME'] || ".#{ name }"
+ @state_path = File.join(state_dirname, state_basename) unless defined?(@state_path)
@state_path = state_path.join('/') unless state_path.empty?
@@ -315,6 +317,7 @@ def config(*args, &block)
[]
end
dash = lines.shift if lines.first.to_s =~ /^---/
+ require 'fileutils' unless defined?(FileUtils)
FileUtils.mkdir_p(File.dirname(config_path))
open(config_path, 'w') do |fd|
fd.puts "## file: #{ config_path }"

0 comments on commit 3bba409

Please sign in to comment.