class GettextI18nRails::BaseParser

Public Class Methods

libraries() click to toggle source
# File lib/gettext_i18n_rails/base_parser.rb, line 18
def self.libraries
  [extension]
end
load_library() click to toggle source
# File lib/gettext_i18n_rails/base_parser.rb, line 22
def self.load_library
  return true if @library_loaded

  loaded = libraries.detect do |library|
    if Gem::Specification.find_all_by_name(library).any?
      require library
      true
    else
      false
    end
  end

  unless loaded
    puts "No #{extension} library could be found: #{libraries.join(" or ")}"

    return false
  end

  require 'gettext_i18n_rails/ruby_gettext_extractor'
  @library_loaded = loaded
end
parse(file, _options = {}, msgids = []) click to toggle source
# File lib/gettext_i18n_rails/base_parser.rb, line 9
def self.parse(file, _options = {}, msgids = [])
  return msgids unless load_library
  code = convert_to_code(File.read(file))
  RubyGettextExtractor.parse_string(code, msgids, file)
rescue Racc::ParseError => e
  $stderr.puts "file ignored: ruby_parser cannot read #{extension} files with 1.9 syntax --- #{file}: (#{e.message.strip})"
  return msgids
end
target?(file) click to toggle source
# File lib/gettext_i18n_rails/base_parser.rb, line 5
def self.target?(file)
  File.extname(file) == ".#{extension}"
end