Class: OutputTask

Inherits:
Task show all
Defined in:
lib/tasks/output-task.rb

Direct Known Subclasses

MultipleOutputTask, SingleOutputTask

Instance Attribute Summary

Attributes inherited from Task

#assets, #included_files

Attributes inherited from Configurable

#options

Instance Method Summary collapse

Methods inherited from Task

available_tasks, #build_assets, by_name, #cleanup, #copy_assets, #copy_assets_orig, #document_files, #find_files, #finish, #handles_file?, #include_file, inherited, #need_to_build, #process_files, #replace_tokens, #symlink_assets, task_index, #task_name, task_name, #validate_files

Methods inherited from Configurable

#get_options, option, option_alias

Constructor Details

#initialize(target, options) ⇒ OutputTask

Returns a new instance of OutputTask.



12
13
14
15
16
17
# File 'lib/tasks/output-task.rb', line 12

def initialize(target, options)
  super(target, options)
  @files_to_exclude= @options.exclude.to_a
  @files_to_include= @options.include.to_a
  FileUtils.mkdir_p(output_folder)
end

Instance Method Details

#minify(source) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/tasks/output-task.rb', line 35

def minify(source)
	# Run the Y!UI Compressor
	buffer= ""
	
	IO.popen("java -jar #{$compressor} --type #{source_type}", "r+") { |pipe|
	  pipe.puts(source)
	  pipe.close_write
	  buffer= pipe.read
 }
 
  # buffer = `java -jar #{$compressor} --type #{type} #{working_file}`
	if ('css'==output_type)
		# puts each rule on its own line, and deletes @import statements
		return buffer.gsub(/\}/,"}\n").gsub(/.*@import url\(\".*\"\);/,'')
	else
		return buffer
	end
end

#notice_textObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/tasks/output-task.rb', line 54

def notice_text
  if (!@options.notice)
    return ""
  end
  
  if (nil==@notice_text)
    notice_file= @options.notice;
    if (!File.exists?(notice_file))
      @notice_text= ""
    else
      text= File.read(notice_file).strip
      text= "    #{text}".gsub(/\n/, "\n    ")
      @notice_text= "/*!\n#{text}\n*/\n\n"
    end
  end

  return @notice_text
end

#output_extensionObject



27
28
29
# File 'lib/tasks/output-task.rb', line 27

def output_extension
  output_type
end

#output_typeObject



19
20
21
# File 'lib/tasks/output-task.rb', line 19

def output_type
  nil
end

#productsObject



31
32
33
# File 'lib/tasks/output-task.rb', line 31

def products
  @products
end

#source_typeObject



23
24
25
# File 'lib/tasks/output-task.rb', line 23

def source_type
  output_type
end