Commits

Julian Mann committed 8fafd01

added ability to specify a relative section of release path for copy files to allow arbitrary hierarchy copies while still having individual files file dependency triggers

Comments (0)

Files changed (1)

lib/flak/rake/templates/environment.rb

             identifier = k.to_s.gsub("_erb_files", "") #  shell or mel
             files_key = identifier.to_sym        # :shell or :mel
             destination_path_key = "#{identifier}_destination".to_sym
+            relative_path_key = "#{identifier}_relative".to_sym
 
             write_erb_opts = {:chmod => 0755}
 
             unless files.nil?
               files.each do |f|
 
+
+                f_relative = ''
+                if settings.has_key? relative_path_key
+                  f_relative = File.dirname(f).gsub(settings[relative_path_key],'')
+                end
+
                 if settings.has_key? destination_path_key
-                  destination_file = target.destination_filepath( settings[destination_path_key], f)
+                  rel_dest = File.join(settings[destination_path_key], f_relative)   
+                  destination_file = target.destination_filepath( rel_dest, f)
                 else
                   if target.respond_to?(destination_path_key)
                     destination_file = target.send destination_path_key, f
                   else
-                    destination_file = target.destination_filepath( '', f)
+                    destination_file = target.destination_filepath( f_relative, f)
                   end
                 end
 
 
           # copy_keys is an array of keys representing file types that should be copied
           # for example maya_script_copy_files
-          # If so, there should be a proc called maya_script_release_path which is responsible for generating the release path
+          # If so, there should be a proc called maya_script_release_path 
+          # which is responsible for generating the release path
           # this smells a bit - not sure if it can be fixed - we will see
           ##############################################
           copy_keys = settings.keys.find_all {|el|  ( el.to_s =~ /^.*_copy_files$/)}
 
             # destination_path_proc = "#{identifier}_destination".to_sym
             destination_path_key = "#{identifier}_destination".to_sym
-
-
+            relative_path_key = "#{identifier}_relative".to_sym
 
             files = settings[k]
 
 
               files.each do |f|
 
+                # if the relative_path_key exists, it is the part of the path
+                # to strip away (along with the filename) to give a destination directory
+                # for the particular file. 
+                # Its good for when you want to release folders of stuff and keep the
+                # hierarchy in tact - such as python packages.
+                # Example - see medusa sanity
+                f_relative = ''
+                if settings.has_key? relative_path_key
+                  f_relative = File.dirname(f).gsub(settings[relative_path_key],'')
+                end
+
+                puts settings[relative_path_key]
+                puts f_relative
+                
+
                 if settings.has_key? destination_path_key
-                  destination_file = target.destination_filepath(settings[destination_path_key], f)
+                  rel_dest = File.join(settings[destination_path_key], f_relative)  
+
+                  destination_file = target.destination_filepath(rel_dest, f)
                 else
+
                   if target.respond_to?(destination_path_key)
                     destination_file = target.send destination_path_key, f
                   else
-                    destination_file = target.destination_filepath( '', f)
+                    destination_file = target.destination_filepath( f_relative, f)
                   end
                 end