summaryrefslogtreecommitdiff
path: root/libraries
diff options
context:
space:
mode:
authorSeth Chisamore <schisamo@opscode.com>2011-09-27 02:53:28 -0400
committerSeth Chisamore <schisamo@opscode.com>2011-09-27 02:53:28 -0400
commita3c32650c1540e4eae12fb775aedfed15e4462b7 (patch)
tree731e67a548a83d6540ec9c4e34fa1746ea3ca3eb /libraries
parent490a6db6f627c00e19e20ad1324998b2f9d11f55 (diff)
downloadmixlib-shellout-a3c32650c1540e4eae12fb775aedfed15e4462b7.tar.gz
combined numerous helper libarires for easier sharing across libaries/LWRPs
Diffstat (limited to 'libraries')
-rw-r--r--libraries/helper.rb25
-rw-r--r--libraries/key_helper.rb26
-rw-r--r--libraries/package_helper.rb45
3 files changed, 25 insertions, 71 deletions
diff --git a/libraries/helper.rb b/libraries/helper.rb
index 9865ef7..dc7c7b3 100644
--- a/libraries/helper.rb
+++ b/libraries/helper.rb
@@ -21,6 +21,9 @@
module Windows
module Helper
+ AUTO_RUN_KEY = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
+ ENV_KEY = 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
+
# returns windows friendly version of the provided path,
# ensures backslashes are used everywhere
def win_friendly_path(path)
@@ -56,6 +59,28 @@ module Windows
@win_version ||= Windows::Version.new
end
+ # if a file is local it returns a windows friendly path version
+ # if a file is remote it caches it locally
+ def cached_file(source, checksum=nil, 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.checksum(checksum) if checksum
+ r.run_action(:create)
+ else
+ cache_file_path = source
+ end
+
+ windows_path ? win_friendly_path(cache_file_path) : cache_file_path
+ end
+ end
+
end
end
diff --git a/libraries/key_helper.rb b/libraries/key_helper.rb
deleted file mode 100644
index 5715615..0000000
--- a/libraries/key_helper.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Author:: Paul Morotn (<pmorton@biaprotect.com>)
-# Cookbook Name:: windows
-# Library:: key_helper
-#
-# Copyright:: 2011, Business Intelligence Associates, 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 KeyHelper
- AUTO_RUN_KEY = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run'
- ENV_KEY = 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
- end
-end \ No newline at end of file
diff --git a/libraries/package_helper.rb b/libraries/package_helper.rb
deleted file mode 100644
index da592be..0000000
--- a/libraries/package_helper.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-# Author:: Seth Chisamore (<schisamo@opscode.com>)
-# Cookbook Name:: windows
-# Library:: package_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 PackageHelper
-
- def cached_file(source, checksum=nil, 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.checksum(checksum) if checksum
- r.run_action(:create)
- else
- cache_file_path = source
- end
-
- windows_path ? Windows::Helper.win_friendly_path(cache_file_path) : cache_file_path
- end
- end
-
- end
-end \ No newline at end of file