Class: Fdlint::Helper::CodeType
- Defined in:
- lib/fdlint/helper/code_type.rb
Class Method Summary collapse
- .guess(text, filename = nil) ⇒ Object
- .guess_by_content(text) ⇒ Object
- .guess_by_name(filename) ⇒ Object
- .scope(filename) ⇒ Object
- .style_file?(filename) ⇒ Boolean
Class Method Details
.guess(text, filename = nil) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/fdlint/helper/code_type.rb', line 8 def guess(text, filename=nil) if filename && !filename.empty? guess_by_name filename else guess_by_content text end end |
.guess_by_content(text) ⇒ Object
27 28 29 30 31 |
# File 'lib/fdlint/helper/code_type.rb', line 27 def guess_by_content(text) return :html if html? text return :css if css? text :js #TODO: support more code syntaxes end |
.guess_by_name(filename) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fdlint/helper/code_type.rb', line 16 def guess_by_name( filename ) case File.extname( filename ) when /\.css$/i :css when /\.js$/i :js else :html #TODO: support more suffix end end |
.scope(filename) ⇒ Object
37 38 39 |
# File 'lib/fdlint/helper/code_type.rb', line 37 def scope(filename) filename =~ /[\\\/]lib[\\\/]/ ? 'lib' : 'page' end |
.style_file?(filename) ⇒ Boolean
33 34 35 |
# File 'lib/fdlint/helper/code_type.rb', line 33 def style_file?(filename) File.extname( filename ) =~ /(css|js|html?)$/i end |