Skip to content

Commit

Permalink
Closes #45 - image files now actually get returned!
Browse files Browse the repository at this point in the history
  • Loading branch information
walkeriniraq committed Jun 23, 2013
1 parent e7200a8 commit 5d6e465
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
kul (0.1.6)
kul (0.2.0)
andand (~> 1.3.3)
coffee-script (~> 2.2)
sass (~> 3.2.7)
Expand Down
4 changes: 4 additions & 0 deletions lib/kul/framework/route_type_list.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class Kul::RouteTypeList

def initialize
@file_extensions = %w(png jpg jpeg gif)
@extensions = {
'html' => [
{:extra_extension => '.erb', :instruction => :template},
Expand All @@ -24,11 +25,14 @@ def add_route_type(extension, instruction)
end

def handle_type?(extension)
return true if @file_extensions.include? extension
@extensions.keys.each { |key| return true if extension.end_with? key }
false
end

# TODO: add tests for this method
def route_type_listing(route)
yield :file, route.file_path if @file_extensions.include? route.extension
return unless handle_type? route.extension
@extensions[route.extension].each do |value|
yield value[:instruction], "#{route.file_path}#{value[:extra_extension]}"
Expand Down
12 changes: 12 additions & 0 deletions spec/kul/router_spec.rb → spec/kul/route_type_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@

context 'default router' do
context '#handle_extension?' do
it 'returns true for .png files' do
described_class.new.handle_type?('png').should be_true
end
it 'returns true for .jpg files' do
described_class.new.handle_type?('jpg').should be_true
end
it 'returns true for .jpeg files' do
described_class.new.handle_type?('jpeg').should be_true
end
it 'returns true for .gif files' do
described_class.new.handle_type?('gif').should be_true
end
it 'returns true for .js files' do
described_class.new.handle_type?('js').should be_true
end
Expand Down

0 comments on commit 5d6e465

Please sign in to comment.