summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorSeth Chisamore <schisamo@opscode.com>2011-07-08 18:08:12 -0400
committerSeth Chisamore <schisamo@opscode.com>2011-07-08 18:08:12 -0400
commit59c8f8414af1e31c9b589d2292636a5b1362d8a3 (patch)
tree8c5cb1ce36f73bda24b9c662428beda810761802 /libraries
downloadmixlib-shellout-59c8f8414af1e31c9b589d2292636a5b1362d8a3.tar.gz
[COOK-612] useful windows primitives
Diffstat (limited to 'libraries')
-rw-r--r--libraries/helper.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/libraries/helper.rb b/libraries/helper.rb
new file mode 100644
index 0000000..953213c
--- /dev/null
+++ b/libraries/helper.rb
@@ -0,0 +1,45 @@
+#
+# Author:: Seth Chisamore (<schisamo@opscode.com>)
+# Cookbook Name:: windows
+# Library:: helper
+#
+# Copyright:: 2011, Opscode, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+module Windows
+ module Helpers
+
+ def cached_file(source, windows_path=true)
+ @installer_file_path ||= begin
+
+ if(source =~ /^(https?:\/\/)(.*\/)(.*)$/)
+ cache_file_path = "#{Chef::Config[:file_cache_path]}/#{::File.basename(source)}"
+ Chef::Log.debug("Caching a copy of file #{source} at #{cache_file_path}")
+ r = Chef::Resource::RemoteFile.new(cache_file_path, run_context)
+ r.source(source)
+ r.backup(false)
+ r.mode("0755")
+ r.run_action(:create)
+ else
+ cache_file_path = source
+ end
+
+ cache_file_path.gsub!(::File::SEPARATOR, ::File::ALT_SEPARATOR) if windows_path
+ cache_file_path
+ end
+ end
+
+ end
+end \ No newline at end of file