Class: Distil::Product
Instance Attribute Summary collapse
Attributes inherited from Configurable
#options
Instance Method Summary
collapse
#get_option, #get_options, option
Constructor Details
#initialize(settings, target) ⇒ Product
Returns a new instance of Product.
14
15
16
17
18
19
|
# File 'lib/distil/product.rb', line 14
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.
11
12
13
|
# File 'lib/distil/product.rb', line 11
def assets
@assets
end
|
#join_string ⇒ Object
Returns the value of attribute join_string.
11
12
13
|
# File 'lib/distil/product.rb', line 11
def join_string
@join_string
end
|
#target ⇒ Object
Returns the value of attribute target.
11
12
13
|
# File 'lib/distil/product.rb', line 11
def target
@target
end
|
Instance Method Details
#can_embed_file?(file) ⇒ Boolean
21
22
23
|
# File 'lib/distil/product.rb', line 21
def can_embed_file?(file)
false
end
|
#filename ⇒ Object
70
71
72
|
# File 'lib/distil/product.rb', line 70
def filename
raise NotImplementedError.new("This product does not implement the filename method.")
end
|
#files ⇒ Object
29
30
31
|
# File 'lib/distil/product.rb', line 29
def files
@files
end
|
#files=(fileset) ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/distil/product.rb', line 33
def files=(fileset)
fileset.each { |f|
next if !handles_file?(f)
@files << f
@assets.merge(f.assets)
}
end
|
#handles_file?(file) ⇒ Boolean
25
26
27
|
# File 'lib/distil/product.rb', line 25
def handles_file?(file)
[extension].include?(file.extension)
end
|
#relative_path(file) ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/distil/product.rb', line 78
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/distil/product.rb', line 41
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
}
return @up_to_date=false if (output_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=false if (output_modified < max_asset_modified)
@up_to_date= true
end
|
#write_output ⇒ Object
74
75
76
|
# File 'lib/distil/product.rb', line 74
def write_output
raise NotImplementedError.new("No write_output method has been defined for this product.")
end
|