Module: Spider::I18n::SHTMLParser

Defined in:
lib/spiderfw/i18n/shtml_parser.rb

Class Method Summary collapse

Class Method Details

.parse(file, ary) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/spiderfw/i18n/shtml_parser.rb', line 13

def parse(file, ary)
    f = File.new(file)
    cnt = 0
    f.each_line do |line|
        cnt += 1
        scanner = ::StringScanner.new(line)
        while scanner.scan_until(Spider::TemplateBlocks::GettextRegexp)
            str = scanner.matched
            str =~ Spider::TemplateBlocks::GettextRegexp
            found = false
            ary.each do |msg|
                if (msg[0] == $1)
                    msg << "#{file}:#{cnt}"
                    found = true
                    break
                end
            end
            ary << [$1, "#{file}:#{cnt}"] unless found
        end
    end
    f.close
    return ary    
end

.target?(file) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/spiderfw/i18n/shtml_parser.rb', line 9

def target?(file)
    File.extname(file) == '.shtml'
end