Module: QooxParser
- Defined in:
- lib/qooxview/helpers/qoox_parser.rb
Class Method Summary collapse
- .parse(file) ⇒ Object
-
.target?(file) ⇒ Boolean
If the file is the target of your parser, then return true, otherwise false.
Class Method Details
.parse(file) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/qooxview/helpers/qoox_parser.rb', line 13 def parse(file) ary = [] File.open( file ){|f| line = 0 f.readlines.each{|l| line += 1 if l =~ /^\s*value_[^\s]+\s+[^=]/ or l =~ /^\s*show_[^\s]+\s+[^=]/ or l =~ /^\s*vtlp_list\s+[^=]/ case l when /(value_block|show_block)/ when /(show_button|show_print)/ = l.sub( /^[^:]*:/, '' ).gsub( /:/, '' ).chop.split( /,\s*/ ) .each{|b| po = POEntry.new(:normal) po.msgid = b po.references = [ "#{file}:#{line}" ] po.add_comment( "Comes from file #{file} and line is #{l}" ) ary << po } else po = POEntry.new(:normal) po.msgid = l.sub( /^[^:]*:/, '' ).sub( /,.*/, '' ).chop po.references = [ "#{file}:#{line}" ] po.add_comment( "Comes from file #{file} and line is #{l}" ) ary << po end elsif l =~ /<\s*View\s*$/ po = POEntry.new(:normal) po.msgid = l.sub( /^\s*class\s*/, '' ).sub( /\s*<.*$/, '' ).chop po.references = [ "#{file}:#{line}" ] po.add_comment( "Comes from file #{file} and line is #{l}" ) ary << po end } } return ary end |
.target?(file) ⇒ Boolean
If the file is the target of your parser, then return true, otherwise false.
9 10 11 |
# File 'lib/qooxview/helpers/qoox_parser.rb', line 9 def target?(file) File.extname(file) == ".rb" end |