lib/cupper/recipe.rb in cupper-0.1.3 vs lib/cupper/recipe.rb in cupper-0.2.0

- old
+ new

@@ -32,14 +32,10 @@ def link_type?(file) (file[1]['type'].split.first(2).join(' ').match('symbolic link')) end - def dir_type?(file) - file[1]['type'].match('directory') - end - def text_type?(file) file[1]['type'].match('text') or file[1]['type'].match('ASCII') end # TODO: this should be on ohai plugin @@ -142,11 +138,11 @@ end def expand_files(files) att = Array.new files.each do |attr| - if text_type?(attr) and (!(attr[1]['related'].nil?) or attr[0].include? "/etc/apt/sources.list") + if valid_cookbook_file?(attr) path = attr[0] source = attr[0] group = attr[1]['group'] mode = attr[1]['mode'] owner = attr[1]['owner'] @@ -158,9 +154,20 @@ full_path = attr[0] CookbookFile.new(@files_path, source, content, 'cookbook_file', full_path).create end end att + end + + def valid_cookbook_file?(attr) + (text_type?(attr) and + !sensible_files?(attr) and + (!(attr[1]['related'].nil?) or + attr[0].include? "/etc/apt/sources.list")) + end + + def sensible_files?(attr) + !!(Config.all_sensibles.find { |file| attr[0].match Regexp.new("^#{file}$") }) end # Every attribute object is created dynamic def new_package(name, version) package = Attribute.new