Module: Flak::Template::Environment::Tasks
- Defined in:
- lib/flak/rake/templates/environment.rb
Class Method Summary collapse
- .extended(target) ⇒ Object
- .generate_copy_tasks(target) ⇒ Object
-
.generate_erb_tasks(target) ⇒ Object
We want to release erb files by binding them using ERB.
- .generate_inspect_and_release_tasks(target) ⇒ Object
- .task_factory(target) ⇒ Object
Class Method Details
.extended(target) ⇒ Object
49 50 51 |
# File 'lib/flak/rake/templates/environment.rb', line 49 def self.extended target task_factory target end |
.generate_copy_tasks(target) ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/flak/rake/templates/environment.rb', line 106 def self.generate_copy_tasks target settings = target.settings namespace settings[:name].to_sym do # 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 # 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$/)} copy_keys.each do |k| identifier = k.to_s.gsub("_copy_files", "") # destination_path_proc = "#{identifier}_destination".to_sym destination_path_key = "#{identifier}_destination".to_sym files = settings[k] unless files.nil? files.each do |f| if settings.has_key? destination_path_key destination_file = target.destination_filepath(settings[destination_path_key], f) else if target.respond_to?(destination_path_key) destination_file = target.send destination_path_key, f else destination_file = target.destination_filepath( '', f) end end file destination_file => f do target.make_directory_for(destination_file) sh "cp -r #{f} #{destination_file}" File.chmod 0755, destination_file end task :release => destination_file end end end ############################################## end end |
.generate_erb_tasks(target) ⇒ Object
We want to release erb files by binding them using ERB. To help identify erb files we define them as Filelists in yaml files under the key <identifier>_erb_files e.g. shell_erb_files or maya_script_erb_files for the identifiers: shell, and maya_script respectively
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/flak/rake/templates/environment.rb', line 58 def self.generate_erb_tasks target settings = target.settings namespace settings[:name].to_sym do erb_keys = settings.keys.find_all {|el| ( el.to_s =~ /^.*_erb_files$/)} erb_keys.each do |k| 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 write_erb_opts = {:chmod => 0755} files = settings[k] unless files.nil? files.each do |f| if settings.has_key? destination_path_key destination_file = target.destination_filepath( settings[destination_path_key], f) else if target.respond_to?(destination_path_key) destination_file = target.send destination_path_key, f else destination_file = target.destination_filepath( '', f) end end file destination_file => f do target.make_directory_for(destination_file) target.write_erb_template(f,destination_file,write_erb_opts) end # desc "bind and release ERB #{destination_file.pathmap('%f')}" task destination_file.pathmap('%f') => destination_file task :release => destination_file.pathmap('%f') end end end end end |
.generate_inspect_and_release_tasks(target) ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/flak/rake/templates/environment.rb', line 158 def self.generate_inspect_and_release_tasks target settings = target.settings namespace settings[:name].to_sym do desc "See resolved configuration settings for #{settings[:name].to_sym}" task :inspect do ap settings end desc "Release #{settings[:name].to_sym}" task :release end task :release => "#{settings[:name].to_sym}:release" end |
.task_factory(target) ⇒ Object
176 177 178 179 180 |
# File 'lib/flak/rake/templates/environment.rb', line 176 def self.task_factory target self.generate_erb_tasks target self.generate_copy_tasks target self.generate_inspect_and_release_tasks target end |