instance methods
instance methods
instance methods
instance methods
# File lib/synthesis/asset_package.rb, line 61 def build_all @@asset_packages_yml.keys.each do |asset_type| @@asset_packages_yml[asset_type].each { |p| self.new(asset_type, p).build } end end
# File lib/synthesis/asset_package.rb, line 73 def create_yml unless File.exists?("#{config.root}/config/asset_packages.yml") asset_yml = Hash.new asset_yml['javascripts'] = [{"base" => build_file_list("#{config.root}/public/javascripts", "js")}] asset_yml['stylesheets'] = [{"base" => build_file_list("#{config.root}/public/stylesheets", "css")}] File.open("#{config.root}/config/asset_packages.yml", "w") do |out| YAML.dump(asset_yml, out) end log "config/asset_packages.yml example file created!" log "Please reorder files under 'base' so dependencies are loaded in correct order." else log "config/asset_packages.yml already exists. Aborting task..." end end
# File lib/synthesis/asset_package.rb, line 67 def delete_all @@asset_packages_yml.keys.each do |asset_type| @@asset_packages_yml[asset_type].each { |p| self.new(asset_type, p).delete_previous_build } end end
# File lib/synthesis/asset_package.rb, line 32 def find_by_source(asset_type, source) path_parts = parse_path(source) package_hash = @@asset_packages_yml[asset_type].find do |p| key = p.keys.first p[key].include?(path_parts[2]) && (parse_path(key)[1] == path_parts[1]) end package_hash ? self.new(asset_type, package_hash) : nil end
# File lib/synthesis/asset_package.rb, line 27 def find_by_target(asset_type, target) package_hash = @@asset_packages_yml[asset_type].find {|p| p.keys.first == target } package_hash ? self.new(asset_type, package_hash) : nil end
# File lib/synthesis/asset_package.rb, line 23 def find_by_type(asset_type) @@asset_packages_yml[asset_type].map { |p| self.new(asset_type, p) } end
# File lib/synthesis/asset_package.rb, line 15 def merge_environments @@merge_environments ||= ["production"] end
# File lib/synthesis/asset_package.rb, line 11 def merge_environments=(environments) @@merge_environments = environments end
# File lib/synthesis/asset_package.rb, line 96 def initialize(asset_type, package_hash) target_parts = self.class.parse_path(package_hash.keys.first) @target_dir = target_parts[1].to_s @target = target_parts[2].to_s @sources = package_hash[package_hash.keys.first] @asset_type = asset_type @asset_path = ($asset_base_path ? "#{$asset_base_path}/" : "#{RAILS_ROOT}/public/") + "#{@asset_type}#{@target_dir.gsub(/^(.+)$/, '/\1')}" @extension = get_extension @file_name = "#{@target}_packaged.#{@extension}" @full_path = File.join(@asset_path, @file_name) end
# File lib/synthesis/asset_package.rb, line 19 def parse_path(path) /^(?:(.*)\/)?([^\/]+)$/.match(path).to_a end
# File lib/synthesis/asset_package.rb, line 50 def sources_from_targets(asset_type, targets) source_names = Array.new targets.each do |target| package = find_by_target(asset_type, target) source_names += (package ? package.sources.collect do |src| package.target_dir.gsub(/^(.+)$/, '\1/') + src end : target.to_a) end source_names.uniq end
# File lib/synthesis/asset_package.rb, line 41 def targets_from_sources(asset_type, sources) package_names = Array.new sources.each do |source| package = find_by_target(asset_type, source) || find_by_source(asset_type, source) package_names << (package ? package.current_file : source) end package_names.uniq end
# File lib/synthesis/asset_package.rb, line 120 def build delete_previous_build create_new_build end
# File lib/synthesis/asset_package.rb, line 113 def current_file build unless package_exists? path = @target_dir.gsub(/^(.+)$/, '\1/') "#{path}#{@target}_packaged" end
# File lib/synthesis/asset_package.rb, line 125 def delete_previous_build File.delete(@full_path) if File.exists?(@full_path) end
# File lib/synthesis/asset_package.rb, line 109 def package_exists? File.exists?(@full_path) end