From 020b783b02ed7e31f4b96cda856b1e0d29b6b355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 28 Apr 2014 14:32:39 +0200 Subject: skeleton.rb: use extension before filetype to find a skeleton --- skeletons.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/skeletons.rb b/skeletons.rb index 144116b..f88ae49 100755 --- a/skeletons.rb +++ b/skeletons.rb @@ -10,11 +10,12 @@ EXTENSION = "erb" filepath, filetype = ARGV filename = File.basename( filepath ) +extension = File.extname( filename ).split( '.' )[1] if filename =~ /\.h$/ then filetype='c_header'; end # otherwise filetype is cpp -if filetype.nil? then filetype = File.extname( filename ).split( '.' )[1] ; end +if filetype.nil? then filetype = extension; end -skeleton = [ filename, filetype ].map { |s| File.join( SKELETON_DIR, "#{s}.#{EXTENSION}" ) }.find { |s| File.exist?(s) && File.readable?(s) } +skeleton = [ filename, extension, filetype ].map { |s| File.join( SKELETON_DIR, "#{s}.#{EXTENSION}" ) }.find { |s| File.exist?(s) && File.readable?(s) } exit if skeleton.nil? -- cgit v1.1-2-g2b99