Class: Distil::Product
Instance Attribute Summary collapse
Attributes inherited from Configurable
#options
Instance Method Summary
collapse
#error, error, #ignore_warnings, #ignore_warnings=, #report, warning, #warning
#get_option, #get_options, option
Constructor Details
#initialize(settings, target) ⇒ Product
Returns a new instance of Product.
16
17
18
19
20
21
|
# File 'lib/distil/product.rb', line 16
def initialize(settings, target)
@target= target
@files= []
@assets= Set.new
super(settings, target)
end
|
Instance Attribute Details
#assets ⇒ Object
Returns the value of attribute assets.
13
14
15
|
# File 'lib/distil/product.rb', line 13
def assets
@assets
end
|
#join_string ⇒ Object
Returns the value of attribute join_string.
13
14
15
|
# File 'lib/distil/product.rb', line 13
def join_string
@join_string
end
|
#target ⇒ Object
Returns the value of attribute target.
13
14
15
|
# File 'lib/distil/product.rb', line 13
def target
@target
end
|
Instance Method Details
#can_embed_file?(file) ⇒ Boolean
23
24
25
|
# File 'lib/distil/product.rb', line 23
def can_embed_file?(file)
false
end
|
#clean ⇒ Object
80
81
82
|
# File 'lib/distil/product.rb', line 80
def clean
FileUtils.rm filename if File.exist? filename
end
|
#external_files ⇒ Object
35
36
37
|
# File 'lib/distil/product.rb', line 35
def external_files
[]
end
|
#filename ⇒ Object
72
73
74
|
# File 'lib/distil/product.rb', line 72
def filename
raise NotImplementedError.new("This product does not implement the filename method.")
end
|
#files ⇒ Object
31
32
33
|
# File 'lib/distil/product.rb', line 31
def files
@files
end
|
#files=(fileset) ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/distil/product.rb', line 39
def files=(fileset)
fileset.each { |f|
next if !handles_file?(f)
@files << f
@assets.merge(f.assets)
}
end
|
#handles_file?(file) ⇒ Boolean
27
28
29
|
# File 'lib/distil/product.rb', line 27
def handles_file?(file)
[extension].include?(file.extension)
end
|
#relative_path(file) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/distil/product.rb', line 84
def relative_path(file)
file=SourceFile.from_path(file) if file.is_a?(String)
file_path= file.full_path
output_folder= target.project.output_folder
source_folder= target.project.source_folder
path=file.relative_to_folder(source_folder) if 0==file_path.index(source_folder)
path=file.relative_to_folder(output_folder) if 0==file_path.index(output_folder)
path
end
|
#up_to_date ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/distil/product.rb', line 47
def up_to_date
return @up_to_date if !@up_to_date.nil?
return false if force
return @up_to_date=false if !File.exists?(filename)
output_modified= File.stat(filename).mtime
max_asset_modified= File.stat(target.project.project_file).mtime
assets.each { |f|
max_asset_modified= f.last_modified if f.last_modified > max_asset_modified
}
files.each { |f|
max_asset_modified= f.last_modified if f.last_modified > max_asset_modified
}
external_files.each { |f|
next if !File.exist?(f)
last_modified= File.stat(f).mtime
max_asset_modified= last_modified if last_modified > max_asset_modified
}
return @up_to_date=(output_modified > max_asset_modified)
end
|
#write_output ⇒ Object
76
77
78
|
# File 'lib/distil/product.rb', line 76
def write_output
raise NotImplementedError.new("No write_output method has been defined for this product.")
end
|