lib/vtools/shared_methods.rb in vtools-1.0.0 vs lib/vtools/shared_methods.rb in vtools-1.0.1

- old
+ new

@@ -1,9 +1,8 @@ # -*- encoding: binary -*- module VTools - # shared methods module SharedMethods # both static & instance bindings module Common @@ -81,17 +80,25 @@ generator = CONFIG[:"#{scope}_path_generator"] begin generator = instance_exec(file_name, &generator).to_s if generator.is_a? Proc rescue => e generator = nil - raise ConfigError, "Path generator error (#{e})" + raise ConfigError, "Path generator error: (#{e})" end storage = CONFIG[:"#{scope}_storage"].to_s storage += "/" unless storage.empty? storage += generator || "" - (!storage || storage.empty? ? CONFIG[:PWD] : storage).to_s.strip.gsub(%r#/+#, '/').gsub(%r#/$#, '') + path = (!storage || storage.empty? ? CONFIG[:PWD] : storage).to_s.strip.gsub(%r#/+#, '/').gsub(%r#/$#, '') + + # generate path + begin + FileUtils.mkdir_p path, :mode => 775 + rescue => e + raise FileError, "Path generator error: #{e}" + end unless File.exists?(path) + path end # path generator setter def path_generator scope = nil, &block if scope