Created
June 11, 2012 08:58
-
-
Save si1en2i0/2909171 to your computer and use it in GitHub Desktop.
根据yaml文件的内容打包指定的文件
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#coding: utf-8 | |
require 'yaml' | |
require 'fileutils' | |
config_file_path = 'package.yaml' | |
# get related diretories information & prepare | |
src = Dir.getwd | |
dst = File.expand_path('_package', src) | |
Dir.mkdir(dst) if not File.exist?(dst) | |
# read structure data | |
files = YAML.load_file(config_file_path) | |
# fetch files and keep their hierarchy | |
files.each do |v| | |
dir = File.expand_path(File.dirname(v), dst) | |
FileUtils.mkdir_p(dir) if not File.exist?(dir) | |
FileUtils.cp_r(File.expand_path(v, src), File.expand_path(v, dst)) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- dir1 | |
- dir2 | |
- dir3/file1.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment