lib/mill/site.rb in mill-0.7.3 vs lib/mill/site.rb in mill-0.8
- old
+ new
@@ -263,33 +263,30 @@
end
private
def resource_class_for_file(file)
- MIME::Types.of(file.to_s).each do |type|
- if (klass = @file_types[type.content_type])
- return [klass, type]
- end
+ type = MIME::Types.of(file.to_s).first
+ if type && (klass = @file_types[type.content_type])
+ klass
+ else
+ Resource
end
- nil
end
def add_files
raise Error, "Input path not found: #{@input_dir}" unless @input_dir.exist?
@input_dir.find do |input_file|
if input_file.basename.to_s[0] == '.'
Find.prune
elsif input_file.directory?
# skip
- elsif (klass, type = resource_class_for_file(input_file))
+ else (klass = resource_class_for_file(input_file))
resource = klass.new(
input_file: input_file,
- output_file: @output_dir / input_file.relative_to(@input_dir),
- type: type)
+ output_file: @output_dir / input_file.relative_to(@input_dir))
add_resource(resource)
- else
- warn "Warning: can't determine resource of file: #{input_file} (#{MIME::Types.of(input_file.to_s).join(', ').inspect})"
end
end
end
def add_feed
@@ -328,10 +325,10 @@
key: @google_site_verification)
add_resource(resource)
end
def add_htpasswd
- resource = Resource::Other.new(
+ resource = Resource.new(
input_file: @htpasswd_file,
output_file: @output_dir / '.htpasswd')
add_resource(resource)
end
\ No newline at end of file